PDA

View Full Version : Getting system wide X11 events problems



wandereq
21st August 2009, 09:23
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.


class CaptureApp: public QApplication
{
public:
CaptureApp(int argc, char **argv);
~CaptureApp();
bool x11EventFilter (XEvent *event);
static bool customEventFilter(void *message);
private:
QAbstractEventDispatcher *evInstance;
};



CaptureApp::CaptureApp(int argc, char** argv): QApplication(argc, argv)
{
evInstance = QAbstractEventDispatcher::instance();
evInstance->setEventFilter((QAbstractEventDispatcher::EventFil ter)customEventFilter);
}


CaptureApp::~CaptureApp()
{

}

bool CaptureApp::customEventFilter(void *message)
{
XEvent *ev;

ev = (XEvent *) message;

if (ev->type == CreateNotify)
{
qDebug("[customEventFilter]: Window id 0x%.8lx created\n", ev->xcreatewindow.window);
}
return false;
}

bool CaptureApp::x11EventFilter(XEvent *event)
{

if (event->type == CreateNotify)
{
qDebug("Window id 0x%.8lx created\n", event->xcreatewindow.window );
}

return false;
}

tebrandt
19th March 2010, 21:13
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).