Example #1
0
void QXcbWindow::setVisible(bool visible)
{
    xcb_wm_hints_t hints;
    if (visible) {
        if (widget()->isMinimized())
            xcb_wm_hints_set_iconic(&hints);
        else
            xcb_wm_hints_set_normal(&hints);
        xcb_set_wm_hints(xcb_connection(), m_window, &hints);
        Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window));
        connection()->sync();
    } else {
        Q_XCB_CALL(xcb_unmap_window(xcb_connection(), m_window));

        // send synthetic UnmapNotify event according to icccm 4.1.4
        xcb_unmap_notify_event_t event;
        event.response_type = XCB_UNMAP_NOTIFY;
        event.sequence = 0; // does this matter?
        event.event = m_screen->root();
        event.window = m_window;
        event.from_configure = false;
        Q_XCB_CALL(xcb_send_event(xcb_connection(), false, m_screen->root(),
                                  XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event));

        xcb_flush(xcb_connection());
    }
}
Example #2
0
File: cawc.c Project: 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;
}