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>
This commit is contained in:
parent
7245599a8c
commit
e76b0c05f2
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user