Dear All,
Sorry, this is an old question, still unsolved.
In main.cpp file, I have
int main(int argc, char *argv[])
{
SubQApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
int main(int argc, char *argv[])
{
SubQApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
In the related SubQApplication, I just inherit from QApplication, and reimplement the X11EventFilter() as follows:
bool SubQApplication::x11EventFilter(XEvent *e){
// http://doc.trolltech.com/4.1/qapplication.html#x11EventFilter
if(e->type == GenericEvent){
printf("!!!!!!!!!!!!!!!!!!GenericEvent finded !!!!!!!!!!!!!\n");
}
return false;
}
bool SubQApplication::x11EventFilter(XEvent *e){
// http://doc.trolltech.com/4.1/qapplication.html#x11EventFilter
if(e->type == GenericEvent){
printf("!!!!!!!!!!!!!!!!!!GenericEvent finded !!!!!!!!!!!!!\n");
}
return false;
}
To copy to clipboard, switch view to plain text mode
And the Class class MainWindow : public QMainWindow { and implement the bool x11Event(XEvent *e); as follows:
bool MainWindow::x11Event(XEvent * e){
XEvent ev = *e;
XGenericEventCookie *cookie = &ev.xcookie; //&e->xcookie;
if(cookie->type != GenericEvent || cookie->extension != xi_opcode || !XGetEventData(dpy, cookie) ){
printf("No GenericEvent Type is found in X11Event, return ******************* \n");
return false;
}
printf("EVENT TYPE %d hahahahahaha---!!!!GenericEvent!!!!!!!!! \n", cookie->evtype);
return flase;
}
bool MainWindow::x11Event(XEvent * e){
XEvent ev = *e;
XGenericEventCookie *cookie = &ev.xcookie; //&e->xcookie;
if(cookie->type != GenericEvent || cookie->extension != xi_opcode || !XGetEventData(dpy, cookie) ){
printf("No GenericEvent Type is found in X11Event, return ******************* \n");
return false;
}
printf("EVENT TYPE %d hahahahahaha---!!!!GenericEvent!!!!!!!!! \n", cookie->evtype);
return flase;
}
To copy to clipboard, switch view to plain text mode
So, the weired thing is that:
In X11EventFilter, GenericEvent type could be found, but can never be found in X11Event().
i.e, printf("EVENT TYPE %d hahahahahaha---!!!!GenericEvent!!!!!!!!! ) is never excuted!!!!!!!!!
WHY? 


Can anybody tell me?
Thanks a million beforehand.
Bookmarks