Implemented key filter support on platform input context

As previously with QInputContext, now supporting filterEvent()
interface. Usage only on XCB so far.

Change-Id: I8e5972626552bda32318fe060017d0217bb79a94
Reviewed-on: http://codereview.qt-project.org/5240
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Pekka Vuorela 2011-09-20 15:33:27 +03:00 committed by Qt by Nokia
parent 6aad412233
commit dbdfdb2c95
3 changed files with 17 additions and 3 deletions

View File

@ -78,6 +78,11 @@ void QPlatformInputContext::invokeAction(QInputPanel::Action action, int cursorP
reset();
}
bool QPlatformInputContext::filterEvent(const QEvent *event)
{
return false;
}
QRectF QPlatformInputContext::keyboardRect() const
{
return QRectF();

View File

@ -66,7 +66,7 @@ public:
virtual void commit();
virtual void update(Qt::InputMethodQueries);
virtual void invokeAction(QInputPanel::Action, int cursorPosition);
virtual bool filterEvent(const QEvent *event);
virtual QRectF keyboardRect() const;
void emitKeyboardRectChanged() const;

View File

@ -1026,9 +1026,9 @@ void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycod
QByteArray chars;
xcb_keysym_t sym = lookupString(window, state, code, type, &chars);
QPlatformInputContext *inputContext = QGuiApplicationPrivate::platformIntegration()->inputContext();
if (QObject* inputContext = QGuiApplicationPrivate::platformIntegration()->inputContext()) {
if (inputContext) {
bool retval = false;
if (inputContext->metaObject()->indexOfMethod("x11FilterEvent") != -1)
QMetaObject::invokeMethod(inputContext, "x11FilterEvent", Qt::DirectConnection,
@ -1045,6 +1045,15 @@ void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycod
int qtcode = 0;
int count = chars.count();
QString string = translateKeySym(sym, state, qtcode, modifiers, chars, count);
if (inputContext) {
QKeyEvent event(type, qtcode, modifiers, string);
event.setTimestamp(time);
bool retval = inputContext->filterEvent(&event);
if (retval)
return;
}
QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers,
code, 0, state, string.left(count));
}