diff options
Diffstat (limited to 'src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp')
-rw-r--r-- | src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index 6f06797393..1e33e2b50f 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp @@ -1,6 +1,6 @@ /*************************************************************************** ** -** Copyright (C) 2011 - 2012 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -46,6 +46,7 @@ #include "qqnxintegration.h" #include "qqnxkeytranslator.h" #include "qqnxscreen.h" +#include "qqnxscreeneventfilter.h" #include <QDebug> #include <QGuiApplication> @@ -90,6 +91,16 @@ QQnxScreenEventHandler::QQnxScreenEventHandler(QQnxIntegration *integration) } } +void QQnxScreenEventHandler::addScreenEventFilter(QQnxScreenEventFilter *filter) +{ + m_eventFilters.append(filter); +} + +void QQnxScreenEventHandler::removeScreenEventFilter(QQnxScreenEventFilter *filter) +{ + m_eventFilters.removeOne(filter); +} + bool QQnxScreenEventHandler::handleEvent(screen_event_t event) { // get the event type @@ -256,7 +267,23 @@ void QQnxScreenEventHandler::handleKeyboardEvent(screen_event_t event) if (result) qFatal("QQNX: failed to query event cap, errno=%d", errno); - injectKeyboardEvent(flags, sym, modifiers, scan, cap); + int sequenceId = 0; +#if defined(Q_OS_BLACKBERRY) + result = screen_get_event_property_iv(event, SCREEN_PROPERTY_SEQUENCE_ID, &sequenceId); + if (result) + qFatal("QQNX: failed to query event seqId, errno=%d", errno); +#endif + + bool inject = true; + Q_FOREACH (QQnxScreenEventFilter *filter, m_eventFilters) { + if (filter->handleKeyboardEvent(flags, sym, modifiers, scan, cap, sequenceId)) { + inject = false; + break; + } + } + + if (inject) + injectKeyboardEvent(flags, sym, modifiers, scan, cap); } void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event) @@ -314,10 +341,6 @@ void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event) } } - // If we don't have a navigator, we don't get activation events. - if (buttonState && w && w != QGuiApplication::focusWindow() && !m_qnxIntegration->supportsNavigatorEvents()) - QWindowSystemInterface::handleWindowActivated(w); - m_lastMouseWindow = qnxWindow; // Apply scaling to wheel delta and invert value for Qt. We'll probably want to scale @@ -589,9 +612,15 @@ void QQnxScreenEventHandler::handleKeyboardFocusPropertyEvent(screen_window_t wi if (window && screen_get_window_property_iv(window, SCREEN_PROPERTY_KEYBOARD_FOCUS, &focus) != 0) qFatal("QQnx: failed to query keyboard focus property, errno=%d", errno); - QWindow *w = focus ? QQnxIntegration::window(window) : 0; - - QWindowSystemInterface::handleWindowActivated(w); + QWindow *focusWindow = QQnxIntegration::window(window); + if (focus) { + QWindowSystemInterface::handleWindowActivated(focusWindow); + } else if (focusWindow == QGuiApplication::focusWindow()) { + // Deactivate only if the window was the focus window. + // Screen might send a keyboard focus event for a newly created + // window on the secondary screen, with focus 0. + QWindowSystemInterface::handleWindowActivated(0); + } } #include "moc_qqnxscreeneventhandler.cpp" |