diff options
Diffstat (limited to 'src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp')
-rw-r--r-- | src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp | 73 |
1 files changed, 62 insertions, 11 deletions
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index 6f06797393..b50e590265 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 @@ -405,6 +428,19 @@ void QQnxScreenEventHandler::handleTouchEvent(screen_event_t event, int qnxType) if (result) qFatal("QQNX: failed to query event window, errno=%d", errno); + errno = 0; + int touchArea[2]; + result = screen_get_event_property_iv(event, SCREEN_PROPERTY_SIZE, touchArea); + if (result) + qFatal("QQNX: failed to query event touch area, errno=%d", errno); + + errno = 0; + int touchPressure; + result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_PRESSURE, &touchPressure); + if (result) + qFatal("QQNX: failed to query event touch pressure, errno=%d", errno); + + screen_window_t qnxWindow = static_cast<screen_window_t>(handle); // check if finger is valid @@ -439,14 +475,23 @@ void QQnxScreenEventHandler::handleTouchEvent(screen_event_t event, int qnxType) QPointF(static_cast<qreal>(pos[0]) / screenSize.width(), static_cast<qreal>(pos[1]) / screenSize.height()); - m_touchPoints[touchId].area = QRectF(w->geometry().left() + windowPos[0], - w->geometry().top() + windowPos[1], 0.0, 0.0); + m_touchPoints[touchId].area = QRectF(w->geometry().left() + windowPos[0] - (touchArea[0]>>1), + w->geometry().top() + windowPos[1] - (touchArea[1]>>1), + 0.0, 0.0); QWindow *parent = w->parent(); while (parent) { m_touchPoints[touchId].area.translate(parent->geometry().topLeft()); parent = parent->parent(); } + //Qt expects the pressure between 0 and 1. There is however no definit upper limit for + //the integer value of touch event pressure. The 200 was determined by experiment, it + //usually does not get higher than that. + m_touchPoints[touchId].pressure = static_cast<qreal>(touchPressure)/200.0; + // Can happen, because there is no upper limit for pressure + if (m_touchPoints[touchId].pressure > 1) + m_touchPoints[touchId].pressure = 1; + // determine event type and update state of current touch point QEvent::Type type = QEvent::None; switch (qnxType) { @@ -589,9 +634,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" |