Windows QPA: Directly link against touch functions
They are available on Windows 7. Change-Id: Ia937c459fe0df0d39d407ca0e65641f8aa583f4a Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This commit is contained in:
parent
53fb2c48ef
commit
cccede8fc7
@ -198,19 +198,6 @@ void QWindowsUser32DLL::init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QWindowsUser32DLL::initTouch()
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QWindowsShcoreDLL::init()
|
void QWindowsShcoreDLL::init()
|
||||||
{
|
{
|
||||||
if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8_1)
|
if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8_1)
|
||||||
@ -267,7 +254,7 @@ QWindowsContextPrivate::QWindowsContextPrivate()
|
|||||||
QWindowsContext::user32dll.init();
|
QWindowsContext::user32dll.init();
|
||||||
QWindowsContext::shcoredll.init();
|
QWindowsContext::shcoredll.init();
|
||||||
|
|
||||||
if (m_mouseHandler.touchDevice() && QWindowsContext::user32dll.initTouch())
|
if (m_mouseHandler.touchDevice())
|
||||||
m_systemInfo |= QWindowsContext::SI_SupportsTouch;
|
m_systemInfo |= QWindowsContext::SI_SupportsTouch;
|
||||||
m_displayContext = GetDC(0);
|
m_displayContext = GetDC(0);
|
||||||
m_defaultDPI = GetDeviceCaps(m_displayContext, LOGPIXELSY);
|
m_defaultDPI = GetDeviceCaps(m_displayContext, LOGPIXELSY);
|
||||||
@ -325,11 +312,6 @@ bool QWindowsContext::initTouch(unsigned integrationOptions)
|
|||||||
if (!touchDevice)
|
if (!touchDevice)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!QWindowsContext::user32dll.initTouch()) {
|
|
||||||
delete touchDevice;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(integrationOptions & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch))
|
if (!(integrationOptions & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch))
|
||||||
touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation);
|
touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation);
|
||||||
|
|
||||||
|
@ -84,13 +84,7 @@ class QTouchDevice;
|
|||||||
struct QWindowsUser32DLL
|
struct QWindowsUser32DLL
|
||||||
{
|
{
|
||||||
inline void init();
|
inline void init();
|
||||||
inline bool initTouch();
|
|
||||||
|
|
||||||
typedef BOOL (WINAPI *IsTouchWindow)(HWND, PULONG); // Windows 7
|
|
||||||
typedef BOOL (WINAPI *RegisterTouchWindow)(HWND, ULONG);
|
|
||||||
typedef BOOL (WINAPI *UnregisterTouchWindow)(HWND);
|
|
||||||
typedef BOOL (WINAPI *GetTouchInputInfo)(HANDLE, UINT, PVOID, int);
|
|
||||||
typedef BOOL (WINAPI *CloseTouchInputHandle)(HANDLE);
|
|
||||||
typedef BOOL (WINAPI *SetProcessDPIAware)();
|
typedef BOOL (WINAPI *SetProcessDPIAware)();
|
||||||
typedef BOOL (WINAPI *AddClipboardFormatListener)(HWND);
|
typedef BOOL (WINAPI *AddClipboardFormatListener)(HWND);
|
||||||
typedef BOOL (WINAPI *RemoveClipboardFormatListener)(HWND);
|
typedef BOOL (WINAPI *RemoveClipboardFormatListener)(HWND);
|
||||||
@ -100,13 +94,6 @@ struct QWindowsUser32DLL
|
|||||||
typedef int (WINAPI *GetWindowDpiAwarenessContext)(HWND);
|
typedef int (WINAPI *GetWindowDpiAwarenessContext)(HWND);
|
||||||
typedef int (WINAPI *GetAwarenessFromDpiAwarenessContext)(int);
|
typedef int (WINAPI *GetAwarenessFromDpiAwarenessContext)(int);
|
||||||
|
|
||||||
// Touch functions from Windows 7 onwards (also for use with Q_CC_MSVC).
|
|
||||||
IsTouchWindow isTouchWindow = nullptr;
|
|
||||||
RegisterTouchWindow registerTouchWindow = nullptr;
|
|
||||||
UnregisterTouchWindow unregisterTouchWindow = nullptr;
|
|
||||||
GetTouchInputInfo getTouchInputInfo = nullptr;
|
|
||||||
CloseTouchInputHandle closeTouchInputHandle = nullptr;
|
|
||||||
|
|
||||||
// Windows Vista onwards
|
// Windows Vista onwards
|
||||||
SetProcessDPIAware setProcessDPIAware = nullptr;
|
SetProcessDPIAware setProcessDPIAware = nullptr;
|
||||||
|
|
||||||
|
@ -37,6 +37,13 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(WINVER) && WINVER < 0x0601
|
||||||
|
# undef WINVER
|
||||||
|
#endif
|
||||||
|
#if !defined(WINVER)
|
||||||
|
# define WINVER 0x0601 // Enable touch functions for MinGW
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "qwindowsmousehandler.h"
|
#include "qwindowsmousehandler.h"
|
||||||
#include "qwindowskeymapper.h"
|
#include "qwindowskeymapper.h"
|
||||||
#include "qwindowscontext.h"
|
#include "qwindowscontext.h"
|
||||||
@ -56,37 +63,6 @@
|
|||||||
|
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
|
|
||||||
/* Touch is supported from Windows 7 onwards and data structures
|
|
||||||
* are present in the Windows SDK's, but not in older MSVC Express
|
|
||||||
* versions. */
|
|
||||||
|
|
||||||
#if defined(Q_CC_MINGW) || !defined(TOUCHEVENTF_MOVE)
|
|
||||||
|
|
||||||
typedef struct tagTOUCHINPUT {
|
|
||||||
LONG x;
|
|
||||||
LONG y;
|
|
||||||
HANDLE hSource;
|
|
||||||
DWORD dwID;
|
|
||||||
DWORD dwFlags;
|
|
||||||
DWORD dwMask;
|
|
||||||
DWORD dwTime;
|
|
||||||
ULONG_PTR dwExtraInfo;
|
|
||||||
DWORD cxContact;
|
|
||||||
DWORD cyContact;
|
|
||||||
} TOUCHINPUT, *PTOUCHINPUT;
|
|
||||||
typedef TOUCHINPUT const * PCTOUCHINPUT;
|
|
||||||
|
|
||||||
# define TOUCHEVENTF_MOVE 0x0001
|
|
||||||
# define TOUCHEVENTF_DOWN 0x0002
|
|
||||||
# define TOUCHEVENTF_UP 0x0004
|
|
||||||
# define TOUCHEVENTF_INRANGE 0x0008
|
|
||||||
# define TOUCHEVENTF_PRIMARY 0x0010
|
|
||||||
# define TOUCHEVENTF_NOCOALESCE 0x0020
|
|
||||||
# define TOUCHEVENTF_PALM 0x0080
|
|
||||||
# define TOUCHINPUTMASKF_CONTACTAREA 0x0004
|
|
||||||
# define TOUCHINPUTMASKF_EXTRAINFO 0x0002
|
|
||||||
#endif // if defined(Q_CC_MINGW) || !defined(TOUCHEVENTF_MOVE)
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
static inline void compressMouseMove(MSG *msg)
|
static inline void compressMouseMove(MSG *msg)
|
||||||
@ -522,9 +498,8 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
|
|||||||
touchPoints.reserve(winTouchPointCount);
|
touchPoints.reserve(winTouchPointCount);
|
||||||
Qt::TouchPointStates allStates = 0;
|
Qt::TouchPointStates allStates = 0;
|
||||||
|
|
||||||
QWindowsContext::user32dll.getTouchInputInfo(reinterpret_cast<HANDLE>(msg.lParam),
|
GetTouchInputInfo(reinterpret_cast<HTOUCHINPUT>(msg.lParam),
|
||||||
UINT(msg.wParam),
|
UINT(msg.wParam), winTouchInputs.data(), sizeof(TOUCHINPUT));
|
||||||
winTouchInputs.data(), sizeof(TOUCHINPUT));
|
|
||||||
for (int i = 0; i < winTouchPointCount; ++i) {
|
for (int i = 0; i < winTouchPointCount; ++i) {
|
||||||
const TOUCHINPUT &winTouchInput = winTouchInputs[i];
|
const TOUCHINPUT &winTouchInput = winTouchInputs[i];
|
||||||
int id = m_touchInputIDToTouchPointID.value(winTouchInput.dwID, -1);
|
int id = m_touchInputIDToTouchPointID.value(winTouchInput.dwID, -1);
|
||||||
@ -565,7 +540,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
|
|||||||
touchPoints.append(touchPoint);
|
touchPoints.append(touchPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWindowsContext::user32dll.closeTouchInputHandle(reinterpret_cast<HANDLE>(msg.lParam));
|
CloseTouchInputHandle(reinterpret_cast<HTOUCHINPUT>(msg.lParam));
|
||||||
|
|
||||||
// all touch points released, forget the ids we've seen, they may not be reused
|
// all touch points released, forget the ids we've seen, they may not be reused
|
||||||
if (allStates == Qt::TouchPointReleased)
|
if (allStates == Qt::TouchPointReleased)
|
||||||
|
@ -37,6 +37,13 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(WINVER) && WINVER < 0x0601
|
||||||
|
# undef WINVER
|
||||||
|
#endif
|
||||||
|
#if !defined(WINVER)
|
||||||
|
# define WINVER 0x0601 // Enable touch functions for MinGW
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "qwindowswindow.h"
|
#include "qwindowswindow.h"
|
||||||
#include "qwindowscontext.h"
|
#include "qwindowscontext.h"
|
||||||
#if QT_CONFIG(draganddrop)
|
#if QT_CONFIG(draganddrop)
|
||||||
@ -1110,7 +1117,7 @@ QWindowsWindow::~QWindowsWindow()
|
|||||||
{
|
{
|
||||||
setFlag(WithinDestroy);
|
setFlag(WithinDestroy);
|
||||||
if (testFlag(TouchRegistered))
|
if (testFlag(TouchRegistered))
|
||||||
QWindowsContext::user32dll.unregisterTouchWindow(m_data.hwnd);
|
UnregisterTouchWindow(m_data.hwnd);
|
||||||
destroyWindow();
|
destroyWindow();
|
||||||
destroyIcon();
|
destroyIcon();
|
||||||
}
|
}
|
||||||
@ -2585,12 +2592,12 @@ void QWindowsWindow::registerTouchWindow(QWindowsWindowFunctions::TouchWindowTou
|
|||||||
if ((QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch)
|
if ((QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch)
|
||||||
&& !testFlag(TouchRegistered)) {
|
&& !testFlag(TouchRegistered)) {
|
||||||
ULONG touchFlags = 0;
|
ULONG touchFlags = 0;
|
||||||
const bool ret = QWindowsContext::user32dll.isTouchWindow(m_data.hwnd, &touchFlags);
|
const bool ret = IsTouchWindow(m_data.hwnd, &touchFlags);
|
||||||
// Return if it is not a touch window or the flags are already set by a hook
|
// Return if it is not a touch window or the flags are already set by a hook
|
||||||
// such as HCBT_CREATEWND
|
// such as HCBT_CREATEWND
|
||||||
if (ret || touchFlags != 0)
|
if (ret || touchFlags != 0)
|
||||||
return;
|
return;
|
||||||
if (QWindowsContext::user32dll.registerTouchWindow(m_data.hwnd, ULONG(touchTypes)))
|
if (RegisterTouchWindow(m_data.hwnd, ULONG(touchTypes)))
|
||||||
setFlag(TouchRegistered);
|
setFlag(TouchRegistered);
|
||||||
else
|
else
|
||||||
qErrnoWarning("RegisterTouchWindow() failed for window '%s'.", qPrintable(window()->objectName()));
|
qErrnoWarning("RegisterTouchWindow() failed for window '%s'.", qPrintable(window()->objectName()));
|
||||||
|
Loading…
Reference in New Issue
Block a user