void Compositor::registerCompositor(QWindow *w) { xcb_ewmh_set_wm_cm_owner(&ewmh_, QX11Info::appScreen(), w->winId(), QX11Info::getTimestamp(), 0, 0); auto wmCmCookie = xcb_ewmh_get_wm_cm_owner_unchecked(&ewmh_, QX11Info::appScreen()); xcb_window_t wmCmOwnerWin = XCB_NONE; if (!xcb_ewmh_get_wm_cm_owner_reply(&ewmh_, wmCmCookie, &wmCmOwnerWin, Q_NULLPTR)) { qFatal("Cannot check _NET_WM_CM_Sn"); } if (wmCmOwnerWin != w->winId()) { qFatal("Another compositing manager is already running"); } }
/** Handler for PropertyNotify event meaningful to set the timestamp * (given in the PropertyNotify event field) when acquiring the * ownership of _NET_WM_CM_Sn using SetOwner request (as specified in * ICCCM and EWMH) * * \see display_register_cm * \param event The X PropertyNotify event */ void display_event_set_owner_property(xcb_property_notify_event_t *event) { debug("Set _NET_WM_CM_Sn ownership"); /* Set ownership on _NET_WM_CM_Sn giving the Compositing Manager window */ xcb_ewmh_set_wm_cm_owner(&globalconf.ewmh, globalconf.screen_nbr, globalconf.cm_window, event->time, 0, 0); /* Send request to check whether the ownership succeeded */ _get_wm_cm_owner_cookie = xcb_ewmh_get_wm_cm_owner_unchecked(&globalconf.ewmh, globalconf.screen_nbr); }
void create_wm_cm_window(xcwm_context_t *context) { context->wm_cm_window = xcb_generate_id(context->conn); printf("Created WM/CM window with XID 0x%08x\n", context->wm_cm_window); xcb_create_window(context->conn, XCB_COPY_FROM_PARENT, context->wm_cm_window, context->root_window->window_id, 0, 0, 1, 1, 0, /* 1x1 size, no border */ XCB_COPY_FROM_PARENT, XCB_COPY_FROM_PARENT, 0, NULL); /* Set the name for the window */ xcb_ewmh_set_wm_name(&context->atoms.ewmh_conn, context->wm_cm_window, strlen("xcwm"), "xcwm"); /* Set the atoms for the window */ xcb_ewmh_set_supporting_wm_check(&context->atoms.ewmh_conn, context->root_window->window_id, context->wm_cm_window); xcb_ewmh_set_supporting_wm_check(&context->atoms.ewmh_conn, context->wm_cm_window, context->wm_cm_window); /* Take & announce ownership of the _NET_CM_Sn selection */ xcb_ewmh_set_wm_cm_owner(&context->atoms.ewmh_conn, context->conn_screen, context->wm_cm_window, XCB_CURRENT_TIME, 0, 0); /* Likewise WM_Sn selection */ /* XXX: Need to do this in a way which complies with ICCCM "Manager Selections" i.e. use an actual timestamp, so in the case of races, we either acquire selection or don't */ }