Advertisement
adilima

XCB: Catch Substructure Redirect Error

Oct 30th, 2011
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1. static int redirect(xcb_connection_t* conn)
  2. {
  3.     xcb_screen_iterator_t iter;
  4.     uint32_t root_redirect_values[] = {
  5.         XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
  6.         XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_COLOR_MAP_CHANGE |
  7.         XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
  8.         XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
  9.         XCB_EVENT_MASK_KEY_PRESS
  10.     };
  11.  
  12.     /* this assume conn has been initialized */
  13.     iter = xcb_setup_roots_iterator(xcb_get_setup(conn));
  14.    
  15.     while (iter.rem) {
  16.         xcb_screen_t* screen = iter.data;
  17.         xcb_void_cookie_t cookie;
  18.         xcb_generic_error_t* error;
  19.                
  20.         cookie = xcb_change_window_attributes_checked(conn, screen->root, XCB_CW_EVENT_MASK, root_redirect_values);
  21.         xcb_flush(conn);
  22.         if (error = xcb_request_check(conn, cookie)) {
  23.             /*
  24.              * Unable to redirect... another window manager is running...?
  25.              */
  26.             fprintf(stderr, "Unable to redirect, another window manager is running...\nerror code: %d\n",
  27.                     error->error_code);
  28.             return false;
  29.         }
  30.         fprintf(stdout, "Redirecting root window of screen %p succeeded...\n", screen);
  31.        
  32.         /* do some initial setup for this screen */
  33.        
  34.         xcb_screen_next(&iter);
  35.     }
  36.     return true;
  37. }
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement