PDA

View Full Version : Catching XEvents with x11EventFilter



colfax4
21st May 2007, 00:50
Hi all,

I am attempting to write a Qt application that displays a small window for a short period of time in certain intervals. I would also like to detect any motion on the mouse both when my window is shown and when it is not.

I have inherited QApplication and overloaded x11EventFilter which from what I have read should receive ALL XEvents and allow me to detect motion on the mouse cursor:


bool OSDApp::x11EventFilter(XEvent *e)
{
qDebug("Got an event!\n");
if (e->type == MotionNotify) {
if ( sendMouseEvent() )
qDebug("Sent Motion Event...\n");
else
qDebug("Error Sending Motion Event...\n");
}

return QApplication::x11EventFilter(e);
}

Unfortunately, after executing my application I am unable to see any activity from x11EventFilter. This leads me to believe I will only see activity in x11EventFilter if I show a window and mouse activity happens within that window. Is this the case? Or am I missing something entirely. If this is indeed the case, does anybody know a way in which I can receive all motion events in Qt?

Thanks!

marcel
21st May 2007, 05:27
Have you used XSelectInput correctly?
This requests the X server to forward events to your window.
The syntax is:


XSelectInput( Display *display, Window w, long event_mask )


Regards