How to track events and windows?
Tomas carnecky
tom at dbservice.com
Wed Sep 13 11:12:24 PDT 2006
I'm working on a small project [1] that needs to hook a few X11 (XEvent
and friends) and GLX (glXSwapBuffers) functions. The idea is that when
the user presses a predefined hotkey, the library saves the Display and
Window XID and later any call to glXSwapBuffers with the correct
arguments will cause that function to save the framebuffer and write it
to a file. I first took the Display variable passed to the XEvent
functions and "event->xkey.window" as the Window XID. This works for
simple X11 applications that open only one connection to the server and
use only one window (for both drawing and events).
But unfortunately there are apps that handle events in a more
complicated way: libSDL, cedega, wine are just a few examples. They use
two or more different windows and each app does it in a different way.
That's why I thought I could query the window that currently has focus
and take its XID. But too bad that the window that has input focus is
not always the window that the apps uses for drawing. And what's even
stranger, when I query the input focus window after I receive a
key-event, then the focus window doesn't match the window from the
event. That means, if I understand it correctly, that a window _without_
input focus received a key event. How is that possible?
A last way to get the Window XID would be to query the window that is
under the mouse but that wouldn't work for apps that are not fullscreen
and where the user has the mouse outside of the window.
Does anyone have an idea how I could properly get the Window XID?
thanks
tom
[1] http://www.neopsis.com/projects/yukon/
More information about the xorg
mailing list