Results 1 to 2 of 2

Thread: Catching XEvents with x11EventFilter

  1. #1
    Join Date
    May 2007
    Location
    H-town, Alabama
    Posts
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Catching XEvents with x11EventFilter

    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:

    Qt Code:
    1. bool OSDApp::x11EventFilter(XEvent *e)
    2. {
    3. qDebug("Got an event!\n");
    4. if (e->type == MotionNotify) {
    5. if ( sendMouseEvent() )
    6. qDebug("Sent Motion Event...\n");
    7. else
    8. qDebug("Error Sending Motion Event...\n");
    9. }
    10.  
    11. return QApplication::x11EventFilter(e);
    12. }
    To copy to clipboard, switch view to plain text mode 

    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!

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Catching XEvents with x11EventFilter

    Have you used XSelectInput correctly?
    This requests the X server to forward events to your window.
    The syntax is:
    Qt Code:
    1. XSelectInput( Display *display, Window w, long event_mask )
    To copy to clipboard, switch view to plain text mode 

    Regards

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.