From e7e2c8006260c4a82ea11446576fda2fcd42e528 Mon Sep 17 00:00:00 2001 From: Jarkko Koivikko Date: Wed, 14 Jan 2015 12:55:02 +0200 Subject: Filter events using QObject::eventFilter() method QPlatformInputContext::filterEvent() method is broken and not functional for other than X11 generated key events. In this change the events are filtered using QObject::eventFilter() method. This works consistently in all use cases, including the key events generated by the qt test library. Change-Id: If3470a9a6a7f5974155f3568f98f0ab64762fa40 Reviewed-by: Gatis Paeglis --- src/virtualkeyboard/platforminputcontext.cpp | 32 ++-------------------------- 1 file changed, 2 insertions(+), 30 deletions(-) (limited to 'src/virtualkeyboard/platforminputcontext.cpp') diff --git a/src/virtualkeyboard/platforminputcontext.cpp b/src/virtualkeyboard/platforminputcontext.cpp index 3808fbe4..a910461b 100644 --- a/src/virtualkeyboard/platforminputcontext.cpp +++ b/src/virtualkeyboard/platforminputcontext.cpp @@ -33,10 +33,8 @@ PlatformInputContext::PlatformInputContext() : m_inputPanel(0), m_focusObject(0), m_locale(), - m_inputDirection(m_locale.textDirection()) -#if defined(Q_OS_WIN) - ,m_filterEvent(0) -#endif + m_inputDirection(m_locale.textDirection()), + m_filterEvent(0) { } @@ -88,18 +86,6 @@ void PlatformInputContext::invokeAction(QInputMethod::Action action, int cursorP VIRTUALKEYBOARD_DEBUG() << "PlatformInputContext::invokeAction():" << action << cursorPosition; } -bool PlatformInputContext::filterEvent(const QEvent *event) -{ - // On Windows the events are filtered using eventFilter() -#if !defined(Q_OS_WIN) - if (m_declarativeContext) - return m_declarativeContext->filterEvent(event); -#else - Q_UNUSED(event) -#endif - return false; -} - QRectF PlatformInputContext::keyboardRect() const { return m_declarativeContext ? m_declarativeContext->keyboardRectangle() : QRectF(); @@ -168,15 +154,11 @@ void PlatformInputContext::setFocusObject(QObject *object) { VIRTUALKEYBOARD_DEBUG() << "PlatformInputContext::setFocusObject():" << object; if (m_focusObject != object) { -#if defined(Q_OS_WIN) if (m_focusObject) m_focusObject->removeEventFilter(this); -#endif m_focusObject = object; -#if defined(Q_OS_WIN) if (m_focusObject) m_focusObject->installEventFilter(this); -#endif emit focusObjectChanged(); } update(Qt::ImQueryAll); @@ -187,25 +169,19 @@ DeclarativeInputContext *PlatformInputContext::declarativeInputContext() const return m_declarativeContext; } -#if defined(Q_OS_WIN) bool PlatformInputContext::eventFilter(QObject *object, QEvent *event) { if (event != m_filterEvent && object == m_focusObject && m_declarativeContext) return m_declarativeContext->filterEvent(event); return false; } -#endif void PlatformInputContext::sendEvent(QEvent *event) { if (m_focusObject) { -#if defined(Q_OS_WIN) m_filterEvent = event; -#endif QGuiApplication::sendEvent(m_focusObject, event); -#if defined(Q_OS_WIN) m_filterEvent = 0; -#endif } } @@ -214,13 +190,9 @@ void PlatformInputContext::sendKeyEvent(QKeyEvent *event) const QGuiApplication *app = qApp; QWindow *focusWindow = app ? app->focusWindow() : 0; if (focusWindow) { -#if defined(Q_OS_WIN) m_filterEvent = event; -#endif QGuiApplication::sendEvent(focusWindow, event); -#if defined(Q_OS_WIN) m_filterEvent = 0; -#endif } } -- cgit v1.2.3