aboutsummaryrefslogtreecommitdiffstats
path: root/src/virtualkeyboard/platforminputcontext.cpp
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2015-01-14 12:55:02 +0200
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2015-01-16 09:11:28 +0200
commite7e2c8006260c4a82ea11446576fda2fcd42e528 (patch)
treeda21957625935a45b626fd61bc06425616fba049 /src/virtualkeyboard/platforminputcontext.cpp
parent81b5c1a37eb469a6ee49c01a0b84990d8c2a856f (diff)
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 <gatis.paeglis@theqtcompany.com>
Diffstat (limited to 'src/virtualkeyboard/platforminputcontext.cpp')
-rw-r--r--src/virtualkeyboard/platforminputcontext.cpp32
1 files changed, 2 insertions, 30 deletions
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
}
}