diff options
| author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2014-11-24 13:37:06 +0100 |
|---|---|---|
| committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2014-11-24 13:39:13 +0100 |
| commit | 34aba4724f196e34ed02cf50073f41968f119bb6 (patch) | |
| tree | 0ebdfcabda989ab76ee6de53c6461553c7a767a5 /src/plugins/platforms/windows/qwindowsmousehandler.cpp | |
| parent | b86b2a742afae118bf974c82ba966ddb0cae4afb (diff) | |
| parent | b1cf07f495e10c93e53651ac03e46ebdaea0a97e (diff) | |
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts:
src/corelib/io/qiodevice.cpp
src/plugins/bearer/linux_common/qofonoservice_linux.cpp
src/plugins/bearer/linux_common/qofonoservice_linux_p.h
src/plugins/platforms/android/qandroidplatformtheme.cpp
src/tools/bootstrap/bootstrap.pro
src/widgets/styles/qmacstyle_mac.mm
Change-Id: Ia02aab6c4598ce74e9c30bb4666d5e2ef000f99b
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsmousehandler.cpp')
| -rw-r--r-- | src/plugins/platforms/windows/qwindowsmousehandler.cpp | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 39321c34607..acb692579bc 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -109,6 +109,30 @@ static inline void compressMouseMove(MSG *msg) } } +static inline QTouchDevice *createTouchDevice() +{ + enum { QT_SM_TABLETPC = 86, QT_SM_DIGITIZER = 94, QT_SM_MAXIMUMTOUCHES = 95, + QT_NID_INTEGRATED_TOUCH = 0x1, QT_NID_EXTERNAL_TOUCH = 0x02, + QT_NID_MULTI_INPUT = 0x40, QT_NID_READY = 0x80 }; + + if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS7) + return 0; + const int digitizers = GetSystemMetrics(QT_SM_DIGITIZER); + if (!(digitizers & (QT_NID_INTEGRATED_TOUCH | QT_NID_EXTERNAL_TOUCH))) + return 0; + const int tabletPc = GetSystemMetrics(QT_SM_TABLETPC); + const int maxTouchPoints = GetSystemMetrics(QT_SM_MAXIMUMTOUCHES); + qCDebug(lcQpaEvents) << "Digitizers:" << hex << showbase << (digitizers & ~QT_NID_READY) + << "Ready:" << (digitizers & QT_NID_READY) << dec << noshowbase + << "Tablet PC:" << tabletPc << "Max touch points:" << maxTouchPoints; + QTouchDevice *result = new QTouchDevice; + result->setType(digitizers & QT_NID_INTEGRATED_TOUCH + ? QTouchDevice::TouchScreen : QTouchDevice::TouchPad); + result->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition); + result->setMaximumTouchPoints(maxTouchPoints); + return result; +} + /*! \class QWindowsMouseHandler \brief Windows mouse handler @@ -122,10 +146,12 @@ static inline void compressMouseMove(MSG *msg) QWindowsMouseHandler::QWindowsMouseHandler() : m_windowUnderMouse(0), m_trackedWindow(0), - m_touchDevice(0), + m_touchDevice(createTouchDevice()), m_leftButtonDown(false), m_previousCaptureWindow(0) { + if (m_touchDevice) + QWindowSystemInterface::registerTouchDevice(m_touchDevice); } Qt::MouseButtons QWindowsMouseHandler::queryMouseButtons() @@ -404,6 +430,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, typedef QWindowSystemInterface::TouchPoint QTouchPoint; typedef QList<QWindowSystemInterface::TouchPoint> QTouchPointList; + Q_ASSERT(m_touchDevice); const QRect screenGeometry = window->screen()->geometry(); const int winTouchPointCount = msg.wParam; @@ -464,14 +491,6 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, if (allStates == Qt::TouchPointReleased) m_touchInputIDToTouchPointID.clear(); - if (!m_touchDevice) { - m_touchDevice = new QTouchDevice; - // TODO: Device used to be hardcoded to screen in previous code. - m_touchDevice->setType(QTouchDevice::TouchScreen); - m_touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition); - QWindowSystemInterface::registerTouchDevice(m_touchDevice); - } - QWindowSystemInterface::handleTouchEvent(window, m_touchDevice, touchPoints); |
