[Xcb] Catch events from external window

Rémi Denis-Courmont remi at remlab.net
Thu Nov 25 12:46:02 PST 2010


Le jeudi 25 novembre 2010 22:25:33 Borys Igor Polevoj, vous avez écrit :
> Hi guys,
> I want to write an application which finds a current focus window and
> counts
> mouse and keyboard clicks for it.
> I retrieve focus window id with xcb_get_input_focus function.
> How can I catch/signalize my application about events for the given id?

Typically, you can't. The X11 protocols requires, and the X11 server enforces 
that there is only one X11 client subscribed to button press events, which is 
to say mouse clicks. Thus unless the focused application does not catch its 
"own" mouse clicks, your application cannot catch them.

Instead, your application should need to grab the mouse buttons.

> I used XSelectInput from XLib but this function turned out to be
> insufficient
> since I couldn't catch mouse button up/down events with it.

It is irrelevant which of Xlib vs XCB you use.
This "limitation" is a design choice in the X protocol and server.

-- 
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis


More information about the Xcb mailing list