8 /* inherits from xcb_screen_t */
12 xcb_window_t selwin; /* for the selection */
15 static xcb_connection_t *conn;
16 static const xcb_setup_t *setup;
17 static d_screen_t *screens = NULL;
20 register_screen (d_screen_t *sc)
25 xcb_intern_atom_cookie_t ack;
26 xcb_intern_atom_reply_t *arep;
27 xcb_get_selection_owner_cookie_t sck;
28 xcb_get_selection_owner_reply_t *srep;
31 w = xcb_generate_id(conn);
32 xcb_create_window(conn, XCB_COPY_FROM_PARENT, w, sc->super.root,
33 0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_ONLY,
34 sc->super.root_visual, 0, NULL);
36 name = g_strdup_printf("_NET_WM_CM_S%d", sc->num);
37 ack = xcb_intern_atom(conn, FALSE, strlen(name), name);
38 arep = xcb_intern_atom_reply(conn, ack, NULL);
41 sck = xcb_get_selection_owner(conn, arep->atom);
42 srep = xcb_get_selection_owner_reply(conn, sck, NULL);
43 taken = !!srep->owner;
46 printf(_("screen %d already has a composite manager, skipping\n"),
51 xcb_set_selection_owner(conn, w, arep->atom, XCB_CURRENT_TIME);
52 sck = xcb_get_selection_owner(conn, arep->atom);
53 srep = xcb_get_selection_owner_reply(conn, sck, NULL);
54 taken = srep->owner == w;
60 xcb_destroy_window(conn, w);
68 xcb_screen_iterator_t it;
73 for (it = xcb_setup_roots_iterator(setup); it.rem; xcb_screen_next(&it)) {
76 if (register_screen(&sc)) {
78 screens = g_renew(d_screen_t, screens, count);
79 screens[count-1] = sc;
80 printf(_("managing screen %d\n"), sc.num);
87 main(int argc, char **argv)
89 conn = xcb_connect(NULL, NULL);
91 printf(_("Unable to connect to display\n"));
94 setup = xcb_get_setup(conn);