11 all_screens(xcb_connection_t *conn, d_screen_t **list)
13 static const xcb_setup_t *setup;
14 xcb_screen_iterator_t it;
18 setup = xcb_get_setup(conn);
21 for (it = xcb_setup_roots_iterator(setup); it.rem; xcb_screen_next(&it)) {
25 if (screen_register(&sc)) {
27 *list = g_renew(d_screen_t, *list, count);
28 (*list)[count-1] = sc;
29 printf(_("managing screen %d\n"), sc.num);
36 screen_from_root(d_screen_t *list, int n, xcb_window_t root)
39 for (i = 0; i < n; ++i)
40 if (list->super.root == root) return &list[i];
41 g_assert_not_reached();
46 main(int argc, char **argv)
48 xcb_connection_t *conn;
49 d_screen_t *screens = NULL;
51 xcb_generic_event_t *ev;
53 conn = xcb_connect(NULL, NULL);
55 printf(_("Unable to connect to display\n"));
59 nscreens = all_screens(conn, &screens);
61 printf(_("found no screens to run on\n"));
66 while (ev = xcb_wait_for_event(conn)) {
68 switch (ev->response_type & ~0x80) {
69 case XCB_CREATE_WINDOW:
71 xcb_create_notify_event_t *cev = (xcb_create_notify_event_t*)ev;
72 d_screen_t *sc = screen_from_root(screens, nscreens, cev->parent);
73 screen_add_window(sc, cev);
75 case XCB_DESTROY_WINDOW:
77 xcb_destroy_notify_event_t *dev = (xcb_destroy_notify_event_t*)ev;
78 d_screen_t *sc = screen_from_root(screens, nscreens, dev->event);
79 d_window_t *w = screen_find_window(sc, dev->window);
80 screen_hide_window(sc, w);
81 screen_remove_window(sc, w);
83 case XCB_REPARENT_WINDOW: