+ /* Request substructure redirect */
+ events = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
+ XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY;
+ cookie = xcb_change_window_attributes_checked(conn, root,
+ XCB_CW_EVENT_MASK, &events);
+ if ((err = xcb_request_check(conn, cookie)))
+ error("another window manager is already running");
+
+ /* Setup X Atoms */
+ wm_protos = do_intern_atom("WM_PROTOCOLS");
+ wm_delete = do_intern_atom("WM_DELETE_WINDOW");
+ if (!wm_protos || !wm_delete)
+ error("unable to setup atoms");
+
+ /* Setup EWMH connection */
+ if (!do_ewmh_init_atoms())
+ error("ewmh setup failed");
+
+ /* Set EWMH wm window */
+ uint32_t override = 1;
+ control = xcb_generate_id(conn);
+ printf("control window: %d\n", control);
+ cookie = xcb_create_window_checked(conn, 0, control, root,
+ 0, 0, 1, 1, 0, 0, 0,
+ XCB_CW_OVERRIDE_REDIRECT, &override);
+ if ((err = xcb_request_check(conn, cookie)))
+ error("can't create control window");
+ cookie = xcb_ewmh_set_wm_name_checked(&ewmh, control, 5, "wmpus");
+ if ((err = xcb_request_check(conn, cookie)))
+ error("can't set wm name");
+ cookie = xcb_ewmh_set_supporting_wm_check_checked(&ewmh, root, control);
+ if ((err = xcb_request_check(conn, cookie)))
+ error("can't set control window");
+