[Xcb] is it possible to monitor events in other windows?

Patrick patrick at spellingbeewinnars.org
Mon Oct 20 07:59:53 PDT 2014


Thanks Chris

I haven't found anywhere else to post about xcb, could you point me 
somewhere?

There are not a lot of xcb examples floating around, I do have xlib 
books but it's quite the learning curve for both xlib and xcb. I have a 
lot of amateur questions, i don't want to bog down the development list.

Thanks again



On 14-10-20 10:53 AM, Christian Linhart wrote:
> Hi Patrick,
>
> The function xcb_wait_for_event does not have an implicit window passed.
> It waits for all events that have been selected using the appropriate X11-requests.
>
> There are X11-requests for selecting which events your application subscribes to for which window.
>
> Please read the man-pages for the Xlib-functions
> 	XSelectInput
> and
> 	XSelectExtensionEvent
> for details.
>
> Selecting events via XCB is similar to the Xlib-functions.
> You just have to use the underlying X11-request.
>
> Hope this helps,
>
> Chris
>
> P.S.: This mailinglist is primarily for the development for XCB itself.
> For questions about X11-programming, with or without XCB, there may be better forums or websites.
>
> On 10/20/14 16:00, Patrick wrote:
>> Hi Everyone
>>
>> So this is a bit of a long story and to keep it suitable for the mailing list, I am basically trying to monitor mouse clicks in a terminal under X as opposed to using gpm through ncurses.
>>
>> I have chopped down an example from freedsktop.org and I have it pasted at the end of this email.
>>
>> This is the part I am confused about:
>> xcb_wait_for_event (c)
>>
>>
>> This is responding to events in the window created but is the windows ID passed implicitly ? Is there a way to pass another windows ID ? I am basically planning on creating a small xcb program that will take the window ID of the terminal that the program is running in, I don't want to create another window.
>>
>> Thanks for reading my post-Patrick
>>
>>
>>
>>
>> code-->---------------------------->
>>
>> #include <stdlib.h>
>> #include <stdio.h>
>> #include <xcb/xcb.h>
>>
>> int main (int argc, int * argv[])
>> {
>>    xcb_connection_t    *c;
>>    xcb_screen_t        *screen;
>>    xcb_window_t         win;
>>    xcb_generic_event_t *e;
>>    uint32_t             mask = 0;
>>    uint32_t             values[2];
>>
>>    /* Open the connection to the X server */
>>    c = xcb_connect (NULL, NULL);
>>
>>    /* Get the first screen */
>>    screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data;
>>
>>    /* Ask for our window's Id */
>>    win = xcb_generate_id (c);
>> //  win = 65574484 ;
>>
>>    /* Create the window */
>>    mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
>>    values[0] = screen->white_pixel;
>>    values[1] = XCB_EVENT_MASK_EXPOSURE  | XCB_EVENT_MASK_BUTTON_PRESS   | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_KEY_PRESS      | XCB_EVENT_MASK_KEY_RELEASE;
>>    xcb_create_window (c,                             /* Connection          */
>>                       0,                             /* depth               */
>>                       win,                           /* window Id           */
>>                       screen->root,                  /* parent window       */
>>                       0, 0,                          /* x, y                */
>>                       150, 150,                      /* width, height       */
>>                       10,                            /* border_width        */
>>                       XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class               */
>>                       screen->root_visual,           /* visual              */
>>                       mask, values);                 /* masks */
>>
>>    /* Map the window on the screen */
>>    xcb_map_window (c, win);
>>    xcb_flush (c);
>> //CONFUSED HERE
>>    while (    (e = xcb_wait_for_event (c) )      ) {
>>      switch (e->response_type & ~0x80) {
>>
>>                      case XCB_BUTTON_RELEASE: {
>>                      xcb_button_release_event_t *ev = (xcb_button_release_event_t *)e;
>>                      printf ("Button %d released in window %ld, at coordinates (%d,%d)\n",  ev->detail, ev->event, ev->event_x, ev->event_y);
>>                      break;
>>                      }
>>
>>                 case XCB_KEY_PRESS: {
>>                 xcb_key_press_event_t *ev = (xcb_key_press_event_t *)e;
>>                 printf ("Key pressed in window %ld\n", ev->event);
>>                 break;
>>                 }
>>      case XCB_KEY_RELEASE: {
>>      xcb_key_release_event_t *ev = (xcb_key_release_event_t *)e;
>>      printf ("Key released in window %ld\n",  ev->event);
>>      break;
>>      }
>>      default:
>>      ;
>>      break;
>>      }
>> /* Free the Generic Event */
>> free (e);
>> }
>>
>>    return 0;
>> }
>> _______________________________________________
>> Xcb mailing list
>> Xcb at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/xcb
>>
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb
>



More information about the Xcb mailing list