Windows: Delay-initialize pluggable touch devices.
Move touch device initialization code to QWindowsContext and replace the assert on the touch device in QWindowsMouseHandler by a call to the initTouch(). Task-number: QTBUG-48849 Change-Id: If8573b8283ef94e7fd015f6edc626e3c8cc0b139 Reviewed-by: Joni Poikelin <joni.poikelin@theqtcompany.com> Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com> Reviewed-by: Andreas Holzammer <andreas.holzammer@kdab.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>bb10
parent
a91c40868b
commit
7daae2c2c7
|
|
@ -33,6 +33,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "qwindowscontext.h"
|
||||
#include "qwindowsintegration.h"
|
||||
#include "qwindowswindow.h"
|
||||
#include "qwindowskeymapper.h"
|
||||
#include "qwindowsguieventdispatcher.h"
|
||||
|
|
@ -201,12 +202,14 @@ void QWindowsUser32DLL::init()
|
|||
|
||||
bool QWindowsUser32DLL::initTouch()
|
||||
{
|
||||
QSystemLibrary library(QStringLiteral("user32"));
|
||||
isTouchWindow = (IsTouchWindow)(library.resolve("IsTouchWindow"));
|
||||
registerTouchWindow = (RegisterTouchWindow)(library.resolve("RegisterTouchWindow"));
|
||||
unregisterTouchWindow = (UnregisterTouchWindow)(library.resolve("UnregisterTouchWindow"));
|
||||
getTouchInputInfo = (GetTouchInputInfo)(library.resolve("GetTouchInputInfo"));
|
||||
closeTouchInputHandle = (CloseTouchInputHandle)(library.resolve("CloseTouchInputHandle"));
|
||||
if (!isTouchWindow && QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) {
|
||||
QSystemLibrary library(QStringLiteral("user32"));
|
||||
isTouchWindow = (IsTouchWindow)(library.resolve("IsTouchWindow"));
|
||||
registerTouchWindow = (RegisterTouchWindow)(library.resolve("RegisterTouchWindow"));
|
||||
unregisterTouchWindow = (UnregisterTouchWindow)(library.resolve("UnregisterTouchWindow"));
|
||||
getTouchInputInfo = (GetTouchInputInfo)(library.resolve("GetTouchInputInfo"));
|
||||
closeTouchInputHandle = (CloseTouchInputHandle)(library.resolve("CloseTouchInputHandle"));
|
||||
}
|
||||
return isTouchWindow && registerTouchWindow && unregisterTouchWindow && getTouchInputInfo && closeTouchInputHandle;
|
||||
}
|
||||
|
||||
|
|
@ -359,6 +362,36 @@ QWindowsContext::~QWindowsContext()
|
|||
m_instance = 0;
|
||||
}
|
||||
|
||||
bool QWindowsContext::initTouch()
|
||||
{
|
||||
return initTouch(QWindowsIntegration::instance()->options());
|
||||
}
|
||||
|
||||
bool QWindowsContext::initTouch(unsigned integrationOptions)
|
||||
{
|
||||
if (d->m_systemInfo & QWindowsContext::SI_SupportsTouch)
|
||||
return true;
|
||||
|
||||
QTouchDevice *touchDevice = d->m_mouseHandler.ensureTouchDevice();
|
||||
if (!touchDevice)
|
||||
return false;
|
||||
|
||||
#ifndef Q_OS_WINCE
|
||||
if (!QWindowsContext::user32dll.initTouch()) {
|
||||
delete touchDevice;
|
||||
return false;
|
||||
}
|
||||
#endif // !Q_OS_WINCE
|
||||
|
||||
if (!(integrationOptions & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch))
|
||||
touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation);
|
||||
|
||||
QWindowSystemInterface::registerTouchDevice(touchDevice);
|
||||
|
||||
d->m_systemInfo |= QWindowsContext::SI_SupportsTouch;
|
||||
return true;
|
||||
}
|
||||
|
||||
void QWindowsContext::setTabletAbsoluteRange(int a)
|
||||
{
|
||||
#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE)
|
||||
|
|
|
|||
|
|
@ -170,6 +170,9 @@ public:
|
|||
explicit QWindowsContext();
|
||||
~QWindowsContext();
|
||||
|
||||
bool initTouch();
|
||||
bool initTouch(unsigned integrationOptions); // For calls from QWindowsIntegration::QWindowsIntegration() only.
|
||||
|
||||
int defaultDPI() const;
|
||||
|
||||
QString registerWindowClass(const QWindow *w);
|
||||
|
|
|
|||
|
|
@ -230,17 +230,7 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mL
|
|||
<< __FUNCTION__ << "DpiAwareness=" << dpiAwareness <<",Scaling="
|
||||
<< QWindowsScaling::factor();
|
||||
|
||||
QTouchDevice *touchDevice = m_context.touchDevice();
|
||||
if (touchDevice) {
|
||||
#ifdef Q_OS_WINCE
|
||||
touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation);
|
||||
#else
|
||||
if (!(m_options & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch)) {
|
||||
touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation);
|
||||
}
|
||||
#endif
|
||||
QWindowSystemInterface::registerTouchDevice(touchDevice);
|
||||
}
|
||||
m_context.initTouch(m_options);
|
||||
}
|
||||
|
||||
QWindowsIntegrationPrivate::~QWindowsIntegrationPrivate()
|
||||
|
|
|
|||
|
|
@ -150,12 +150,19 @@ static inline QTouchDevice *createTouchDevice()
|
|||
QWindowsMouseHandler::QWindowsMouseHandler() :
|
||||
m_windowUnderMouse(0),
|
||||
m_trackedWindow(0),
|
||||
m_touchDevice(createTouchDevice()),
|
||||
m_touchDevice(Q_NULLPTR),
|
||||
m_leftButtonDown(false),
|
||||
m_previousCaptureWindow(0)
|
||||
{
|
||||
}
|
||||
|
||||
QTouchDevice *QWindowsMouseHandler::ensureTouchDevice()
|
||||
{
|
||||
if (!m_touchDevice)
|
||||
m_touchDevice = createTouchDevice();
|
||||
return m_touchDevice;
|
||||
}
|
||||
|
||||
Qt::MouseButtons QWindowsMouseHandler::queryMouseButtons()
|
||||
{
|
||||
Qt::MouseButtons result = 0;
|
||||
|
|
@ -480,7 +487,11 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
|
|||
typedef QWindowSystemInterface::TouchPoint QTouchPoint;
|
||||
typedef QList<QWindowSystemInterface::TouchPoint> QTouchPointList;
|
||||
|
||||
Q_ASSERT(m_touchDevice);
|
||||
if (!QWindowsContext::instance()->initTouch()) {
|
||||
qWarning("Unable to initialize touch handling.");
|
||||
return true;
|
||||
}
|
||||
|
||||
const QRect screenGeometry = window->screen()->geometry();
|
||||
|
||||
const int winTouchPointCount = msg.wParam;
|
||||
|
|
@ -491,8 +502,6 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
|
|||
touchPoints.reserve(winTouchPointCount);
|
||||
Qt::TouchPointStates allStates = 0;
|
||||
|
||||
Q_ASSERT(QWindowsContext::user32dll.getTouchInputInfo);
|
||||
|
||||
QWindowsContext::user32dll.getTouchInputInfo((HANDLE) msg.lParam, msg.wParam, winTouchInputs.data(), sizeof(TOUCHINPUT));
|
||||
const qreal screenPosFactor = 0.01 / qreal(QWindowsScaling::factor());
|
||||
for (int i = 0; i < winTouchPointCount; ++i) {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ public:
|
|||
QWindowsMouseHandler();
|
||||
|
||||
QTouchDevice *touchDevice() const { return m_touchDevice; }
|
||||
QTouchDevice *ensureTouchDevice();
|
||||
|
||||
bool translateMouseEvent(QWindow *widget, HWND hwnd,
|
||||
QtWindows::WindowsEventType t, MSG msg,
|
||||
|
|
|
|||
Loading…
Reference in New Issue