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.
{
public:
CaptureApp(int argc, char **argv);
~CaptureApp();
bool x11EventFilter (XEvent *event);
static bool customEventFilter(void *message);
private:
};
class CaptureApp: public QApplication
{
public:
CaptureApp(int argc, char **argv);
~CaptureApp();
bool x11EventFilter (XEvent *event);
static bool customEventFilter(void *message);
private:
QAbstractEventDispatcher *evInstance;
};
To copy to clipboard, switch view to plain text mode
CaptureApp
::CaptureApp(int argc,
char** argv
): QApplication(argc, argv
){
}
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;
}
CaptureApp::CaptureApp(int argc, char** argv): QApplication(argc, argv)
{
evInstance = QAbstractEventDispatcher::instance();
evInstance->setEventFilter((QAbstractEventDispatcher::EventFilter)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;
}
To copy to clipboard, switch view to plain text mode
Bookmarks