[Xcb] An xcb/xtest newbie question

Jon Shemitz jshemitz at sta.samsung.com
Mon Oct 11 13:52:06 PDT 2010


Thanks. After I posted, I found some sample code that did just that, and it does the trick for key events. It doesn't seem to work yet for mouse motion, but it's not impossible that this is being confounded by vnc-ing to the X server I'm generating fake events for ....

-----Original Message-----
From: Josh Triplett [mailto:josh at joshtriplett.org] 
Sent: Monday, October 11, 2010 12:22 PM
To: Jon Shemitz
Cc: xcb at lists.freedesktop.org
Subject: Re: [Xcb] An xcb/xtest newbie question

On Mon, Oct 11, 2010 at 01:03:22PM -0500, Jon Shemitz wrote:
> I am trying to use xtest to fake keyboard and mouse events. My daemon seems to connect to X via xcb just fine:  xcb_connect(NULL, NULL) returns a non-NULL xcb_window_t. I can call xcb_get_setup and xcb_setup_roots_iterator and get a root window handle that agrees with xwininfo. But I am having no luck at all with xcb_test_fake_input.
> 
> I call
> 
>     xcb_void_cookie_t cookie =
>     xcb_test_fake_input(xcb,
>         /* type */      MOTION_NOTIFY, /*=6*/
>         /* detail */    0, //relative ? 1 : 0,
>         /* time */      0,//time(NULL),
>         /* root */      xcb_root_window,
>         /* rootX */     x,
>         /* rootY */     y,
>         /* deviceid */  0);
> 
> ... and nothing happens.
> 
> The same thing happens when I try to fake key input:
> 
>     xcb_test_fake_input(xcb,
>                         /* type */      press
> ? KEY_PRESS /*3*/ : KEY_RELEASE /*4*/,
>                         /* detail */    keycode,
>                         /* time */      0,
>                         /* root */      0,
>                         /* rootX */     0,
>                         /* rootY */     0,
>                         /* deviceid */  0);
> 
> I imagine there's a key concept or two that I am missing here - any help would be appreciated.

If you haven't blocked on anything in XCB, then XCB may never have
flushed the request from its buffers; you might need to call xcb_flush
explicitly.

- Josh Triplett


More information about the Xcb mailing list