Results 1 to 2 of 2

Thread: Getting system wide X11 events problems

  1. #1
    Join Date
    Oct 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Getting system wide X11 events problems

    Hi,

    I'm trying to do something similar to a taskbar application for capturing windows. I need to capture all X11 events (I'm mostly interested in CreateNotify/DestroyNotify etc). I created a CaptureApp class from QApplication so I can implement x11EventFilter and even QAbstractEventDispatcheer filter. Everything works ok (meaning I get correct x11 events codes for create/destroy window) till I create a new QWidget (a main application window for example. After the main window is created I still get event codes but they are changed, insted of CreateNotify/DestroyNotify I get a bunch of PropertyChanged codes.

    I'm not sure what I'm doing wrong or why the x11Events are somehow modified as soon as I create a QWidget. Any clues ?

    P.S. I'm also doing XSelectInput(dpy, rootId, SubstructureNotifyMask); to get all events from the root window and dpy display.

    Qt Code:
    1. class CaptureApp: public QApplication
    2. {
    3. public:
    4. CaptureApp(int argc, char **argv);
    5. ~CaptureApp();
    6. bool x11EventFilter (XEvent *event);
    7. static bool customEventFilter(void *message);
    8. private:
    9. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. CaptureApp::CaptureApp(int argc, char** argv): QApplication(argc, argv)
    2. {
    3. evInstance = QAbstractEventDispatcher::instance();
    4. evInstance->setEventFilter((QAbstractEventDispatcher::EventFilter)customEventFilter);
    5. }
    6.  
    7.  
    8. CaptureApp::~CaptureApp()
    9. {
    10.  
    11. }
    12.  
    13. bool CaptureApp::customEventFilter(void *message)
    14. {
    15. XEvent *ev;
    16.  
    17. ev = (XEvent *) message;
    18.  
    19. if (ev->type == CreateNotify)
    20. {
    21. qDebug("[customEventFilter]: Window id 0x%.8lx created\n", ev->xcreatewindow.window);
    22. }
    23. return false;
    24. }
    25.  
    26. bool CaptureApp::x11EventFilter(XEvent *event)
    27. {
    28.  
    29. if (event->type == CreateNotify)
    30. {
    31. qDebug("Window id 0x%.8lx created\n", event->xcreatewindow.window );
    32. }
    33.  
    34. return false;
    35. }
    To copy to clipboard, switch view to plain text mode 

  2. #2

    Default Re: Getting system wide X11 events problems

    I know this is way too late to reply, but I just found this thread and I'm having the exact same problem. I found that if you run XSelectInput after the "show" call of the main widget, the system wide events start reappearing. I think when the main widget is shown the QWidget class makes an implicit call to XSelectInput that you have to override later. This is the function call I use after "show":

    XSelectInput(QX11Info::display(), DefaultRootWindow(QX11Info::display()), SubstructureNotifyMask);

    Thanks for posting this BTW, you gave me just enough info to get this online (I didn't know about XSelectInput til I read this).

Similar Threads

  1. Standby / hibernate system events
    By rensdenobel in forum Qt Programming
    Replies: 0
    Last Post: 13th October 2008, 17:39
  2. Replies: 2
    Last Post: 12th October 2008, 01:55
  3. QGraphicsView Mouse Events
    By tomf in forum Qt Programming
    Replies: 5
    Last Post: 29th July 2008, 15:03

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.