From 3dbd381e039818e4021b33533dbfdab1419510e1 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Tue, 26 Jun 2012 23:02:23 +0800 Subject: [PATCH] Also use x11FilterEvent for auto repeat key in xcb. filterEvent for QPlatformInputContext is already used for auto repeat key, x11FilterEvent also need to be filtered. Task-number: QTBUG-25795 Change-Id: I3db87fdffdb5b01404047e905793ae6e10bb1e90 Reviewed-by: Pekka Vuorela --- src/plugins/platforms/xcb/qxcbkeyboard.cpp | 32 ++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 638c490..9876adf 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -1054,16 +1055,22 @@ 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(); + QMetaMethod method; if (inputContext) { + int methodIndex = inputContext->metaObject()->indexOfMethod("x11FilterEvent(uint,uint,uint,bool)"); + if (methodIndex != -1) + method = inputContext->metaObject()->method(methodIndex); + } + + if (method.isValid()) { bool retval = false; - if (inputContext->metaObject()->indexOfMethod("x11FilterEvent(uint,uint,uint,bool)") != -1) - QMetaObject::invokeMethod(inputContext, "x11FilterEvent", Qt::DirectConnection, - Q_RETURN_ARG(bool, retval), - Q_ARG(uint, sym), - Q_ARG(uint, code), - Q_ARG(uint, state), - Q_ARG(bool, type == QEvent::KeyPress)); + method.invoke(inputContext, Qt::DirectConnection, + Q_RETURN_ARG(bool, retval), + Q_ARG(uint, sym), + Q_ARG(uint, code), + Q_ARG(uint, state), + Q_ARG(bool, type == QEvent::KeyPress)); if (retval) return; } @@ -1105,7 +1112,16 @@ void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycod if (isAutoRepeat && type == QEvent::KeyRelease) { // since we removed it from the event queue using checkEvent we need to send the key press here filtered = false; - if (inputContext) { + if (method.isValid()) { + method.invoke(inputContext, Qt::DirectConnection, + Q_RETURN_ARG(bool, filtered), + Q_ARG(uint, sym), + Q_ARG(uint, code), + Q_ARG(uint, state), + Q_ARG(bool, true)); + } + + if (!filtered && inputContext) { QKeyEvent event(QEvent::KeyPress, qtcode, modifiers, string, isAutoRepeat); event.setTimestamp(time); filtered = inputContext->filterEvent(&event); -- 2.7.4