diff options
author | Andre de la Rocha <andre.rocha@qt.io> | 2020-03-31 07:41:45 +0200 |
---|---|---|
committer | Andre de la Rocha <andre.rocha@qt.io> | 2020-04-10 01:52:35 +0200 |
commit | 4c4693cf964e9d7370c27a26e1d263a262aee568 (patch) | |
tree | 1f4625268d623a8856a7151959fb619890e796b8 /src/plugins/platforms/windows/qwindowsintegration.cpp | |
parent | ae57e4fba5be0b7da5ca721fd672f08a14c9d19e (diff) |
Windows: Provide a way to switch between WinTab and Windows Ink at run-time
This change adds the setWinTabEnabled() function to Qt Platform Headers,
which allows an application to set at run-time whether the WinTab API will
be used for tablet input instead of the native Windows Ink API.
[ChangeLog][Windows] The setWinTabEnabled() function added to Qt Platform
Headers now allows an application to set at run-time whether the WinTab API
will be used for tablet input instead of the native Windows Ink API.
Fixes: QTBUG-83218
Change-Id: I51d3c7316baeda136763cf37c2f54295905450ec
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsintegration.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsintegration.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 977b5903a5..2c87e80ec7 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -140,6 +140,7 @@ struct QWindowsIntegrationPrivate ~QWindowsIntegrationPrivate(); unsigned m_options = 0; + int m_tabletAbsoluteRange = -1; QWindowsContext m_context; QPlatformFontDatabase *m_fontDatabase = nullptr; #if QT_CONFIG(clipboard) @@ -239,19 +240,18 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mL initOpenGlBlacklistResources(); static bool dpiAwarenessSet = false; - int tabletAbsoluteRange = -1; // Default to per-monitor awareness to avoid being scaled when monitors with different DPI // are connected to Windows 8.1 QtWindows::ProcessDpiAwareness dpiAwareness = QtWindows::ProcessPerMonitorDpiAware; - m_options = parseOptions(paramList, &tabletAbsoluteRange, &dpiAwareness); + m_options = parseOptions(paramList, &m_tabletAbsoluteRange, &dpiAwareness); QWindowsFontDatabase::setFontOptions(m_options); if (m_context.initPointer(m_options)) { QCoreApplication::setAttribute(Qt::AA_CompressHighFrequencyEvents); } else { m_context.initTablet(m_options); - if (tabletAbsoluteRange >= 0) - m_context.setTabletAbsoluteRange(tabletAbsoluteRange); + if (m_tabletAbsoluteRange >= 0) + m_context.setTabletAbsoluteRange(m_tabletAbsoluteRange); } if (!dpiAwarenessSet) { // Set only once in case of repeated instantiations of QGuiApplication. @@ -642,6 +642,28 @@ void QWindowsIntegration::beep() const MessageBeep(MB_OK); // For QApplication } +bool QWindowsIntegration::setWinTabEnabled(bool enabled) +{ + bool ret = false; + if (QWindowsIntegration *p = QWindowsIntegration::instance()) { + if (enabled) { + if (p->d->m_context.tabletSupport()) { + ret = true; + } else { + ret = p->d->m_context.initTablet(p->d->m_options); + if (ret && p->d->m_tabletAbsoluteRange >= 0) + p->d->m_context.setTabletAbsoluteRange(p->d->m_tabletAbsoluteRange); + } + } else { + if (p->d->m_context.tabletSupport()) + ret = p->d->m_context.disposeTablet(); + else + ret = true; + } + } + return ret; +} + #if QT_CONFIG(vulkan) QPlatformVulkanInstance *QWindowsIntegration::createPlatformVulkanInstance(QVulkanInstance *instance) const { |