View Single Post
daperl's Avatar
Posts: 2,427 | Thanked: 2,986 times | Joined on Dec 2007
#6
WARNING: Major Hacking Ahead

Okay, it's a two step process. Here's the first step:

Sub-class QApplication and reimplement x11EventFilter like this:

Code:
...
#include <QDebug>
#include <X11/Xlib.h>
...
bool Application::x11EventFilter(XEvent *event) {
        XClientMessageEvent *cm = (XClientMessageEvent *) event;
        if (cm->type == 33 /* ClientMessage */) {
                qDebug() << "Application::x11EventFilter" << cm->message_type << cm->format;
                for (long i=0; i<5; i++)
                        qDebug() << " " << cm->data.l[i];
        }
        return QApplication::x11EventFilter(event);
}
...
Here's the output when you click outside of the virtual keyboard:

Code:
Application::x11EventFilter 464 8 
  65011750 
  24 
  5 
  0 
  0 
Application::x11EventFilter 277 32 
  278 
  70522943 
  0 
  0 
  0 
Application::x11EventFilter 172 32 
  1 
  600 
  0 
  0 
  0
Here's the output when you click the Return key:

Code:
Application::x11EventFilter 464 8 
  65011750 
  20 
  5 
  0 
  0 
Application::x11EventFilter 464 8 
  65011750 
  24 
  5 
  0 
  0 
Application::x11EventFilter 277 32 
  278 
  70559392 
  0 
  0 
  0 
Application::x11EventFilter 172 32 
  1 
  600 
  0 
  0 
  0
If you decide to try something like the above, here's the next step in Python. I can do a proof-of-concept in C++ if need be. eventFilter() only gets invoked when the virtual keyboard pops up. focusWidget() can then be compared to the input widget of interest.

Code:
...
class EFObject(QObject):
    def eventFilter(s,o,e):
        print 'efo',o,o.focusWidget(),e,e.type()
        return False
...
class Application(QApplication):
...
app = Application(sys.argv)
oic = app.inputContext()
efo = EFObject()
oic.installEventFilter(efo)
...
__________________
N9: Go white or go home
 

The Following 3 Users Say Thank You to daperl For This Useful Post: