Esempio n. 1
0
/** Update the size hints of a client.
 * \param c The client.
 */
void
property_update_wm_normal_hints(client_t *c, xcb_get_property_reply_t *reply)
{
    if(reply)
    {
        if(!xcb_get_wm_size_hints_from_reply(&c->size_hints, reply))
            return;
    }
    else
    {
        if(!xcb_get_wm_normal_hints_reply(globalconf.connection,
                                          xcb_get_wm_normal_hints_unchecked(globalconf.connection,
                                                                            c->win),
                                          &c->size_hints, NULL))
            return;
    }

    if((c->size_hints.flags & XCB_SIZE_HINT_P_SIZE))
    {
        c->basew = c->size_hints.base_width;
        c->baseh = c->size_hints.base_height;
    }
    else if((c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE))
    {
        c->basew = c->size_hints.min_width;
        c->baseh = c->size_hints.min_height;
    }
    else
        c->basew = c->baseh = 0;

    if((c->size_hints.flags & XCB_SIZE_HINT_P_RESIZE_INC))
    {
        c->incw = c->size_hints.width_inc;
        c->inch = c->size_hints.height_inc;
    }
    else
        c->incw = c->inch = 0;

    if((c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE))
    {
        c->maxw = c->size_hints.max_width;
        c->maxh = c->size_hints.max_height;
    }
    else
        c->maxw = c->maxh = 0;

    if((c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE))
    {
        c->minw = c->size_hints.min_width;
        c->minh = c->size_hints.min_height;
    }
    else if((c->size_hints.flags & XCB_SIZE_HINT_BASE_SIZE))
    {
        c->minw = c->size_hints.base_width;
        c->minh = c->size_hints.base_height;
    }
    else
        c->minw = c->minh = 0;

    if((c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT))
    {
        c->minax = c->size_hints.min_aspect_num;
        c->minay = c->size_hints.min_aspect_den;
        c->maxax = c->size_hints.max_aspect_num;
        c->maxay = c->size_hints.max_aspect_den;
    }
    else
        c->minax = c->maxax = c->minay = c->maxay = 0;

    c->hassizehints = !(!c->basew && !c->baseh && !c->incw && !c->inch
                        && !c->maxw && !c->maxh && !c->minw && !c->minh
                        && !c->minax && !c->maxax && !c->minax && !c->minay);
}
Esempio n. 2
0
File: cawc.c Progetto: Roger/caw
static PyObject *
_set_hints(PyObject *self, PyObject *args)
{
    xcb_connection_t *connection;
    xcb_window_t window;
    int x, y, w, h;
    xcb_wm_hints_t hints;
    xcb_size_hints_t normal_hints;
    //xcb_generic_error_t *e;

    if (!PyArg_ParseTuple(args, "lIiiii", &connection, &window, &x, &y, &w, &h))
        return NULL;

    /*
       this is now done on the python side
    data[0] = 0xffffffff;
    xcb_change_property(connection, XCB_PROP_MODE_REPLACE,
            window, atoms[_NET_WM_DESKTOP], CARDINAL,
            32, 1, data);

    data[0] = atoms[_NET_WM_WINDOW_TYPE_DOCK];
    xcb_change_property(connection, XCB_PROP_MODE_REPLACE,
            window, atoms[_NET_WM_WINDOW_TYPE], ATOM,
            32, 1, data);
            */

    // send requests
    xcb_get_property_cookie_t hint_c = xcb_get_wm_hints(connection, window);
    xcb_get_property_cookie_t normal_hints_c = xcb_get_wm_normal_hints(connection, window);


    // set wm hints
    xcb_get_wm_hints_reply(connection, hint_c, &hints, 0);
    xcb_wm_hints_set_input(&hints, 0);
    xcb_wm_hints_set_normal(&hints);
    xcb_set_wm_hints(connection, window, &hints);


    // set the normal hints
    xcb_get_wm_normal_hints_reply(connection, normal_hints_c, &normal_hints, 0);

    //printf("w: %d, h: %d\n", w, h);
    normal_hints.flags = XCB_SIZE_HINT_P_POSITION;
    xcb_size_hints_set_position(&normal_hints, 0, x, y);
    xcb_size_hints_set_min_size(&normal_hints, w, h);
    xcb_size_hints_set_max_size(&normal_hints, w, h);

    xcb_set_wm_normal_hints(connection, window, &normal_hints);

    /*
    data[0] = atoms[_NET_WM_STATE_SKIP_TASKBAR];
    data[1] = atoms[_NET_WM_STATE_SKIP_PAGER];
    data[2] = atoms[_NET_WM_STATE_STICKY];
    data[3] = atoms[_NET_WM_STATE_ABOVE];

    xcb_change_property(connection, XCB_PROP_MODE_REPLACE,
            window, atoms[_NET_WM_STATE], ATOM,
            32, 4, data);
            */

    Py_RETURN_NONE;
}