summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-10-30 16:42:15 +0100
committerFriedemann Kleint <Friedemann.Kleint@digia.com>2014-10-31 13:26:36 +0100
commite76b0c05f2c0f0376157aa1ef5fdc5d718248d98 (patch)
tree79d8aaa19c396bca3d408786fd757d5f1f3b7a86 /src/plugins
parent7245599a8c7102de04a41a995b19e37ed7f1b7f0 (diff)
Windows: Create touch device in initialization.
Previously, the device was delay-created, which is a problem if its type is to be used for determinining the pan gesture type. Task-number: QTBUG-40461 Change-Id: I2dee3d7a3786a0fdf0a9b2b9e174dd121697ab44 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp11
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp37
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.h2
3 files changed, 31 insertions, 19 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index db48e0ed93..22a4dbb09f 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -102,15 +102,6 @@ static inline int componentVerbose(const char *v, const char *keyWord)
return 0;
}
-static inline bool hasTouchSupport(QSysInfo::WinVersion wv)
-{
- enum { QT_SM_DIGITIZER = 94, QT_NID_INTEGRATED_TOUCH = 0x1,
- QT_NID_EXTERNAL_TOUCH = 0x02, QT_NID_MULTI_INPUT = 0x40 };
-
- return wv < QSysInfo::WV_WINDOWS7 ? false :
- (GetSystemMetrics(QT_SM_DIGITIZER) & (QT_NID_INTEGRATED_TOUCH | QT_NID_EXTERNAL_TOUCH | QT_NID_MULTI_INPUT)) != 0;
-}
-
#if !defined(LANG_SYRIAC)
# define LANG_SYRIAC 0x5a
#endif
@@ -318,7 +309,7 @@ QWindowsContextPrivate::QWindowsContextPrivate()
QWindowsContext::shell32dll.init();
QWindowsContext::shcoredll.init();
- if (hasTouchSupport(ver) && QWindowsContext::user32dll.initTouch())
+ if (m_mouseHandler.touchDevice() && QWindowsContext::user32dll.initTouch())
m_systemInfo |= QWindowsContext::SI_SupportsTouch;
#endif // !Q_OS_WINCE
m_displayContext = GetDC(0);
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index 39321c3460..acb692579b 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);
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.h b/src/plugins/platforms/windows/qwindowsmousehandler.h
index 967c64e597..6491de93b5 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.h
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.h
@@ -51,6 +51,8 @@ class QWindowsMouseHandler
public:
QWindowsMouseHandler();
+ QTouchDevice *touchDevice() const { return m_touchDevice; }
+
bool translateMouseEvent(QWindow *widget, HWND hwnd,
QtWindows::WindowsEventType t, MSG msg,
LRESULT *result);