Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
[win] Implement Tablet API switching using Qt6 interfaces
Dmitry Kazakov885f3348c6b8
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 96f7a92e16..962de13c15 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -498,7 +498,7 @@ if (QT_MAJOR_VERSION STREQUAL "6")endif()-if (WIN32)+if (WIN32 AND QT_MAJOR_VERSION STREQUAL "5")set(CMAKE_REQUIRED_INCLUDES ${Qt5Core_INCLUDE_DIRS})set(CMAKE_REQUIRED_LIBRARIES ${Qt5Core_LIBRARIES})@@ -508,16 +508,14 @@ int main(int argc, char *argv[]) {QCoreApplication::setAttribute(Qt::AA_MSWindowsUseWinTabAPI);}"- QT_HAS_WINTAB_SWITCH+ QT5_HAS_WINTAB_SWITCH)unset(CMAKE_REQUIRED_INCLUDES)unset(CMAKE_REQUIRED_LIBRARIES)- option(USE_QT_TABLET_WINDOWS "Do not use Krita's forked Wintab and Windows Ink support on Windows, but leave everything to Qt." ON)- add_feature_info("Use Qt's Windows Tablet Support" USE_QT_TABLET_WINDOWS "Do not use Krita's forked Wintab and Windows Ink support on Windows, but leave everything to Qt.")configure_file(config_use_qt_tablet_windows.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config_use_qt_tablet_windows.h)-endif ()+endif ()set(CMAKE_REQUIRED_INCLUDES ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})set(CMAKE_REQUIRED_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES})diff --git a/config_use_qt_tablet_windows.h.cmake b/config_use_qt_tablet_windows.h.cmakeindex e118b91f92..73af6abcc4 100644--- a/config_use_qt_tablet_windows.h.cmake+++ b/config_use_qt_tablet_windows.h.cmake@@ -1,2 +1 @@-#cmakedefine USE_QT_TABLET_WINDOWS !-#cmakedefine QT_HAS_WINTAB_SWITCH !+#cmakedefine QT5_HAS_WINTAB_SWITCH !diff --git a/krita/CMakeLists.txt b/krita/CMakeLists.txtindex 42ed7c939d..47bfdaea7a 100644--- a/krita/CMakeLists.txt+++ b/krita/CMakeLists.txt@@ -28,6 +28,15 @@ else())endif()+if (WIN32)+ # Private headers are needed for main.cc to enable WinTab support+ set_source_files_properties(+ main.cc+ PROPERTIES+ INCLUDE_DIRECTORIES "${Qt${QT_MAJOR_VERSION}Gui_PRIVATE_INCLUDE_DIRS}"+ )+endif()+if (WIN32)set(krita_windows_stub_ICONS_SRCS "")ecm_add_app_icon(krita_windows_stub_ICONS_SRCS ICONS ${ICON_SRCS} OUTFILE_BASENAME krita)diff --git a/krita/main.cc b/krita/main.ccindex a4dc90e725..c224bbfe38 100644--- a/krita/main.cc+++ b/krita/main.cc@@ -57,15 +57,16 @@#endif#if defined Q_OS_WIN-#include "config_use_qt_tablet_windows.h"+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)+// this include is Qt5-only, the switch to WinTab is embedded in Qt+# include "config_use_qt_tablet_windows.h"+#else+# include <QtGui/private/qguiapplication_p.h>+# include <QtGui/qpa/qplatformintegration.h>+#endif#include <windows.h>#include <winuser.h>-#ifndef USE_QT_TABLET_WINDOWS-#include <kis_tablet_support_win.h>-#include <kis_tablet_support_win8.h>-#else#include <dialogs/KisDlgCustomTabletResolution.h>-#endif#include "config-high-dpi-scale-factor-rounding-policy.h"#include "config-set-has-border-in-full-screen-default.h"#ifdef HAVE_SET_HAS_BORDER_IN_FULL_SCREEN_DEFAULT@@ -547,7 +548,7 @@ extern "C" MAIN_EXPORT int MAIN_FN(int argc, char **argv)KisUsageLogger::writeLocaleSysInfo();-#if defined Q_OS_WIN && defined USE_QT_TABLET_WINDOWS && defined QT_HAS_WINTAB_SWITCH+#if defined Q_OS_WIN && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && defined QT5_HAS_WINTAB_SWITCHconst bool forceWinTab = !KisConfig::useWin8PointerInputNoApp(&kritarc);QCoreApplication::setAttribute(Qt::AA_MSWindowsUseWinTabAPI, forceWinTab);@@ -564,6 +565,15 @@ extern "C" MAIN_EXPORT int MAIN_FN(int argc, char **argv)// first create the application so we can create a pixmapKisApplication app(key, argc, argv);+#if defined Q_OS_WIN && QT_VERSION > QT_VERSION_CHECK(6, 0, 0)+ const bool forceWinTab = !KisConfig::useWin8PointerInputNoApp(&kritarc);+ using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;+ if (auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration())) {+ nativeWindowsApp->setWinTabEnabled(forceWinTab);+ }+#endif++installTranslators(app);if (KisApplication::platformName() == "wayland") {@@ -680,14 +690,10 @@ extern "C" MAIN_EXPORT int MAIN_FN(int argc, char **argv)#if defined Q_OS_WINKisConfig cfg(false);- bool supportedWindowsVersion = true;QOperatingSystemVersion osVersion = QOperatingSystemVersion::current();if (osVersion.type() == QOperatingSystemVersion::Windows) {- if (osVersion.majorVersion() >= QOperatingSystemVersion::Windows7.majorVersion()) {- supportedWindowsVersion = true;- }- else {- supportedWindowsVersion = false;+ // TODO QT6: update minimum requirement+ if (osVersion.majorVersion() < QOperatingSystemVersion::Windows7.majorVersion()) {if (cfg.readEntry("WarnedAboutUnsupportedWindows", false)) {QMessageBox::information(nullptr,i18nc("@title:window", "Krita: Warning"),@@ -699,48 +705,8 @@ extern "C" MAIN_EXPORT int MAIN_FN(int argc, char **argv)}}}-#ifndef USE_QT_TABLET_WINDOWS- {- if (cfg.useWin8PointerInput() && !KisTabletSupportWin8::isAvailable()) {- cfg.setUseWin8PointerInput(false);- }- if (!cfg.useWin8PointerInput()) {- bool hasWinTab = KisTabletSupportWin::init();- if (!hasWinTab && supportedWindowsVersion) {- if (KisTabletSupportWin8::isPenDeviceAvailable()) {- // Use WinInk automatically- cfg.setUseWin8PointerInput(true);- } else if (!cfg.readEntry("WarnedAboutMissingWinTab", false)) {- if (KisTabletSupportWin8::isAvailable()) {- QMessageBox::information(nullptr,- i18n("Krita Tablet Support"),- i18n("Cannot load WinTab driver and no Windows Ink pen devices are found. If you have a drawing tablet, please make sure the tablet driver is properly installed."),- QMessageBox::Ok, QMessageBox::Ok);- } else {- QMessageBox::information(nullptr,- i18n("Krita Tablet Support"),- i18n("Cannot load WinTab driver. If you have a drawing tablet, please make sure the tablet driver is properly installed."),- QMessageBox::Ok, QMessageBox::Ok);- }- cfg.writeEntry("WarnedAboutMissingWinTab", true);- }- }- }- if (cfg.useWin8PointerInput()) {- KisTabletSupportWin8 *penFilter = new KisTabletSupportWin8();- if (penFilter->init()) {- // penFilter.registerPointerDeviceNotifications();- app.installNativeEventFilter(penFilter);- dbgKrita << "Using Win8 Pointer Input for tablet support";- } else {- dbgKrita << "No Win8 Pointer Input available";- delete penFilter;- }- }- }-#elif defined QT_HAS_WINTAB_SWITCH- Q_UNUSED(supportedWindowsVersion);+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && defined QT5_HAS_WINTAB_SWITCH// Check if WinTab/WinInk has actually activatedconst bool useWinInkAPI = !KisApplication::testAttribute(Qt::AA_MSWindowsUseWinTabAPI);@@ -750,7 +716,6 @@ extern "C" MAIN_EXPORT int MAIN_FN(int argc, char **argv)cfg.setUseWin8PointerInput(useWinInkAPI);cfg.setUseRightMiddleTabletButtonWorkaround(true);}-#endif#endifKisApplication::setAttribute(Qt::AA_CompressHighFrequencyEvents, false);@@ -777,9 +742,32 @@ extern "C" MAIN_EXPORT int MAIN_FN(int argc, char **argv)KisUsageLogger::writeSysInfo(QString(" Supported instruction sets: %1").arg(KisSupportedArchitectures::supportedInstructionSets()));-KisUsageLogger::writeSysInfo("");+ // Tablet API information+#if defined Q_OS_WIN && QT_VERSION > QT_VERSION_CHECK(6, 0, 0)+ {+ auto tabletAPIName = [] (bool useWinTab) {+ return useWinTab ? "WinTab" : "WinInk";+ };++ QString actualTabletProtocol = "<unknown>";++ using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;+ if (auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration())) {+ actualTabletProtocol = tabletAPIName(nativeWindowsApp->isWinTabEnabled());+ } else {+ KisUsageLogger::log("WARNING: Failed to fetch WinTab protocol status: QWindowsApplication is not available");+ }++ KisUsageLogger::writeSysInfo("\nTablet API Information\n");+ KisUsageLogger::writeSysInfo(QString(" User-selected tablet API: %1").arg(tabletAPIName(!cfg.useWin8PointerInput())));+ KisUsageLogger::writeSysInfo(QString(" Actually used tablet API: %1").arg(actualTabletProtocol));+ KisUsageLogger::writeSysInfo("");+ }+#endif++KisConfig(true).logImportantSettings();KisApplication::setFont(KisUiFont::normalFont());diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txtindex aa13d2ffc0..6974f13f25 100644--- a/libs/ui/CMakeLists.txt+++ b/libs/ui/CMakeLists.txt@@ -493,19 +493,10 @@ if(WIN32)${kritaui_LIB_SRCS}qtlockedfile/qtlockedfile_win.cpp)- if (NOT USE_QT_TABLET_WINDOWS)- set(kritaui_LIB_SRCS- ${kritaui_LIB_SRCS}- input/wintab/kis_tablet_support_win.cpp- input/wintab/kis_screen_size_choice_dialog.cpp- input/wintab/kis_tablet_support_win8.cpp- )- else()- set(kritaui_LIB_SRCS- ${kritaui_LIB_SRCS}- dialogs/KisDlgCustomTabletResolution.cpp- )- endif()+ set(kritaui_LIB_SRCS+ ${kritaui_LIB_SRCS}+ dialogs/KisDlgCustomTabletResolution.cpp+ )endif()set(kritaui_LIB_SRCS@@ -650,7 +641,6 @@ ki18n_wrap_ui(kritaui_LIB_SRCSlayerstyles/wdgKisLayerStyleAngleSelector.uiwdgsplash.ui- input/wintab/kis_screen_size_choice_dialog.uiinput/wintab/drawpile_tablettester/tablettest.uianimation/wdg_animationrenderer.ui@@ -664,15 +654,9 @@ ki18n_wrap_ui(kritaui_LIB_SRCS)if(WIN32)- if(USE_QT_TABLET_WINDOWS)- ki18n_wrap_ui(kritaui_LIB_SRCS- dialogs/KisDlgCustomTabletResolution.ui- )- else()- ki18n_wrap_ui(kritaui_LIB_SRCS- input/wintab/kis_screen_size_choice_dialog.ui- )- endif()+ ki18n_wrap_ui(kritaui_LIB_SRCS+ dialogs/KisDlgCustomTabletResolution.ui+ )endif()@@ -707,9 +691,11 @@ if(WIN32)# Private headers are needed for:# * KisDlgCustomTabletResolution# * KisScreenInformationAdapter+ # * dialogs/kis_dlg_preferences.ccset_source_files_properties(dialogs/KisDlgCustomTabletResolution.cppopengl/KisScreenInformationAdapter.cpp+ dialogs/kis_dlg_preferences.cc # for WinTab switching APIPROPERTIESINCLUDE_DIRECTORIES "${Qt${QT_MAJOR_VERSION}Gui_PRIVATE_INCLUDE_DIRS}")diff --git a/libs/ui/dialogs/kis_dlg_preferences.cc b/libs/ui/dialogs/kis_dlg_preferences.ccindex beaa400193..cb450edcb1 100644--- a/libs/ui/dialogs/kis_dlg_preferences.cc+++ b/libs/ui/dialogs/kis_dlg_preferences.cc@@ -99,10 +99,13 @@#include "KisDlgConfigureCumulativeUndo.h"#ifdef Q_OS_WIN-#include "config_use_qt_tablet_windows.h"-# ifndef USE_QT_TABLET_WINDOWS-# include <kis_tablet_support_win8.h>-# endif+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)+// this include is Qt5-only, the switch to WinTab is embedded in Qt+# include "config_use_qt_tablet_windows.h"+#else+# include <QtGui/private/qguiapplication_p.h>+# include <QtGui/qpa/qplatformintegration.h>+#endif#include "config-high-dpi-scale-factor-rounding-policy.h"#include "KisWindowsPackageUtils.h"#endif@@ -1367,21 +1370,9 @@ void TabletSettingsTab::setDefault()m_page->chkUseRightMiddleClickWorkaround->setChecked(KisConfig(true).useRightMiddleTabletButtonWorkaround(true));-#if defined Q_OS_WIN && (!defined USE_QT_TABLET_WINDOWS || defined QT_HAS_WINTAB_SWITCH)--#ifdef USE_QT_TABLET_WINDOWS- // ask Qt if WinInk is actually available- const bool isWinInkAvailable = true;-#else- const bool isWinInkAvailable = KisTabletSupportWin8::isAvailable();-#endif- if (isWinInkAvailable) {+#if defined Q_OS_WIN && (defined QT5_HAS_WINTAB_SWITCH || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))m_page->radioWintab->setChecked(!cfg.useWin8PointerInput(true));m_page->radioWin8PointerInput->setChecked(cfg.useWin8PointerInput(true));- } else {- m_page->radioWintab->setChecked(true);- m_page->radioWin8PointerInput->setChecked(false);- }#elsem_page->grpTabletApi->setVisible(false);#endif@@ -1409,30 +1400,21 @@ TabletSettingsTab::TabletSettingsTab(QWidget* parent, const char* name): QWidgetm_page->chkUseRightMiddleClickWorkaround->setChecked(cfg.useRightMiddleTabletButtonWorkaround());-#if defined Q_OS_WIN && (!defined USE_QT_TABLET_WINDOWS || defined QT_HAS_WINTAB_SWITCH)-#ifdef USE_QT_TABLET_WINDOWS- // ask Qt if WinInk is actually available- const bool isWinInkAvailable = true;-#else- const bool isWinInkAvailable = KisTabletSupportWin8::isAvailable();-#endif- if (isWinInkAvailable) {- m_page->radioWintab->setChecked(!cfg.useWin8PointerInput());- m_page->radioWin8PointerInput->setChecked(cfg.useWin8PointerInput());- } else {- m_page->radioWintab->setChecked(true);- m_page->radioWin8PointerInput->setChecked(false);- m_page->grpTabletApi->setVisible(false);+#if defined Q_OS_WIN && (defined QT5_HAS_WINTAB_SWITCH || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))+# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)+ QString actualTabletProtocol = "<unknown>";+ using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;+ if (auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration())) {+ actualTabletProtocol = nativeWindowsApp->isWinTabEnabled() ? "WinTab" : "Windows Ink";}+ m_page->grpTabletApi->setTitle(i18n("Tablet Input API (currently active API: \"%1\")", actualTabletProtocol));+# endif+ m_page->radioWintab->setChecked(!cfg.useWin8PointerInput());+ m_page->radioWin8PointerInput->setChecked(cfg.useWin8PointerInput());-#ifdef USE_QT_TABLET_WINDOWSconnect(m_page->btnResolutionSettings, SIGNAL(clicked()), SLOT(slotResolutionSettings()));connect(m_page->radioWintab, SIGNAL(toggled(bool)), m_page->btnResolutionSettings, SLOT(setEnabled(bool)));m_page->btnResolutionSettings->setEnabled(m_page->radioWintab->isChecked());-#else- m_page->btnResolutionSettings->setVisible(false);-#endif-#elsem_page->grpTabletApi->setVisible(false);#endif@@ -1476,16 +1458,12 @@ void TabletSettingsTab::slotTabletTest()tabletTestDialog.exec();}-#if defined Q_OS_WIN && defined USE_QT_TABLET_WINDOWS#include "KisDlgCustomTabletResolution.h"-#endifvoid TabletSettingsTab::slotResolutionSettings(){-#if defined Q_OS_WIN && defined USE_QT_TABLET_WINDOWSKisDlgCustomTabletResolution dlg(this);dlg.exec();-#endif}@@ -2581,16 +2559,16 @@ bool KisDlgPreferences::editPreferences()cfg.setUseRightMiddleTabletButtonWorkaround(m_tabletSettings->m_page->chkUseRightMiddleClickWorkaround->isChecked());-#if defined Q_OS_WIN && (!defined USE_QT_TABLET_WINDOWS || defined QT_HAS_WINTAB_SWITCH)-#ifdef USE_QT_TABLET_WINDOWS- // ask Qt if WinInk is actually available- const bool isWinInkAvailable = true;-#else- const bool isWinInkAvailable = KisTabletSupportWin8::isAvailable();-#endif- if (isWinInkAvailable) {- cfg.setUseWin8PointerInput(m_tabletSettings->m_page->radioWin8PointerInput->isChecked());+#if defined Q_OS_WIN && (defined QT5_HAS_WINTAB_SWITCH || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))+ cfg.setUseWin8PointerInput(m_tabletSettings->m_page->radioWin8PointerInput->isChecked());++# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)+ // Qt6 supports switching the tablet API on the fly+ using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;+ if (auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration())) {+ nativeWindowsApp->setWinTabEnabled(!cfg.useWin8PointerInput());}+# endif#endifcfg.writeEntry<bool>("useTimestampsForBrushSpeed", m_tabletSettings->m_page->chkUseTimestampsForBrushSpeed->isChecked());cfg.writeEntry<int>("maxAllowedSpeedValue", m_tabletSettings->m_page->intMaxAllowedBrushSpeed->value());diff --git a/libs/ui/input/wintab/kis_screen_size_choice_dialog.cpp b/libs/ui/input/wintab/kis_screen_size_choice_dialog.cppdeleted file mode 100644index 17fd5f0436..0000000000--- a/libs/ui/input/wintab/kis_screen_size_choice_dialog.cpp+++ /dev/null@@ -1,128 +0,0 @@-/*- * SPDX-FileCopyrightText: 2015 Dmitry Kazakov <[email protected]>- *- * SPDX-License-Identifier: GPL-2.0-or-later- */--#include "kis_screen_size_choice_dialog.h"-#include "ui_kis_screen_size_choice_dialog.h"--#include <QButtonGroup>--#include <kconfig.h>-#include <ksharedconfig.h>-#include <kconfiggroup.h>-#include <kstandardguiitem.h>---#include "kis_debug.h"---QString rectToString(const QRect &rc) {- return i18nc("Screen rect when choosing Wintab/Qt settings", "%1x%2 offset: %3,%4", rc.width(), rc.height(), rc.x(), rc.y());-}--KisScreenSizeChoiceDialog::KisScreenSizeChoiceDialog(QWidget *parent,- const QRect &wintabRect,- const QRect &qtRect)- : QDialog(parent),- ui(new Ui::KisScreenSizeChoiceDialog),- m_wintabRect(wintabRect),- m_qtRect(qtRect)-{- ui->setupUi(this);-- connect(ui->radioManual, SIGNAL(toggled(bool)), ui->lblXOffset, SLOT(setEnabled(bool)));- connect(ui->radioManual, SIGNAL(toggled(bool)), ui->lblYOffset, SLOT(setEnabled(bool)));- connect(ui->radioManual, SIGNAL(toggled(bool)), ui->lblWidth, SLOT(setEnabled(bool)));- connect(ui->radioManual, SIGNAL(toggled(bool)), ui->lblHeight, SLOT(setEnabled(bool)));-- connect(ui->radioManual, SIGNAL(toggled(bool)), ui->intXOffset, SLOT(setEnabled(bool)));- connect(ui->radioManual, SIGNAL(toggled(bool)), ui->intYOffset, SLOT(setEnabled(bool)));- connect(ui->radioManual, SIGNAL(toggled(bool)), ui->intWidth, SLOT(setEnabled(bool)));- connect(ui->radioManual, SIGNAL(toggled(bool)), ui->intHeight, SLOT(setEnabled(bool)));-- // cold-init the state of the manual controls- ui->radioManual->setChecked(true);-- ui->radioWintab->setText(i18nc("@option:radio", "%1 (Wintab)", rectToString(wintabRect)));- ui->radioQt->setText(i18nc("@option:radio", "%1 (Qt)", rectToString(qtRect)));-- m_dataSource = new QButtonGroup(this);- m_dataSource->addButton(ui->radioWintab, 0);- m_dataSource->addButton(ui->radioQt, 1);- m_dataSource->addButton(ui->radioManual, 2);-- loadSettings(wintabRect);-- connect(this, SIGNAL(finished(int)), SLOT(slotFinished()));-- KGuiItem::assign(ui->buttonBox->button(QDialogButtonBox::Ok), KStandardGuiItem::ok());-}--void KisScreenSizeChoiceDialog::slotFinished()-{- saveSettings();-}--bool KisScreenSizeChoiceDialog::canUseDefaultSettings() const-{- return ui->chkRememberSetting->isChecked();-}--QRect KisScreenSizeChoiceDialog::screenRect() const-{- QRect rect;-- switch (m_dataSource->checkedId()) {- case 0:- rect = m_wintabRect;- break;- case 1:- rect = m_qtRect;- break;- case 2:- rect.setRect(ui->intXOffset->value(),- ui->intYOffset->value(),- ui->intWidth->value(),- ui->intHeight->value());- break;-- }-- return rect;-}--void KisScreenSizeChoiceDialog::loadSettings(const QRect &defaultRect)-{- KConfigGroup cfg = KSharedConfig::openConfig()->group("ScreenSizeWorkaroundDialog");- int index = qBound(0, cfg.readEntry("choiceIndex", 0), 2);-- m_dataSource->button(index)->setChecked(true);-- ui->intXOffset->setValue(cfg.readEntry("xOffset", defaultRect.x()));- ui->intYOffset->setValue(cfg.readEntry("yOffset", defaultRect.y()));- ui->intWidth->setValue(cfg.readEntry("Width", defaultRect.width()));- ui->intHeight->setValue(cfg.readEntry("Height", defaultRect.height()));-- ui->chkRememberSetting->setChecked(cfg.readEntry("RememberSetting", false));-}--void KisScreenSizeChoiceDialog::saveSettings()-{- KConfigGroup cfg = KSharedConfig::openConfig()->group("ScreenSizeWorkaroundDialog");-- cfg.writeEntry("choiceIndex", m_dataSource->checkedId());-- cfg.writeEntry("xOffset", ui->intXOffset->value());- cfg.writeEntry("yOffset", ui->intYOffset->value());- cfg.writeEntry("Width", ui->intWidth->value());- cfg.writeEntry("Height", ui->intHeight->value());-- cfg.writeEntry("RememberSetting", ui->chkRememberSetting->isChecked());-}--KisScreenSizeChoiceDialog::~KisScreenSizeChoiceDialog()-{- delete ui;-}diff --git a/libs/ui/input/wintab/kis_screen_size_choice_dialog.h b/libs/ui/input/wintab/kis_screen_size_choice_dialog.hdeleted file mode 100644index c99468fdd8..0000000000--- a/libs/ui/input/wintab/kis_screen_size_choice_dialog.h+++ /dev/null@@ -1,49 +0,0 @@-/*- * SPDX-FileCopyrightText: 2015 Dmitry Kazakov <[email protected]>- *- * SPDX-License-Identifier: GPL-2.0-or-later- */--#ifndef KIS_SCREEN_SIZE_CHOICE_DIALOG_H-#define KIS_SCREEN_SIZE_CHOICE_DIALOG_H--#include <QDialog>--class QButtonGroup;--namespace Ui {-class KisScreenSizeChoiceDialog;-}--class KisScreenSizeChoiceDialog : public QDialog-{- Q_OBJECT--public:- explicit KisScreenSizeChoiceDialog(QWidget *parent,- const QRect &wintabRect,- const QRect &qtRect);-- ~KisScreenSizeChoiceDialog();--- QRect screenRect() const;- bool canUseDefaultSettings() const;--private:- void loadSettings(const QRect &defaultRect);- void saveSettings();--private Q_SLOTS:- void slotFinished();--private:- Ui::KisScreenSizeChoiceDialog *ui;-- QRect m_wintabRect;- QRect m_qtRect;-- QButtonGroup *m_dataSource;-};--#endif // KIS_SCREEN_SIZE_CHOICE_DIALOG_Hdiff --git a/libs/ui/input/wintab/kis_screen_size_choice_dialog.ui b/libs/ui/input/wintab/kis_screen_size_choice_dialog.uideleted file mode 100644index 04eb24db75..0000000000--- a/libs/ui/input/wintab/kis_screen_size_choice_dialog.ui+++ /dev/null@@ -1,226 +0,0 @@-<?xml version="1.0" encoding="utf-8"?>-<ui version="4.0">- <author>- SPDX-FileCopyrightText: none- SPDX-License-Identifier: GPL-3.0-or-later- </author>- <class>KisScreenSizeChoiceDialog</class>- <widget class="QDialog" name="KisScreenSizeChoiceDialog">- <property name="geometry">- <rect>- <x>0</x>- <y>0</y>- <width>376</width>- <height>280</height>- </rect>- </property>- <property name="windowTitle">- <string>Choose screen resolution</string>- </property>- <layout class="QVBoxLayout" name="verticalLayout_3">- <item>- <widget class="QLabel" name="lblTitleMessage">- <property name="text">- <string><html><head/><body><p>The driver for your drawing tablet and Windows do not agree on the size of the screen your tablet is connected to. Please select the right option.</p></body></html></string>- </property>- <property name="wordWrap">- <bool>true</bool>- </property>- </widget>- </item>- <item>- <widget class="QGroupBox" name="groupBox">- <property name="title">- <string/>- </property>- <layout class="QVBoxLayout" name="verticalLayout_2">- <item>- <widget class="QRadioButton" name="radioWintab">- <property name="text">- <string notr="true">This is what the tablet thinks: NO_I18N</string>- </property>- </widget>- </item>- <item>- <widget class="QRadioButton" name="radioQt">- <property name="text">- <string notr="true">This is what the computer thinks: NO_I18N</string>- </property>- </widget>- </item>- <item>- <layout class="QVBoxLayout" name="verticalLayout">- <item>- <widget class="QRadioButton" name="radioManual">- <property name="text">- <string>If both are wrong, enter the size manually:</string>- </property>- </widget>- </item>- <item>- <layout class="QGridLayout" name="gridLayout">- <item column="0" row="0" rowspan="2">- <spacer name="horizontalSpacer">- <property name="orientation">- <enum>Qt::Horizontal</enum>- </property>- <property name="sizeType">- <enum>QSizePolicy::Fixed</enum>- </property>- <property name="sizeHint" stdset="0">- <size>- <width>40</width>- <height>20</height>- </size>- </property>- </spacer>- </item>- <item column="1" row="0">- <widget class="QLabel" name="lblWidth">- <property name="text">- <string>Width:</string>- </property>- </widget>- </item>- <item column="2" row="0">- <widget class="QSpinBox" name="intWidth">- <property name="suffix">- <string>px</string>- </property>- <property name="maximum">- <number>10000</number>- </property>- </widget>- </item>- <item column="3" row="0">- <widget class="QLabel" name="lblXOffset">- <property name="text">- <string>X offset:</string>- </property>- </widget>- </item>- <item column="4" row="0">- <widget class="QSpinBox" name="intXOffset">- <property name="suffix">- <string>px</string>- </property>- <property name="minimum">- <number>-10000</number>- </property>- <property name="maximum">- <number>10000</number>- </property>- </widget>- </item>- <item column="1" row="1">- <widget class="QLabel" name="lblHeight">- <property name="text">- <string>Height:</string>- </property>- </widget>- </item>- <item column="2" row="1">- <widget class="QSpinBox" name="intHeight">- <property name="suffix">- <string>px</string>- </property>- <property name="maximum">- <number>10000</number>- </property>- </widget>- </item>- <item column="3" row="1">- <widget class="QLabel" name="lblYOffset">- <property name="text">- <string>Y offset:</string>- </property>- </widget>- </item>- <item column="4" row="1">- <widget class="QSpinBox" name="intYOffset">- <property name="suffix">- <string>px</string>- </property>- <property name="minimum">- <number>-10000</number>- </property>- <property name="maximum">- <number>10000</number>- </property>- </widget>- </item>- </layout>- </item>- </layout>- </item>- <item>- <widget class="QCheckBox" name="chkRememberSetting">- <property name="text">- <string>Do not ask again (hold Shift to ask again)</string>- </property>- </widget>- </item>- <item>- <spacer name="verticalSpacer">- <property name="orientation">- <enum>Qt::Vertical</enum>- </property>- <property name="sizeHint" stdset="0">- <size>- <width>20</width>- <height>40</height>- </size>- </property>- </spacer>- </item>- </layout>- </widget>- </item>- <item>- <widget class="QDialogButtonBox" name="buttonBox">- <property name="orientation">- <enum>Qt::Horizontal</enum>- </property>- <property name="standardButtons">- <set>QDialogButtonBox::Ok</set>- </property>- </widget>- </item>- </layout>- </widget>- <resources/>- <connections>- <connection>- <sender>buttonBox</sender>- <signal>accepted()</signal>- <receiver>KisScreenSizeChoiceDialog</receiver>- <slot>accept()</slot>- <hints>- <hint type="sourcelabel">- <x>248</x>- <y>254</y>- </hint>- <hint type="destinationlabel">- <x>157</x>- <y>274</y>- </hint>- </hints>- </connection>- <connection>- <sender>buttonBox</sender>- <signal>rejected()</signal>- <receiver>KisScreenSizeChoiceDialog</receiver>- <slot>reject()</slot>- <hints>- <hint type="sourcelabel">- <x>316</x>- <y>260</y>- </hint>- <hint type="destinationlabel">- <x>286</x>- <y>274</y>- </hint>- </hints>- </connection>- </connections>-</ui>\ No newline at end of filediff --git a/libs/ui/input/wintab/kis_tablet_support_win.cpp b/libs/ui/input/wintab/kis_tablet_support_win.cppdeleted file mode 100644index 469c77608e..0000000000--- a/libs/ui/input/wintab/kis_tablet_support_win.cpp+++ /dev/null@@ -1,978 +0,0 @@-/*- * SPDX-FileCopyrightText: 2013 Digia Plc and /or its subsidiary(-ies).- * SPDX-FileCopyrightText: 2013 Boudewijn Rempt <[email protected]>- * SPDX-FileCopyrightText: 2013 Dmitry Kazakov <[email protected]>- * SPDX-FileCopyrightText: 2015 Michael Abrahams <[email protected]>- * SPDX-FileCopyrightText: 2015 The Qt Company Ltd.- *- * SPDX-License-Identifier: GPL-2.0-or-later- */---#include "kis_tablet_support_win_p.h"--#include "kis_tablet_support_win.h"--#include <kis_debug.h>-#include <QApplication>-#include <QGuiApplication>-#include <QDesktopWidget>--// #include <qpa/qwindowsysteminterface.h>-// #include <qpa/qplatformscreen.h>-// #include <private/qguiapplication_p.h>--#include <QPointer>-#include <QScreen>-#include <QWidget>-#include <QLibrary>-#include <cmath>-#define Q_PI M_PI--#include <input/kis_extended_modifiers_mapper.h>-#include <input/kis_tablet_debugger.h>--// For "inline tool switches"-#include <KoToolManager.h>-#include <KoInputDevice.h>-#include "kis_screen_size_choice_dialog.h"---// NOTE: we stub out qwindowcontext.cpp::347 to disable Qt's own tablet support.--// Note: The definition of the PACKET structure in pktdef.h depends on this define.-#define PACKETDATA (PK_X | PK_Y | PK_BUTTONS | PK_TIME | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE | PK_ORIENTATION | PK_CURSOR | PK_Z)-#include "pktdef.h"---QT_BEGIN_NAMESPACE--enum {- PacketMode = 0,- TabletPacketQSize = 128,- DeviceIdMask = 0xFF6, // device type mask && device color mask- CursorTypeBitMask = 0x0F06 // bitmask to find the specific cursor type (see Wacom FAQ)-};--/*- *- * Krita extensions begin here- *- *- */--QWindowsTabletSupport *QTAB = 0;-static QPointer<QWidget> targetWindow = 0; //< Window receiving last tablet event-static QPointer<QWidget> qt_tablet_target = 0; //< Widget receiving last tablet event-static bool dialogOpen = false; //< KisTabletSupportWin is not a Q_OBJECT and can't accept dialog signals--HWND createDummyWindow(const QString &className, const wchar_t *windowName, WNDPROC wndProc)-{- if (!wndProc)- wndProc = DefWindowProc;-- WNDCLASSEX wc;- wc.cbSize = sizeof(WNDCLASSEX);- wc.style = 0;- wc.lpfnWndProc = wndProc;- wc.cbClsExtra = 0;- wc.cbWndExtra = 0;- wc.hInstance = (HINSTANCE)GetModuleHandle(0);- wc.hCursor = 0;- wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);- wc.hIcon = 0;- wc.hIconSm = 0;- wc.lpszMenuName = 0;- wc.lpszClassName = (wchar_t*)className.utf16();- ATOM atom = RegisterClassEx(&wc);- if (!atom)- qErrnoWarning("Registering tablet fake window class failed.");-- return CreateWindowEx(0, (wchar_t*)className.utf16(),- windowName, WS_OVERLAPPED,- CW_USEDEFAULT, CW_USEDEFAULT,- CW_USEDEFAULT, CW_USEDEFAULT,- HWND_MESSAGE, NULL, (HINSTANCE)GetModuleHandle(0), NULL);-}---void printContext(const LOGCONTEXT &lc)-{- dbgTablet << "# Getting current context data:";- dbgTablet << ppVar(lc.lcName);- dbgTablet << ppVar(lc.lcDevice);- dbgTablet << ppVar(lc.lcInOrgX);- dbgTablet << ppVar(lc.lcInOrgY);- dbgTablet << ppVar(lc.lcInExtX);- dbgTablet << ppVar(lc.lcInExtY);- dbgTablet << ppVar(lc.lcOutOrgX);- dbgTablet << ppVar(lc.lcOutOrgY);- dbgTablet << ppVar(lc.lcOutExtX);- dbgTablet << ppVar(lc.lcOutExtY);- dbgTablet << ppVar(lc.lcSysOrgX);- dbgTablet << ppVar(lc.lcSysOrgY);- dbgTablet << ppVar(lc.lcSysExtX);- dbgTablet << ppVar(lc.lcSysExtY);-- dbgTablet << "Qt Desktop Geometry" << QApplication::desktop()->geometry();-}---static QRect mapToNative(const QRect &qRect, int m_factor)-{- return QRect(qRect.x() * m_factor, qRect.y() * m_factor, qRect.width() * m_factor, qRect.height() * m_factor);-}---static inline QEvent::Type mouseEventType(QEvent::Type t)-{- return (t == QEvent::TabletMove ? QEvent::MouseMove :- t == QEvent::TabletPress ? QEvent::MouseButtonPress :- t == QEvent::TabletRelease ? QEvent::MouseButtonRelease :- QEvent::None);-}--static inline bool isMouseEventType(QEvent::Type t)-{- return (t == QEvent::MouseMove ||- t == QEvent::MouseButtonPress ||- t == QEvent::MouseButtonRelease);-}--static QPoint mousePosition()-{- POINT p;- GetCursorPos(&p);- return QPoint(p.x, p.y);-}--QWindowsWinTab32DLL QWindowsTabletSupport::m_winTab32DLL;--bool KisTabletSupportWin::init()-{- if (!QWindowsTabletSupport::m_winTab32DLL.init()) {- qWarning() << "Failed to initialize Wintab";- return false;- }-- QTAB = QWindowsTabletSupport::create();-- // Refresh tablet context after tablet rotated, screen added, etc.- QObject::connect(qApp->primaryScreen(), &QScreen::geometryChanged,- [=](const QRect & geometry){- delete QTAB;- QTAB = QWindowsTabletSupport::create();- });- return true;-}---// Derived from qwidgetwindow.-//-// The work done by processTabletEvent from qguiapplicationprivate is divided-// between here and translateTabletPacketEvent.-static void handleTabletEvent(QWidget *windowWidget, const QPointF &local, const QPointF &global,- int device, int pointerType, Qt::MouseButton button, Qt::MouseButtons buttons,- qreal pressure,int xTilt, int yTilt, qreal tangentialPressure, qreal rotation,- int z, qint64 uniqueId, Qt::KeyboardModifiers modifiers, QEvent::Type type, LONG time)-{-- // Lock in target window- if (type == QEvent::TabletPress) {- targetWindow = windowWidget;- dbgInput << "Locking target window" << targetWindow;- } else if ((type == QEvent::TabletRelease || buttons == Qt::NoButton) && (targetWindow != 0)) {- dbgInput << "Releasing target window" << targetWindow;- targetWindow = 0;- }- if (!windowWidget) // Should never happen- return;--- // We do this instead of constructing the event e beforehand- const QPoint localPos = local.toPoint();- const QPoint globalPos = global.toPoint();-- if (type == QEvent::TabletPress) {- QWidget *widget = windowWidget->childAt(localPos);- if (!widget)- widget = windowWidget;- qt_tablet_target = widget;- }-- QWidget *finalDestination = qt_tablet_target;- if (!finalDestination) {- finalDestination = windowWidget->childAt(localPos);- }--- if ((type == QEvent::TabletRelease || buttons == Qt::NoButton) && (qt_tablet_target != 0)) {- dbgInput << "releasing tablet target" << qt_tablet_target;- qt_tablet_target = 0;- }-- if (finalDestination) {- // The event was specified relative to windowWidget, so we remap it- QPointF delta = global - globalPos;- QPointF mapped = finalDestination->mapFromGlobal(global.toPoint()) + delta;- QTabletEvent ev(type, mapped, global, device, pointerType, pressure, xTilt, yTilt,- tangentialPressure, rotation, z, modifiers, uniqueId, button, buttons);- ev.setTimestamp(time);- QGuiApplication::sendEvent(finalDestination, &ev);--- if (ev.isAccepted()) {- // dbgTablet << "Tablet event" << type << "accepted" << "by target widget" << finalDestination;- }- else {- // Turn off eventEater send a synthetic mouse event.- // dbgTablet << "Tablet event" << type << "rejected; sending mouse event to" << finalDestination;- qt_tablet_target = 0;-- // We shouldn't ever get a widget accepting a tablet event from this- // call, so we won't worry about any interactions with our own- // widget-locking code.- // QWindow *target = platformScreen->topLevelAt(globalPos);- // if (!target) return;- // QPointF windowLocal = global - QPointF(target->mapFromGlobal(QPoint())) + delta;- // QWindowSystemInterface::handleTabletEvent(target, ev.timestamp(), windowLocal,- // global, device, pointerType,- // buttons, pressure, xTilt, yTilt,- // tangentialPressure, rotation, z,- // uniqueId, modifiers);-- }- } else {- qt_tablet_target = 0;- targetWindow = 0;- }-}--/**- * This is a default implementation of a class for converting the- * WinTab value of the buttons pressed to the Qt buttons. This class- * may be substituted from the UI.- */-struct DefaultButtonsConverter-{- void convert(DWORD btnOld, DWORD btnNew,- Qt::MouseButton *button,- Qt::MouseButtons *buttons,- const QWindowsTabletDeviceData &tdd) {-- int pressedButtonValue = btnNew ^ btnOld;-- *button = buttonValueToEnum(pressedButtonValue, tdd);-- *buttons = Qt::NoButton;- for (int i = 0; i < 3; i++) {- int btn = 0x1 << i;-- if (btn & btnNew) {- Qt::MouseButton convertedButton =- buttonValueToEnum(btn, tdd);-- *buttons |= convertedButton;-- /**- * If a button that is present in hardware input is- * mapped to a Qt::NoButton, it means that it is going- * to be eaten by the driver, for example by its- * "Pan/Scroll" feature. Therefore we shouldn't handle- * any of the events associated to it. So just return- * Qt::NoButton here.- */- if (convertedButton == Qt::NoButton) {-- /**- * Sometimes the driver-handled shortcuts are just- * keyboard modifiers, so ideally we should handle- * them as well. The problem is that we cannot- * know if the shortcut was a pan/zoom action or a- * shortcut. So here we use a "hackish" approach.- * We just check if any modifier has been pressed- * and, if so, pass the button to Krita. Of- * course, if the driver uses some really complex- * shortcuts like "Shift + stylus btn" to generate- * some recorded shortcut, it will not work. But I- * guess it will be ok for the most of the- * usecases.- *- * WARNING: this hack will *not* work if you bind- * any non-modifier key to the stylus- * button, e.g. Space.- */-- const Qt::KeyboardModifiers keyboardModifiers = QApplication::queryKeyboardModifiers();-- if (KisTabletDebugger::instance()->shouldEatDriverShortcuts() ||- keyboardModifiers == Qt::NoModifier) {-- *button = Qt::NoButton;- *buttons = Qt::NoButton;- break;- }- }- }- }- }--private:- Qt::MouseButton buttonValueToEnum(DWORD button,- const QWindowsTabletDeviceData &tdd) {- const int leftButtonValue = 0x1;- const int middleButtonValue = 0x2;- const int rightButtonValue = 0x4;- const int doubleClickButtonValue = 0x7;-- button = tdd.buttonsMap.value(button);-- return button == leftButtonValue ? Qt::LeftButton :- button == rightButtonValue ? Qt::RightButton :- button == doubleClickButtonValue ? Qt::MiddleButton :- button == middleButtonValue ? Qt::MiddleButton :- button ? Qt::LeftButton /* fallback item */ :- Qt::NoButton;- }-};---static DefaultButtonsConverter *globalButtonsConverter =- new DefaultButtonsConverter();--/*- *- * Krita extensions end here- *- *- */--// This is the WndProc for a single additional hidden window used to collect tablet events.-extern "C" LRESULT QT_WIN_CALLBACK qWindowsTabletSupportWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)-{- switch (message) {- case WT_PROXIMITY:- if (QTAB->translateTabletProximityEvent(wParam, lParam))- return 0;- break;- case WT_PACKET:- if (QTAB->translateTabletPacketEvent())- return 0;- break;- }- return DefWindowProc(hwnd, message, wParam, lParam);-}---// Scale tablet coordinates to screen coordinates.--static inline int sign(int x)-{- return x >= 0 ? 1 : -1;-}--inline QPointF QWindowsTabletDeviceData::scaleCoordinates(int coordX, int coordY, const QRect &targetArea) const-{- const int targetX = targetArea.x();- const int targetY = targetArea.y();- const int targetWidth = targetArea.width();- const int targetHeight = targetArea.height();-- const qreal x = sign(targetWidth) == sign(maxX) ?- ((coordX - minX) * qAbs(targetWidth) / qAbs(qreal(maxX - minX))) + targetX :- ((qAbs(maxX) - (coordX - minX)) * qAbs(targetWidth) / qAbs(qreal(maxX - minX))) + targetX;-- const qreal y = sign(targetHeight) == sign(maxY) ?- ((coordY - minY) * qAbs(targetHeight) / qAbs(qreal(maxY - minY))) + targetY :- ((qAbs(maxY) - (coordY - minY)) * qAbs(targetHeight) / qAbs(qreal(maxY - minY))) + targetY;-- return QPointF(x, y);-}---/*!- \class QWindowsWinTab32DLL- \brief Functions from wintabl32.dll shipped with WACOM tablets used by QWindowsTabletSupport.-- \internal- \ingroup qt-lighthouse-win-*/-bool QWindowsWinTab32DLL::init()-{- if (wTInfo)- return true;- QLibrary library(QStringLiteral("wintab32"));- if (!library.load()) {- qWarning() << QString("Could not load wintab32 dll: %1").arg(library.errorString());- return false;- }- wTOpen = (PtrWTOpen) library.resolve("WTOpenW");- wTClose = (PtrWTClose) library.resolve("WTClose");- wTInfo = (PtrWTInfo) library.resolve("WTInfoW");- wTEnable = (PtrWTEnable) library.resolve("WTEnable");- wTOverlap = (PtrWTOverlap) library.resolve("WTOverlap");- wTPacketsGet = (PtrWTPacketsGet) library.resolve("WTPacketsGet");- wTGet = (PtrWTGet) library.resolve("WTGetW");- wTQueueSizeGet = (PtrWTQueueSizeGet) library.resolve("WTQueueSizeGet");- wTQueueSizeSet = (PtrWTQueueSizeSet) library.resolve("WTQueueSizeSet");-- if (wTOpen && wTClose && wTInfo && wTEnable && wTOverlap && wTPacketsGet && wTQueueSizeGet && wTQueueSizeSet) {- return true;- }- qWarning() << "Could not resolve the following symbols:\n"- << "\t wTOpen" << wTOpen << "\n"- << "\t wtClose" << wTClose << "\n"- << "\t wtInfo" << wTInfo << "\n"- << "\t wTEnable" << wTEnable << "\n"- << "\t wTOverlap" << wTOverlap << "\n"- << "\t wTPacketsGet" << wTPacketsGet << "\n"- << "\t wTQueueSizeGet" << wTQueueSizeGet << "\n"- << "\t wTQueueSizeSet" << wTQueueSizeSet << "\n";- return false;-}----/*!- \class QWindowsTabletSupport- \brief Tablet support for Windows.-- Support for WACOM tablets.-- \sa http://www.wacomeng.com/windows/docs/Wintab_v140.htm-- \internal- \since 5.2- \ingroup qt-lighthouse-win-*/--QWindowsTabletSupport::QWindowsTabletSupport(HWND window, HCTX context)- : m_window(window)- , m_context(context)- , m_absoluteRange(20)- , m_tiltSupport(false)- , m_currentDevice(-1)-{- AXIS orientation[3];- // Some tablets don't support tilt, check if it is possible,- if (QWindowsTabletSupport::m_winTab32DLL.wTInfo(WTI_DEVICES, DVC_ORIENTATION, &orientation))- m_tiltSupport = orientation[0].axResolution && orientation[1].axResolution;-}--QWindowsTabletSupport::~QWindowsTabletSupport()-{- QWindowsTabletSupport::m_winTab32DLL.wTClose(m_context);- DestroyWindow(m_window);-}--QWindowsTabletSupport *QWindowsTabletSupport::create()-{- const HWND window = createDummyWindow(QStringLiteral("TabletDummyWindow"),- L"TabletDummyWindow",- qWindowsTabletSupportWndProc);-- LOGCONTEXT lcMine;- // build our context from the default context- QWindowsTabletSupport::m_winTab32DLL.wTInfo(WTI_DEFSYSCTX, 0, &lcMine);- // Go for the raw coordinates, the tablet event will return good stuff. The- // defaults for lcOut rectangle are the desktop dimensions in pixels, which- // means Wintab will do lossy rounding. Instead we specify this trivial- // scaling for the output context, then do the scaling ourselves later to- // obtain higher resolution coordinates.- lcMine.lcOptions |= CXO_MESSAGES | CXO_CSRMESSAGES;- lcMine.lcPktData = lcMine.lcMoveMask = PACKETDATA;- lcMine.lcPktMode = PacketMode;- lcMine.lcOutOrgX = 0;- lcMine.lcOutExtX = lcMine.lcInExtX;- lcMine.lcOutOrgY = 0;- lcMine.lcOutExtY = -lcMine.lcInExtY;- const HCTX context = QWindowsTabletSupport::m_winTab32DLL.wTOpen(window, &lcMine, true);- if (!context) {- dbgTablet << __FUNCTION__ << "Unable to open tablet.";- DestroyWindow(window);- return 0;- }- // Set the size of the Packet Queue to the correct size- const int currentQueueSize = QWindowsTabletSupport::m_winTab32DLL.wTQueueSizeGet(context);- if (currentQueueSize != TabletPacketQSize) {- if (!QWindowsTabletSupport::m_winTab32DLL.wTQueueSizeSet(context, TabletPacketQSize)) {- if (!QWindowsTabletSupport::m_winTab32DLL.wTQueueSizeSet(context, currentQueueSize)) {- qWarning() << "Unable to set queue size on tablet. The tablet will not work.";- QWindowsTabletSupport::m_winTab32DLL.wTClose(context);- DestroyWindow(window);- return 0;- } // cannot restore old size- } // cannot set- } // mismatch- dbgTablet << "Opened tablet context " << context << " on window "- << window << "changed packet queue size " << currentQueueSize- << "->" << TabletPacketQSize;- return new QWindowsTabletSupport(window, context);-}---unsigned QWindowsTabletSupport::options() const-{- UINT result = 0;- m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_CTXOPTIONS, &result);- return result;-}---QString QWindowsTabletSupport::description() const-{- const unsigned size = m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_WINTABID, 0);- if (!size)- return QString();- QVarLengthArray<TCHAR> winTabId(size + 1);- m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_WINTABID, winTabId.data());- WORD implementationVersion = 0;- m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_IMPLVERSION, &implementationVersion);- WORD specificationVersion = 0;- m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_SPECVERSION, &specificationVersion);- const unsigned opts = options();- QString result = QString::fromLatin1("%1 specification: v%2.%3 implementation: v%4.%5 options: 0x%6")- .arg(QString::fromWCharArray(winTabId.data()))- .arg(specificationVersion >> 8).arg(specificationVersion & 0xFF)- .arg(implementationVersion >> 8).arg(implementationVersion & 0xFF)- .arg(opts, 0, 16);- if (opts & CXO_MESSAGES)- result += QStringLiteral(" CXO_MESSAGES");- if (opts & CXO_CSRMESSAGES)- result += QStringLiteral(" CXO_CSRMESSAGES");- if (m_tiltSupport)- result += QStringLiteral(" tilt");- return result;-}--void QWindowsTabletSupport::notifyActivate()-{- // Cooperate with other tablet applications, but when we get focus, I want to use the tablet.- const bool result = QWindowsTabletSupport::m_winTab32DLL.wTEnable(m_context, true)- && QWindowsTabletSupport::m_winTab32DLL.wTOverlap(m_context, true);- dbgTablet << __FUNCTION__ << result;-}--static inline int indexOfDevice(const QVector<QWindowsTabletDeviceData> &devices, qint64 uniqueId)-{- for (int i = 0; i < devices.size(); ++i)- if (devices.at(i).uniqueId == uniqueId)- return i;- return -1;-}--static inline QTabletEvent::TabletDevice deviceType(const UINT cursorType)-{- if (((cursorType & 0x0006) == 0x0002) && ((cursorType & CursorTypeBitMask) != 0x0902))- return QTabletEvent::Stylus;- if (cursorType == 0x4020) // Surface Pro 2 tablet device- return QTabletEvent::Stylus;- switch (cursorType & CursorTypeBitMask) {- case 0x0802:- return QTabletEvent::Stylus;- case 0x0902:- return QTabletEvent::Airbrush;- case 0x0004:- return QTabletEvent::FourDMouse;- case 0x0006:- return QTabletEvent::Puck;- case 0x0804:- return QTabletEvent::RotationStylus;- default:- break;- }- return QTabletEvent::NoDevice;-};--static inline QTabletEvent::PointerType pointerType(unsigned pkCursor)-{- switch (pkCursor % 3) { // %3 for dual track- case 0:- return QTabletEvent::Cursor;- case 1:- return QTabletEvent::Pen;- case 2:- return QTabletEvent::Eraser;- default:- break;- }- return QTabletEvent::UnknownPointer;-}--QDebug operator<<(QDebug d, const QWindowsTabletDeviceData &t)-{- d << "TabletDevice id:" << t.uniqueId << " pressure: " << t.minPressure- << ".." << t.maxPressure << " tan pressure: " << t.minTanPressure << ".."- << t.maxTanPressure << " area:" << t.minX << t.minY << t.minZ- << ".." << t.maxX << t.maxY << t.maxZ << " device " << t.currentDevice- << " pointer " << t.currentPointerType;- return d;-}--QWindowsTabletDeviceData QWindowsTabletSupport::tabletInit(const quint64 uniqueId, const UINT cursorType) const-{-- QWindowsTabletDeviceData result;- result.uniqueId = uniqueId;- /* browse WinTab's many info items to discover pressure handling. */- AXIS axis;- LOGCONTEXT lc;- /* get the current context for its device variable. */- QWindowsTabletSupport::m_winTab32DLL.wTGet(m_context, &lc);-- if (KisTabletDebugger::instance()->initializationDebugEnabled()) {- printContext(lc);- }-- /* get the size of the pressure axis. */- QWindowsTabletSupport::m_winTab32DLL.wTInfo(WTI_DEVICES + lc.lcDevice, DVC_NPRESSURE, &axis);- result.minPressure = int(axis.axMin);- result.maxPressure = int(axis.axMax);-- QWindowsTabletSupport::m_winTab32DLL.wTInfo(WTI_DEVICES + lc.lcDevice, DVC_TPRESSURE, &axis);- result.minTanPressure = int(axis.axMin);- result.maxTanPressure = int(axis.axMax);-- result.minX = int(lc.lcOutOrgX);- result.maxX = int(lc.lcOutExtX) + int(lc.lcOutOrgX);- result.minY = int(lc.lcOutOrgY);- result.maxY = -int(lc.lcOutExtY) + int(lc.lcOutOrgY);- // These are set to 0 when we opened the tablet context in QWindowsTabletSupport::create- KIS_SAFE_ASSERT_RECOVER_NOOP(lc.lcOutOrgX == 0);- KIS_SAFE_ASSERT_RECOVER_NOOP(lc.lcOutOrgY == 0);-- result.maxZ = int(lc.lcOutExtZ) - int(lc.lcOutOrgZ);- result.currentDevice = deviceType(cursorType);-- // Define a rectangle representing the whole screen as seen by Wintab.- QRect qtDesktopRect = QApplication::desktop()->geometry();- QRect wintabDesktopRect(lc.lcSysOrgX, lc.lcSysOrgY,- lc.lcSysExtX, lc.lcSysExtY);- qDebug() << ppVar(qtDesktopRect);- qDebug() << ppVar(wintabDesktopRect);-- // Show screen choice dialog- if (!dialogOpen) {- KisScreenSizeChoiceDialog dlg(0,- wintabDesktopRect,- qtDesktopRect);-- KisExtendedModifiersMapper mapper;- KisExtendedModifiersMapper::ExtendedModifiers modifiers =- mapper.queryExtendedModifiers();-- if (modifiers.contains(Qt::Key_Shift) ||- (!dlg.canUseDefaultSettings() &&- qtDesktopRect != wintabDesktopRect)) {-- dialogOpen = true;- dlg.exec();- }-- result.virtualDesktopArea = dlg.screenRect();- dialogOpen = false;- } else {- // This branch should've been explicitly prevented.- KIS_SAFE_ASSERT_RECOVER_NOOP(!dialogOpen);- warnTablet << "Trying to init a WinTab device while screen resolution dialog is active, this should not happen!";- warnTablet << "Tablet coordinates could be wrong as a result.";- result.virtualDesktopArea = qtDesktopRect;- }-- return result;-};-----bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, LPARAM lParam)-{- if (dialogOpen) {- // tabletInit(...) may show the screen resolution dialog and is blocking.- // During this period, don't process any tablet events at all.- dbgTablet << "WinTab screen resolution dialog is active, ignoring WinTab proximity event";- return false;- }- auto sendProximityEvent = [&](QEvent::Type type) {- QPointF emptyPos;- qreal zero = 0.0;- QTabletEvent e(type, emptyPos, emptyPos, 0, m_devices.at(m_currentDevice).currentPointerType,- zero, 0, 0, zero, zero, 0, Qt::NoModifier,- m_devices.at(m_currentDevice).uniqueId, Qt::NoButton, (Qt::MouseButtons)0);- qApp->sendEvent(qApp, &e);- };-- if (!LOWORD(lParam)) {- // dbgTablet << "leave proximity for device #" << m_currentDevice;- sendProximityEvent(QEvent::TabletLeaveProximity);- return true;- }- PACKET proximityBuffer[1]; // we are only interested in the first packet in this case- const int totalPacks = QWindowsTabletSupport::m_winTab32DLL.wTPacketsGet(m_context, 1, proximityBuffer);- if (!totalPacks)- return false;- UINT pkCursor = proximityBuffer[0].pkCursor;- // initializing and updating the cursor should be done in response to- // WT_CSRCHANGE. We do it in WT_PROXIMITY because some wintab never send- // the event WT_CSRCHANGE even if asked with CXO_CSRMESSAGES- tabletUpdateCursor(pkCursor);- // dbgTablet << "enter proximity for device #" << m_currentDevice << m_devices.at(m_currentDevice);-- sendProximityEvent(QEvent::TabletEnterProximity);- return true;-}----bool QWindowsTabletSupport::translateTabletPacketEvent()-{- static PACKET localPacketBuf[TabletPacketQSize]; // our own tablet packet queue.- const int packetCount = QWindowsTabletSupport::m_winTab32DLL.wTPacketsGet(m_context, TabletPacketQSize, &localPacketBuf);- if (!packetCount || m_currentDevice < 0 || dialogOpen)- return false;-- // In contrast to Qt, these will not be "const" during our loop.- // This is because the Surface Pro 3 may cause us to switch devices.- QWindowsTabletDeviceData tabletData = m_devices.at(m_currentDevice);- int currentDevice = tabletData.currentDevice;- int currentPointerType = tabletData.currentPointerType;-- // static Qt::MouseButtons buttons = Qt::NoButton, btnOld, btnChange;-- static DWORD btnNew, btnOld, btnChange;-- // The tablet can be used in 2 different modes, depending on its settings:- // 1) Absolute (pen) mode:- // The coordinates are scaled to the virtual desktop (by default). The user- // can also choose to scale to the monitor or a region of the screen.- // When entering proximity, the tablet driver snaps the mouse pointer to the- // tablet position scaled to that area and keeps it in sync.- // 2) Relative (mouse) mode:- // The pen follows the mouse. The constant 'absoluteRange' specifies the- // manhattanLength difference for detecting if a tablet input device is in this mode,- // in which case we snap the position to the mouse position.- // It seems there is no way to find out the mode programmatically, the LOGCONTEXT orgX/Y/Ext- // area is always the virtual desktop.- static qreal dpr = 1.0;- auto activeWindow = qApp->activeWindow();- if (activeWindow) {- dpr = activeWindow->devicePixelRatio();- }---- const Qt::KeyboardModifiers keyboardModifiers = QApplication::queryKeyboardModifiers();-- for (int i = 0; i < packetCount; ++i) {- const PACKET &packet = localPacketBuf[i];-- btnOld = btnNew;- btnNew = localPacketBuf[i].pkButtons;- btnChange = btnOld ^ btnNew;-- bool buttonPressed = btnChange && btnNew > btnOld;- bool buttonReleased = btnChange && btnNew < btnOld;- bool anyButtonsStillPressed = btnNew;- Qt::MouseButton button = Qt::NoButton;- Qt::MouseButtons buttons;-- globalButtonsConverter->convert(btnOld, btnNew, &button, &buttons, tabletData);-- QEvent::Type type = QEvent::TabletMove;- if (buttonPressed && button != Qt::NoButton) {- type = QEvent::TabletPress;- } else if (buttonReleased && button != Qt::NoButton) {- type = QEvent::TabletRelease;- }-- const int z = currentDevice == QTabletEvent::FourDMouse ? int(packet.pkZ) : 0;-- // NOTE: we shouldn't postpone the tablet events like Qt does, because we- // don't support mouse mode (which was the reason for introducing this- // postponing). See bug 363284.- QPointF globalPosF =- tabletData.scaleCoordinates(packet.pkX, packet.pkY,- tabletData.virtualDesktopArea);- globalPosF /= dpr; // Convert from "native" to "device independent pixels."-- QPoint globalPos = globalPosF.toPoint();-- // Find top-level window- QWidget *w = targetWindow; // If we had a target already, use it.- if (!w) {- w = qApp->activePopupWidget();- if (!w) w = qApp->activeModalWidget();- if (!w) w = qApp->topLevelAt(globalPos);- if (!w) continue;- w = w->window();- }--- const QPoint localPos = w->mapFromGlobal(globalPos);- const QPointF delta = globalPosF - globalPos;- const QPointF localPosF = globalPosF + QPointF(localPos - globalPos) + delta;-- const qreal pressureNew = packet.pkButtons && (currentPointerType == QTabletEvent::Pen || currentPointerType == QTabletEvent::Eraser) ?- m_devices.at(m_currentDevice).scalePressure(packet.pkNormalPressure) :- qreal(0);- const qreal tangentialPressure = currentDevice == QTabletEvent::Airbrush ?- m_devices.at(m_currentDevice).scaleTangentialPressure(packet.pkTangentPressure) :- qreal(0);-- int tiltX = 0;- int tiltY = 0;- qreal rotation = 0;- if (m_tiltSupport) {- // Convert from azimuth and altitude to x tilt and y tilt. What- // follows is the optimized version. Here are the equations used:- // X = sin(azimuth) * cos(altitude)- // Y = cos(azimuth) * cos(altitude)- // Z = sin(altitude)- // X Tilt = arctan(X / Z)- // Y Tilt = arctan(Y / Z)- const double radAzim = (packet.pkOrientation.orAzimuth / 10.0) * (M_PI / 180);- const double tanAlt = std::tan((std::abs(packet.pkOrientation.orAltitude / 10.0)) * (M_PI / 180));-- const double degX = std::atan(std::sin(radAzim) / tanAlt);- const double degY = std::atan(std::cos(radAzim) / tanAlt);- tiltX = int(degX * (180 / M_PI));- tiltY = int(-degY * (180 / M_PI));- rotation = 360.0 - (packet.pkOrientation.orTwist / 10.0);- if (rotation > 180.0)- rotation -= 360.0;- }-- // This is adds *a lot* of noise to the output log- if (false) {- dbgTablet- << "Packet #" << (i+1) << '/' << packetCount << "button:" << packet.pkButtons- << globalPosF << z << "to:" << w << localPos << "(packet" << packet.pkX- << packet.pkY << ") dev:" << currentDevice << "pointer:"- << currentPointerType << "P:" << pressureNew << "tilt:" << tiltX << ','- << tiltY << "tanP:" << tangentialPressure << "rotation:" << rotation;- }-- // Reusable helper function. Better than compiler macros!- auto sendTabletEvent = [&](QTabletEvent::Type t){- handleTabletEvent(w, localPosF, globalPosF, currentDevice, currentPointerType,- button, buttons, pressureNew, tiltX, tiltY, tangentialPressure, rotation, z,- m_devices.at(m_currentDevice).uniqueId, keyboardModifiers, t, packet.pkTime);- };-- /**- * Workaround to deal with "inline" tool switches.- * These are caused by the eraser trigger button on the Surface Pro 3.- * We shoot out a tabletUpdateCursor request and a switchInputDevice request.- */- if (isSurfacePro3 && (packet.pkCursor != currentPkCursor)) {-- dbgTablet << "Got an inline tool switch.";- // Send tablet release event.- sendTabletEvent(QTabletEvent::TabletRelease);-- // Read the new cursor info.- UINT pkCursor = packet.pkCursor;- tabletUpdateCursor(pkCursor);-- // Update the local loop variables.- tabletData = m_devices.at(m_currentDevice);- currentDevice = deviceType(tabletData.currentDevice);- currentPointerType = pointerType(pkCursor);-- sendTabletEvent(QTabletEvent::TabletPress);- }-- sendTabletEvent(type);-- } // Loop over packets- return true;-}------void QWindowsTabletSupport::tabletUpdateCursor(const int pkCursor)-{- UINT physicalCursorId;- QWindowsTabletSupport::m_winTab32DLL.wTInfo(WTI_CURSORS + pkCursor, CSR_PHYSID, &physicalCursorId);- UINT cursorType;- QWindowsTabletSupport::m_winTab32DLL.wTInfo(WTI_CURSORS + pkCursor, CSR_TYPE, &cursorType);- const qint64 uniqueId = (qint64(cursorType & DeviceIdMask) << 32L) | qint64(physicalCursorId);-- m_currentDevice = indexOfDevice(m_devices, uniqueId);- if (m_currentDevice < 0) {- m_currentDevice = m_devices.size();- m_devices.push_back(tabletInit(uniqueId, cursorType));-- // Note: ideally we might check this button map for changes every- // update. However there seems to be an issue with Wintab altering the- // button map when the user right-clicks in Krita while another- // application has focus. This forces Krita to load button settings only- // once, when the tablet is first detected.- //- // See https://bugs.kde.org/show_bug.cgi?id=359561- BYTE logicalButtons[32];- memset(logicalButtons, 0, 32);- m_winTab32DLL.wTInfo(WTI_CURSORS + pkCursor, CSR_SYSBTNMAP, &logicalButtons);- m_devices[m_currentDevice].buttonsMap[0x1] = logicalButtons[0];- m_devices[m_currentDevice].buttonsMap[0x2] = logicalButtons[1];- m_devices[m_currentDevice].buttonsMap[0x4] = logicalButtons[2];- }- m_devices[m_currentDevice].currentPointerType = pointerType(pkCursor);- currentPkCursor = pkCursor;-- // Check tablet name to enable Surface Pro 3 workaround.-#ifdef UNICODE- if (!isSurfacePro3) {- /**- * Some really "nice" tablet drivers don't know that they are- * supposed to return their name length when the buffer is- * null and they try to write into it effectively causing a- * suicide. So we cannot rely on it :(- *- * We workaround it by just allocating a big array and hoping- * for the best.- *- * Failing tablets:- * - Adesso Cybertablet M14- * - Peritab-302- * - Trust Tablet TB7300- * - VisTablet Realm Pro- * - Aiptek 14000u (latest driver: v5.03, 2013-10-21)- * - Genius G-Pen F350- * - Genius G-Pen 560 (supported on win7 only)- */-- // we cannot use the correct api :(- // UINT nameLength = QWindowsTabletSupport::m_winTab32DLL.wTInfo(WTI_DEVICES, DVC_NAME, 0);-- // 1024 chars should be enough for everyone! (c)- UINT nameLength = 1024;-- TCHAR* dvcName = new TCHAR[nameLength + 1];- memset(dvcName, 0, sizeof(TCHAR) * nameLength);- UINT writtenBytes = QWindowsTabletSupport::m_winTab32DLL.wTInfo(WTI_DEVICES, DVC_NAME, dvcName);-- if (writtenBytes > sizeof(TCHAR) * nameLength) {- qWarning() << "WINTAB WARNING: tablet name is too long!" << writtenBytes;-- // avoid crash when trying to read it- dvcName[nameLength - 1] = (TCHAR)0;- }-- QString qDvcName = QString::fromWCharArray((const wchar_t*)dvcName);- dbgInput << "DVC_NAME =" << qDvcName;- // Name changed between older and newer Surface Pro 3 drivers- if (qDvcName == QString::fromLatin1("N-trig DuoSense device") ||- qDvcName == QString::fromLatin1("Microsoft device")) {- dbgInput << "This looks like a Surface Pro 3. Enabling eraser workaround.";- isSurfacePro3 = true;- }- delete[] dvcName;- }-#endif-}---QT_END_NAMESPACEdiff --git a/libs/ui/input/wintab/kis_tablet_support_win.h b/libs/ui/input/wintab/kis_tablet_support_win.hdeleted file mode 100644index 12dbe48687..0000000000--- a/libs/ui/input/wintab/kis_tablet_support_win.h+++ /dev/null@@ -1,22 +0,0 @@-/*- * SPDX-FileCopyrightText: 2013 Digia Plc and /or its subsidiary(-ies).- * SPDX-FileCopyrightText: 2013 Boudewijn Rempt <[email protected]>- * SPDX-FileCopyrightText: 2013 Dmitry Kazakov <[email protected]>- *- * SPDX-License-Identifier: GPL-2.0-or-later- */--#ifndef KIS_TABLET_SUPPORT_WIN_H-#define KIS_TABLET_SUPPORT_WIN_H--#include <kritaui_export.h>--class KRITAUI_EXPORT KisTabletSupportWin-{-public:- static bool init();--};---#endif // KIS_TABLET_SUPPORT_WIN_Hdiff --git a/libs/ui/input/wintab/kis_tablet_support_win8.cpp b/libs/ui/input/wintab/kis_tablet_support_win8.cppdeleted file mode 100644index 233d3827aa..0000000000--- a/libs/ui/input/wintab/kis_tablet_support_win8.cpp+++ /dev/null@@ -1,1092 +0,0 @@-/*- * SPDX-FileCopyrightText: 2017 Alvin Wong <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#include "kis_tablet_support_win8.h"--#include <QApplication>-#include <QDebug>-#include <QHash>-#include <QLibrary>-#include <QPointer>-#include <QTabletEvent>-#include <QVector>-#include <QWidget>-#include <QWindow>--#include <utility>--#include <kis_debug.h>--#include <windows.h>-#include <tpcshrd.h>--#ifndef Q_OS_WIN-# error This file must not be compiled for non-Windows systems-#endif--namespace-{--class Win8PointerInputApi-{-#define WIN8_POINTER_INPUT_API_LIST(FUNC) \- /* Pointer Input Functions */ \- FUNC(GetPointerPenInfo) \- FUNC(GetPointerPenInfoHistory) \- FUNC(GetPointerType) \- /* Pointer Device Functions */ \- FUNC(GetPointerDevices) \- /*FUNC(GetPointerDeviceProperties)*/ \- FUNC(GetPointerDevice) \- FUNC(GetPointerDeviceRects) \- /*FUNC(RegisterPointerDeviceNotifications)*/ \- /* end */-- bool m_loaded;--public:--#define DEFINE_FP_FROM_WINAPI(func) \- public: using p ## func ## _t = std::add_pointer<decltype(func)>::type; \- private: p ## func ## _t m_p ## func = nullptr; \- public: const p ## func ## _t &func = m_p ## func; // const fp ref to member-- WIN8_POINTER_INPUT_API_LIST(DEFINE_FP_FROM_WINAPI)--#undef DEFINE_FP_FROM_WINAPI--public:- Win8PointerInputApi()- : m_loaded(false)- {- }-- bool init() {- if (m_loaded) {- return true;- }-- QLibrary user32Lib("user32");- if (!user32Lib.load()) {- qWarning() << "Failed to load user32.dll! This really should not happen.";- return false;- }--#define LOAD_AND_CHECK_FP_FROM_WINAPI(func) \- m_p ## func = reinterpret_cast<p ## func ## _t>(user32Lib.resolve(#func)); \- if (!m_p ## func) { \- dbgTablet << "Failed to load function " #func " from user32.dll"; \- return false; \- }-- WIN8_POINTER_INPUT_API_LIST(LOAD_AND_CHECK_FP_FROM_WINAPI)--#undef LOAD_AND_CHECK_FP_FROM_WINAPI-- dbgTablet << "Loaded Windows 8 Pointer Input API functions";- m_loaded = true;- return true;- }-- bool isLoaded() {- return m_loaded;- }--#undef WIN8_POINTER_INPUT_API_LIST-}; // class Win8PointerInputApi--Win8PointerInputApi api;--class PointerFlagsWrapper-{- const POINTER_FLAGS f;--public:- PointerFlagsWrapper(POINTER_FLAGS flags)- : f(flags)- {}-- static PointerFlagsWrapper fromPointerInfo(const POINTER_INFO &pointerInfo) {- return PointerFlagsWrapper(pointerInfo.pointerFlags);- }-- static PointerFlagsWrapper fromPenInfo(const POINTER_PEN_INFO &penInfo) {- return fromPointerInfo(penInfo.pointerInfo);- }-- bool isNew() const {- return f & POINTER_FLAG_NEW;- }-- bool isInRange() const {- return f & POINTER_FLAG_INRANGE;- }-- bool isInContact() const {- return f & POINTER_FLAG_INCONTACT;- }-- bool isFirstButtonDown() const {- return f & POINTER_FLAG_FIRSTBUTTON;- }-- bool isSecondButtonDown() const {- return f & POINTER_FLAG_SECONDBUTTON;- }-- bool isThirdButtonDown() const {- return f & POINTER_FLAG_THIRDBUTTON;- }-- bool isForthButtonDown() const {- return f & POINTER_FLAG_FOURTHBUTTON;- }-- bool isFifthButtonDown() const {- return f & POINTER_FLAG_FIFTHBUTTON;- }-- bool isPrimary() const {- return f & POINTER_FLAG_PRIMARY;- }-- bool isConfidence() const {- return f & POINTER_FLAG_CONFIDENCE;- }-- bool isCancelled() const {- return f & POINTER_FLAG_CANCELED;- }-- bool isDown() const {- return f & POINTER_FLAG_DOWN;- }-- bool isUpdate() const {- return f & POINTER_FLAG_UPDATE;- }-- bool isUp() const {- return f & POINTER_FLAG_UP;- }-- bool isWheel() const {- return f & POINTER_FLAG_WHEEL;- }-- bool isHWheel() const {- return f & POINTER_FLAG_HWHEEL;- }-- bool isCaptureChanged() const {- return f & POINTER_FLAG_CAPTURECHANGED;- }-- bool hasTransform() const {- // mingw-w64 headers is missing this flag- // return f & POINTER_FLAG_HASTRANSFORM;- return f & 0x00400000;- }-}; // class PointerFlagsWrapper--class PenFlagsWrapper-{- const PEN_FLAGS f;--public:- PenFlagsWrapper(PEN_FLAGS flags)- : f(flags)- {}-- static PenFlagsWrapper fromPenInfo(const POINTER_PEN_INFO &penInfo) {- return PenFlagsWrapper(penInfo.penFlags);- }-- bool isBarrelPressed() const {- return f & PEN_FLAG_BARREL;- }-- bool isInverted() const {- return f & PEN_FLAG_INVERTED;- }-- bool isEraserPressed() const {- return f & PEN_FLAG_ERASER;- }-}; // class PenFlagsWrapper--class PenMaskWrapper-{- const PEN_MASK f;--public:- PenMaskWrapper(PEN_MASK mask)- :f(mask)- {}-- static PenMaskWrapper fromPenInfo(const POINTER_PEN_INFO &penInfo) {- return PenMaskWrapper(penInfo.penMask);- }-- bool pressureValid() const {- return f & PEN_MASK_PRESSURE;- }-- bool rotationValid() const {- return f & PEN_MASK_ROTATION;- }-- bool tiltXValid() const {- return f & PEN_MASK_TILT_X;- }-- bool tiltYValid() const {- return f & PEN_MASK_TILT_Y;- }-}; // class PenMaskWrapper--struct PointerDeviceItem-{- // HANDLE handle;- // RECT pointerDeviceRect;- // RECT displayRect;- qreal himetricToPixelX;- qreal himetricToPixelY;- qreal pixelOffsetX;- qreal pixelOffsetY;- DISPLAYCONFIG_ROTATION deviceOrientation; // This is needed to fix tilt-};--QHash<HANDLE, PointerDeviceItem> penDevices;--struct PenPointerItem-{- // int pointerId;- // POINTER_PEN_INFO penInfo;- HWND hwnd;- HANDLE deviceHandle;- QPointer<QWidget> activeWidget; // Current widget receiving events- qreal oneOverDpr; // 1 / devicePixelRatio of activeWidget- bool widgetIsCaptured; // Current widget is capturing a pen down event- bool widgetIsIgnored; // Pen events should be ignored until pen up- bool widgetAcceptsPenEvent; // Whether the widget accepts pen events-- bool isCaptured() const {- return widgetIsCaptured;- }-};--QHash<int, PenPointerItem> penPointers;-// int primaryPenPointerId;--bool handlePointerMsg(const MSG &msg);--// extern "C" {-//-// LRESULT CALLBACK pointerDeviceNotificationsWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)-// {-// switch (uMsg) {-// case WM_POINTERDEVICECHANGE:-// dbgTablet << "I would want to handle this WM_POINTERDEVICECHANGE event, but ms just doesn't want me to use it";-// dbgTablet << " wParam:" << wParam;-// dbgTablet << " lParam:" << lParam;-// return 0;-// case WM_POINTERDEVICEINRANGE:-// dbgTablet << "I would want to handle this WM_POINTERDEVICEINRANGE event, but ms just doesn't want me to use it";-// dbgTablet << " wParam:" << wParam;-// dbgTablet << " lParam:" << lParam;-// return 0;-// case WM_POINTERDEVICEOUTOFRANGE:-// dbgTablet << "I would want to handle this WM_POINTERDEVICEOUTOFRANGE event, but ms just doesn't want me to use it";-// dbgTablet << " wParam:" << wParam;-// dbgTablet << " lParam:" << lParam;-// return 0;-// }-// return DefWindowProcW(hwnd, uMsg, wParam, lParam);-// }-//-// } // extern "C"--} // namespace--bool KisTabletSupportWin8::isAvailable()-{- // Just try loading the APIs- return api.init();-}--bool KisTabletSupportWin8::isPenDeviceAvailable()-{- if (!api.init()) {- return false;- }- UINT32 deviceCount = 0;- if (!api.GetPointerDevices(&deviceCount, nullptr)) {- dbgTablet << "GetPointerDevices failed";- return false;- }- if (deviceCount == 0) {- dbgTablet << "No pointer devices";- return false;- }- QVector<POINTER_DEVICE_INFO> devices(deviceCount);- if (!api.GetPointerDevices(&deviceCount, devices.data())) {- dbgTablet << "GetPointerDevices failed";- return false;- }- bool hasPenDevice = false;- Q_FOREACH (const POINTER_DEVICE_INFO &device, devices) {- dbgTablet << "Found pointer device" << static_cast<void *>(device.device)- << QString::fromWCharArray(device.productString)- << "type:" << device.pointerDeviceType;- if (device.pointerDeviceType == POINTER_DEVICE_TYPE_INTEGRATED_PEN ||- device.pointerDeviceType == POINTER_DEVICE_TYPE_EXTERNAL_PEN) {- hasPenDevice = true;- }- }- dbgTablet << "hasPenDevice:" << hasPenDevice;- return hasPenDevice;-}--bool KisTabletSupportWin8::init()-{- return api.init();-}--// void KisTabletSupportWin8::registerPointerDeviceNotifications()-// {-// const wchar_t *className = L"w8PointerMsgWindow";-// HINSTANCE hInst = static_cast<HINSTANCE>(GetModuleHandleW(nullptr));-// WNDCLASSEXW wc;-// wc.cbSize = sizeof(WNDCLASSEXW);-// wc.style = 0;-// wc.lpfnWndProc = pointerDeviceNotificationsWndProc;-// wc.cbClsExtra = 0;-// wc.cbWndExtra = 0;-// wc.hInstance = hInst;-// wc.hCursor = 0;-// wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);-// wc.hIcon = 0;-// wc.hIconSm = 0;-// wc.lpszMenuName = 0;-// wc.lpszClassName = className;-//-// if (RegisterClassEx(&wc)) {-// HWND hwnd = CreateWindowEx(0, className, nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr, hInst, nullptr);-// api.RegisterPointerDeviceNotifications(hwnd, TRUE);-// } else {-// dbgTablet << "Cannot register dummy window";-// }-// }--bool KisTabletSupportWin8::nativeEventFilter(const QByteArray &eventType, void *message, long *result)-{- if (!result) {- // I don't know why this even happens, but it actually does- // And the same event is sent in again with result != nullptr- return false;- }-- // This is only installed on Windows so there is no reason to check eventType- MSG &msg = *static_cast<MSG *>(message);-- switch (msg.message) {- case WM_POINTERDOWN:- case WM_POINTERUP:- case WM_POINTERENTER:- case WM_POINTERLEAVE:- case WM_POINTERUPDATE:- case WM_POINTERCAPTURECHANGED:- {- bool handled = handlePointerMsg(msg);- if (handled) {- *result = 0;- return true;- }- break;- }- case WM_TABLET_QUERYSYSTEMGESTURESTATUS:- *result = 0;- return true;- }-- Q_UNUSED(eventType);- return false;-}--namespace {--QDebug operator<<(QDebug debug, const POINT &pt)-{- QDebugStateSaver saver(debug);- debug.nospace() << '(' << pt.x << ", " << pt.y << ')';-- return debug;-}--QDebug operator<<(QDebug debug, const RECT &rect)-{- QDebugStateSaver saver(debug);- debug.nospace() << '(' << rect.left << ", " << rect.top << ", " << rect.right << ", " << rect.bottom << ')';-- return debug;-}--bool registerOrUpdateDevice(HANDLE deviceHandle, const RECT &pointerDeviceRect, const RECT &displayRect, const DISPLAYCONFIG_ROTATION deviceOrientation)-{- bool isPreviouslyRegistered = penDevices.contains(deviceHandle);- PointerDeviceItem &deviceItem = penDevices[deviceHandle];- PointerDeviceItem oldDeviceItem = deviceItem;- // deviceItem.handle = deviceHandle;- deviceItem.himetricToPixelX =- static_cast<qreal>(displayRect.right - displayRect.left)- / (pointerDeviceRect.right - pointerDeviceRect.left);- deviceItem.himetricToPixelY =- static_cast<qreal>(displayRect.bottom - displayRect.top)- / (pointerDeviceRect.bottom - pointerDeviceRect.top);- deviceItem.pixelOffsetX = static_cast<qreal>(displayRect.left)- - deviceItem.himetricToPixelX * pointerDeviceRect.left;- deviceItem.pixelOffsetY = static_cast<qreal>(displayRect.top)- - deviceItem.himetricToPixelY * pointerDeviceRect.top;- deviceItem.deviceOrientation = deviceOrientation;- if (!isPreviouslyRegistered) {- dbgTablet << "Registered pen device" << deviceHandle- << "with displayRect" << displayRect- << "and deviceRect" << pointerDeviceRect- << "scale" << deviceItem.himetricToPixelX << deviceItem.himetricToPixelY- << "offset" << deviceItem.pixelOffsetX << deviceItem.pixelOffsetY- << "orientation" << deviceItem.deviceOrientation;- } else if (deviceItem.himetricToPixelX != oldDeviceItem.himetricToPixelX- || deviceItem.himetricToPixelY != oldDeviceItem.himetricToPixelY- || deviceItem.pixelOffsetX != oldDeviceItem.pixelOffsetX- || deviceItem.pixelOffsetY != oldDeviceItem.pixelOffsetY- || deviceItem.deviceOrientation != oldDeviceItem.deviceOrientation) {- dbgTablet << "Updated pen device" << deviceHandle- << "with displayRect" << displayRect- << "and deviceRect" << pointerDeviceRect- << "scale" << deviceItem.himetricToPixelX << deviceItem.himetricToPixelY- << "offset" << deviceItem.pixelOffsetX << deviceItem.pixelOffsetY- << "orientation" << deviceItem.deviceOrientation;- }- return true;-}--bool registerOrUpdateDevice(HANDLE deviceHandle)-{- RECT pointerDeviceRect, displayRect;- if (!api.GetPointerDeviceRects(deviceHandle, &pointerDeviceRect, &displayRect)) {- dbgTablet << "GetPointerDeviceRects failed";- return false;- }- POINTER_DEVICE_INFO pointerDeviceInfo;- if (!api.GetPointerDevice(deviceHandle, &pointerDeviceInfo)) {- dbgTablet << "GetPointerDevice failed";- return false;- }- return registerOrUpdateDevice(deviceHandle, pointerDeviceRect, displayRect,- static_cast<DISPLAYCONFIG_ROTATION>(pointerDeviceInfo.displayOrientation));-}--QTabletEvent makeProximityTabletEvent(const QEvent::Type eventType, const POINTER_PEN_INFO &penInfo)-{- PenFlagsWrapper penFlags = PenFlagsWrapper::fromPenInfo(penInfo);- QTabletEvent::PointerType pointerType = penFlags.isInverted() ? QTabletEvent::Eraser : QTabletEvent::Pen;- const QPointF emptyPoint;- return QTabletEvent(- eventType, // type- emptyPoint, // pos- emptyPoint, // globalPos- QTabletEvent::Stylus, // device- pointerType, // pointerType- 0, // pressure- 0, // xTilt- 0, // yTilt- 0, // tangentialPressure- 0, // rotation- 0, // z- Qt::NoModifier, // keyState- reinterpret_cast<qint64>(penInfo.pointerInfo.sourceDevice), // uniqueID- Qt::NoButton, // button- (Qt::MouseButtons)0 // buttons- );-}--// void rotateTiltAngles(int &tiltX, int &tiltY, const DISPLAYCONFIG_ROTATION orientation) {-// int newTiltX, newTiltY;-// switch (orientation) {-// case DISPLAYCONFIG_ROTATION_ROTATE90:-// newTiltX = -tiltY;-// newTiltY = tiltX;-// break;-// case DISPLAYCONFIG_ROTATION_ROTATE180:-// newTiltX = -tiltX;-// newTiltY = -tiltY;-// break;-// case DISPLAYCONFIG_ROTATION_ROTATE270:-// newTiltX = tiltY;-// newTiltY = -tiltX;-// break;-// case DISPLAYCONFIG_ROTATION_IDENTITY:-// default:-// newTiltX = tiltX;-// newTiltY = tiltY;-// break;-// }-// tiltX = newTiltX;-// tiltY = newTiltY;-// }--QTabletEvent makePositionalTabletEvent(const QWidget *targetWidget, const QEvent::Type eventType, const POINTER_PEN_INFO &penInfo, const PointerDeviceItem &deviceItem, const PenPointerItem &penPointerItem)-{- PenFlagsWrapper penFlags = PenFlagsWrapper::fromPenInfo(penInfo);- PointerFlagsWrapper pointerFlags = PointerFlagsWrapper::fromPenInfo(penInfo);- PenMaskWrapper penMask = PenMaskWrapper::fromPenInfo(penInfo);-- const QPointF globalPosF(- (deviceItem.himetricToPixelX * penInfo.pointerInfo.ptHimetricLocationRaw.x + deviceItem.pixelOffsetX) * penPointerItem.oneOverDpr,- (deviceItem.himetricToPixelY * penInfo.pointerInfo.ptHimetricLocationRaw.y + deviceItem.pixelOffsetY) * penPointerItem.oneOverDpr- );- const QPoint globalPos = globalPosF.toPoint();- const QPoint localPos = targetWidget->mapFromGlobal(globalPos);- const QPointF delta = globalPosF - globalPos;- const QPointF localPosF = localPos + delta;-- const QTabletEvent::PointerType pointerType = penFlags.isInverted() ? QTabletEvent::Eraser : QTabletEvent::Pen;-- Qt::MouseButton mouseButton;- if (eventType == QEvent::TabletPress) {- if (penInfo.pointerInfo.ButtonChangeType == POINTER_CHANGE_SECONDBUTTON_DOWN) {- mouseButton = Qt::RightButton;- } else {- KIS_SAFE_ASSERT_RECOVER(penInfo.pointerInfo.ButtonChangeType == POINTER_CHANGE_FIRSTBUTTON_DOWN) {- qWarning() << "WM_POINTER* sent unknown ButtonChangeType" << penInfo.pointerInfo.ButtonChangeType;- }- mouseButton = Qt::LeftButton;- }- } else if (eventType == QEvent::TabletRelease) {- if (penInfo.pointerInfo.ButtonChangeType == POINTER_CHANGE_SECONDBUTTON_UP) {- mouseButton = Qt::RightButton;- } else {- KIS_SAFE_ASSERT_RECOVER(penInfo.pointerInfo.ButtonChangeType == POINTER_CHANGE_FIRSTBUTTON_UP) {- qWarning() << "WM_POINTER* sent unknown ButtonChangeType" << penInfo.pointerInfo.ButtonChangeType;- }- mouseButton = Qt::LeftButton;- }- } else {- mouseButton = Qt::NoButton;- }-- Qt::MouseButtons mouseButtons;- if (pointerFlags.isFirstButtonDown()) {- mouseButtons |= Qt::LeftButton;- }- if (pointerFlags.isSecondButtonDown()) {- mouseButtons |= Qt::RightButton;- }-- int tiltX = 0, tiltY = 0;- if (penMask.tiltXValid()) {- tiltX = qBound(-60, penInfo.tiltX, 60);- }- if (penMask.tiltYValid()) {- tiltY = qBound(-60, penInfo.tiltY, 60);- }- // rotateTiltAngles(tiltX, tiltY, deviceItem.deviceOrientation);-- int rotation = 0;- if (penMask.rotationValid()) {- rotation = 360 - penInfo.rotation; // Flip direction and convert to signed int- if (rotation > 180) {- rotation -= 360;- }- }-- return QTabletEvent(- eventType, // type- localPosF, // pos- globalPosF, // globalPos- QTabletEvent::Stylus, // device- pointerType, // pointerType- penMask.pressureValid() ? static_cast<qreal>(penInfo.pressure) / 1024 : 0, // pressure- tiltX, // xTilt- tiltY, // yTilt- 0, // tangentialPressure- rotation, // rotation- 0, // z- QApplication::queryKeyboardModifiers(), // keyState- reinterpret_cast<qint64>(penInfo.pointerInfo.sourceDevice), // uniqueID- mouseButton, // button- mouseButtons // buttons- );-}--bool sendProximityTabletEvent(const QEvent::Type eventType, const POINTER_PEN_INFO &penInfo)-{- KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(- eventType == QEvent::TabletEnterProximity || eventType == QEvent::TabletLeaveProximity,- false- );- QTabletEvent ev = makeProximityTabletEvent(eventType, penInfo);- ev.setAccepted(false);- ev.setTimestamp(penInfo.pointerInfo.dwTime);- QCoreApplication::sendEvent(qApp, &ev);- return ev.isAccepted();-}--void synthesizeMouseEvent(const QTabletEvent &ev, const POINTER_PEN_INFO &penInfo)-{- // Update the cursor position- BOOL result = SetCursorPos(penInfo.pointerInfo.ptPixelLocationRaw.x, penInfo.pointerInfo.ptPixelLocationRaw.y);- if (!result) {- dbgInput << "SetCursorPos failed, err" << GetLastError();- return;- }- // Send mousebutton down/up events. Windows stores the button state.- DWORD inputDataFlags = 0;- switch (ev.type()) {- case QEvent::TabletPress:- switch (ev.button()) {- case Qt::LeftButton:- inputDataFlags = MOUSEEVENTF_LEFTDOWN;- break;- case Qt::RightButton:- inputDataFlags = MOUSEEVENTF_RIGHTDOWN;- break;- default:- return;- }- break;- case QEvent::TabletRelease:- switch (ev.button()) {- case Qt::LeftButton:- inputDataFlags = MOUSEEVENTF_LEFTUP;- break;- case Qt::RightButton:- inputDataFlags = MOUSEEVENTF_RIGHTUP;- break;- default:- return;- }- break;- case QEvent::TabletMove:- default:- return;- }- INPUT inputData = {};- inputData.type = INPUT_MOUSE;- inputData.mi.dwFlags = inputDataFlags;- inputData.mi.dwExtraInfo = 0xFF515700 | 0x01; // https://msdn.microsoft.com/en-us/library/windows/desktop/ms703320%28v=vs.85%29.aspx- UINT result2 = SendInput(1, &inputData, sizeof(inputData));- if (result2 != 1) {- dbgInput << "SendInput failed, err" << GetLastError();- return;- }-}--bool sendPositionalTabletEvent(QWidget *target, const QEvent::Type eventType, const POINTER_PEN_INFO &penInfo, const PointerDeviceItem &device, const PenPointerItem &penPointerItem, const bool shouldSynthesizeMouseEvent)-{- KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(- eventType == QEvent::TabletMove || eventType == QEvent::TabletPress || eventType == QEvent::TabletRelease,- false- );- QTabletEvent ev = makePositionalTabletEvent(target, eventType, penInfo, device, penPointerItem);- ev.setAccepted(false);- ev.setTimestamp(penInfo.pointerInfo.dwTime);- QCoreApplication::sendEvent(target, &ev);- if (!shouldSynthesizeMouseEvent) {- // For pen update with multiple updates, only the last update should- // be used to synthesize a mouse event.- return false;- }- // This is some specialized code to handle synthesizing of mouse events from- // the pen events. Issues being:- // 1. We must accept the pointer down/up and the intermediate update events- // to indicate that we want all the pen pointer events for painting,- // otherwise Windows may do weird stuff and skip passing pointer events.- // 2. Some Qt and Krita code uses QCursor::pos() which calls GetCursorPos to- // get the cursor position. This doesn't work nicely before ver 1709 and- // doesn't work at all on ver 1709 if the pen events are handled, so we- // need some way to nudge the cursor on the OS level.- // It appears that using the same way (as in synthesizeMouseEvent) to nudge- // the cursor does work fine for when painting on canvas (which handles- // the QTabletEvent), but not for other widgets because it introduces a lag- // with mouse move events on move start and immediately after mouse down.- // The resolution is to simulate mouse movement with our own code only for- // handled pen events, which is what the following code does.- if (ev.type() == QEvent::TabletMove && ev.buttons() == Qt::NoButton) {- // Let Windows synthesize mouse hover events- return false;- }- if (ev.type() == QEvent::TabletPress && !ev.isAccepted()) {- // On pen down event, if the widget doesn't handle the event, let- // Windows translate the event to touch, mouse or whatever- return false;- }- if (ev.type() != QEvent::TabletPress && !penPointerItem.widgetAcceptsPenEvent) {- // For other events, if the previous pen down event wasn't handled by- // the widget, continue to let Windows translate the event- return false;- }- // Otherwise, we synthesize our mouse events- synthesizeMouseEvent(ev, penInfo);- return true; // and tell Windows that we do want the pen events.-}--bool handlePenEnterMsg(const POINTER_PEN_INFO &penInfo)-{- PointerFlagsWrapper pointerFlags = PointerFlagsWrapper::fromPenInfo(penInfo);- if (!pointerFlags.isPrimary()) {- // Don't handle non-primary pointer messages for now- dbgTablet << "Pointer" << penInfo.pointerInfo.pointerId- << "of device" << penInfo.pointerInfo.sourceDevice- << "is not flagged PRIMARY";- return false;- }-- // Update the device scaling factors here- // It doesn't cost much to recalculate anyway- // This ensures that the screen resolution changes are reflected- // WM_POINTERDEVICECHANGE might be useful for this, but its docs are too unclear to use- registerOrUpdateDevice(penInfo.pointerInfo.sourceDevice);- // TODO: Need a way to remove from device registration when devices are changed-- // We now only handle one pointer at a time, so just clear the pointer registration- penPointers.clear();-- int pointerId = penInfo.pointerInfo.pointerId;- PenPointerItem penPointerItem;- penPointerItem.hwnd = penInfo.pointerInfo.hwndTarget;- penPointerItem.deviceHandle = penInfo.pointerInfo.sourceDevice;- penPointerItem.activeWidget = nullptr;- penPointerItem.oneOverDpr = 1.0;- penPointerItem.widgetIsCaptured = false;- penPointerItem.widgetIsIgnored = false;- penPointerItem.widgetAcceptsPenEvent = false;- // penPointerItem.pointerId = pointerId;-- penPointers.insert(pointerId, penPointerItem);- // primaryPenPointerId = pointerId;-- // penEnter- sendProximityTabletEvent(QEvent::TabletEnterProximity, penInfo);-- return false;-}--bool handlePenLeaveMsg(const POINTER_PEN_INFO &penInfo)-{- if (!penPointers.contains(penInfo.pointerInfo.pointerId)) {- dbgTablet << "Pointer" << penInfo.pointerInfo.pointerId << "wasn't being handled";- return false;- }- if (!penDevices.contains(penInfo.pointerInfo.sourceDevice)) {- dbgTablet << "Device is gone from the registration???";- // TODO: re-register device?- penPointers.remove(penInfo.pointerInfo.pointerId);- return false;- }-- // penLeave- sendProximityTabletEvent(QEvent::TabletLeaveProximity, penInfo);-- penPointers.remove(penInfo.pointerInfo.pointerId);-- return false;-}--bool handleSinglePenUpdate(PenPointerItem &penPointerItem, const POINTER_PEN_INFO &penInfo, const PointerDeviceItem &device, const bool shouldSynthesizeMouseEvent)-{- QWidget *targetWidget;- if (penPointerItem.isCaptured()) {- if (penPointerItem.widgetIsIgnored) {- return false;- }- targetWidget = penPointerItem.activeWidget;- if (!targetWidget) {- return false;- }- } else {- QWidget *hwndWidget = QWidget::find(reinterpret_cast<WId>(penInfo.pointerInfo.hwndTarget));- if (!hwndWidget) {- dbgTablet << "HWND cannot be mapped to QWidget (what?)";- return false;- }- {- // Check popup / modal widget- QWidget *modalWidget = QApplication::activePopupWidget();- if (!modalWidget) {- modalWidget = QApplication::activeModalWidget();- }- if (modalWidget && modalWidget != hwndWidget && !modalWidget->isAncestorOf(hwndWidget)) {- return false;- }- }- {- QWindow *topLevelWindow = hwndWidget->windowHandle();- if (topLevelWindow) {- penPointerItem.oneOverDpr = 1.0 / topLevelWindow->devicePixelRatio();- } else {- penPointerItem.oneOverDpr = 1.0 / qApp->devicePixelRatio();- }- }- QPoint posInHwndWidget = hwndWidget->mapFromGlobal(QPoint(- static_cast<int>(penInfo.pointerInfo.ptPixelLocationRaw.x * penPointerItem.oneOverDpr),- static_cast<int>(penInfo.pointerInfo.ptPixelLocationRaw.y * penPointerItem.oneOverDpr)- ));- targetWidget = hwndWidget->childAt(posInHwndWidget);- if (!targetWidget) {- // dbgTablet << "No childQWidget at cursor position";- targetWidget = hwndWidget;- }- // penPointerItem.activeWidget = targetWidget;- }-- bool handled = sendPositionalTabletEvent(targetWidget, QEvent::TabletMove, penInfo, device, penPointerItem, shouldSynthesizeMouseEvent);- return handled;-}--bool handlePenUpdateMsg(const POINTER_PEN_INFO &penInfo)-{- auto currentPointerIt = penPointers.find(penInfo.pointerInfo.pointerId);- if (currentPointerIt == penPointers.end()) {- // dbgTablet << "Pointer" << penInfo.pointerInfo.pointerId << "wasn't being handled";- return false;- }-- const auto devIt = penDevices.find(penInfo.pointerInfo.sourceDevice);- if (devIt == penDevices.end()) {- dbgTablet << "Device not registered???";- return false;- }-- // UINT32 entriesCount = 0;- // if (!api.GetPointerPenInfoHistory(penInfo.pointerInfo.pointerId, &entriesCount, nullptr)) {- // dbgTablet << "GetPointerPenInfoHistory (getting count) failed";- // return false;- // }- UINT32 entriesCount = penInfo.pointerInfo.historyCount;- // dbgTablet << "entriesCount:" << entriesCount;- bool handled = false;- if (entriesCount != 1) {- QVector<POINTER_PEN_INFO> penInfoArray(entriesCount);- if (!api.GetPointerPenInfoHistory(penInfo.pointerInfo.pointerId, &entriesCount, penInfoArray.data())) {- dbgTablet << "GetPointerPenInfoHistory failed";- return false;- }- bool handled = false;- // The returned array is in reverse chronological order- const auto rbegin = penInfoArray.rbegin();- const auto rend = penInfoArray.rend();- const auto rlast = rend - 1; // Only synthesize mouse event for the last one- for (auto it = rbegin; it != rend; ++it) {- handled |= handleSinglePenUpdate(*currentPointerIt, *it, *devIt, it == rlast); // Bitwise OR doesn't short circuit- }- } else {- handled = handleSinglePenUpdate(*currentPointerIt, penInfo, *devIt, true);- }- return handled;-}--bool handlePenDownMsg(const POINTER_PEN_INFO &penInfo)-{- // PointerFlagsWrapper pointerFlags = PointerFlagsWrapper::fromPenInfo(penInfo);- // if (!pointerFlags.isPrimary()) {- // // Don't handle non-primary pointer messages for now- // return false;- // }- auto currentPointerIt = penPointers.find(penInfo.pointerInfo.pointerId);- if (currentPointerIt == penPointers.end()) {- dbgTablet << "Pointer" << penInfo.pointerInfo.pointerId << "wasn't being handled";- return false;- }- currentPointerIt->hwnd = penInfo.pointerInfo.hwndTarget; // They *should* be the same, but just in case- QWidget *hwndWidget = QWidget::find(reinterpret_cast<WId>(penInfo.pointerInfo.hwndTarget));- if (!hwndWidget) {- dbgTablet << "HWND cannot be mapped to QWidget (what?)";- return false;- }- {- QWindow *topLevelWindow = hwndWidget->windowHandle();- if (topLevelWindow) {- currentPointerIt->oneOverDpr = 1.0 / topLevelWindow->devicePixelRatio();- } else {- currentPointerIt->oneOverDpr = 1.0 / qApp->devicePixelRatio();- }- }- QPoint posInHwndWidget = hwndWidget->mapFromGlobal(QPoint(- static_cast<int>(penInfo.pointerInfo.ptPixelLocationRaw.x * currentPointerIt->oneOverDpr),- static_cast<int>(penInfo.pointerInfo.ptPixelLocationRaw.y * currentPointerIt->oneOverDpr)- ));- QWidget *targetWidget = hwndWidget->childAt(posInHwndWidget);- if (!targetWidget) {- dbgTablet << "No childQWidget at cursor position";- targetWidget = hwndWidget;- }-- currentPointerIt->activeWidget = targetWidget;- currentPointerIt->widgetIsCaptured = true;- // dbgTablet << "QWidget" << targetWidget->windowTitle() << "is capturing pointer" << penInfo.pointerInfo.pointerId;- {- // Check popup / modal widget- QWidget *modalWidget = QApplication::activePopupWidget();- if (!modalWidget) {- modalWidget = QApplication::activeModalWidget();- }- if (modalWidget && modalWidget != hwndWidget && !modalWidget->isAncestorOf(hwndWidget)) {- currentPointerIt->widgetIsIgnored = true;- dbgTablet << "Pointer" << penInfo.pointerInfo.pointerId << "is being captured but will be ignored";- return false;- }- }-- // penDown- const auto devIt = penDevices.find(penInfo.pointerInfo.sourceDevice);- if (devIt == penDevices.end()) {- dbgTablet << "Device not registered???";- return false;- }-- bool handled = sendPositionalTabletEvent(targetWidget, QEvent::TabletPress, penInfo, *devIt, *currentPointerIt, true);- currentPointerIt->widgetAcceptsPenEvent = handled;- if (!handled) {- // dbgTablet << "QWidget did not handle tablet down event";- }- return handled;-}--bool handlePenUpMsg(const POINTER_PEN_INFO &penInfo)-{- auto currentPointerIt = penPointers.find(penInfo.pointerInfo.pointerId);- if (currentPointerIt == penPointers.end()) {- dbgTablet << "Pointer" << penInfo.pointerInfo.pointerId << "wasn't being handled";- return false;- }- PenPointerItem &penPointerItem = *currentPointerIt;-- if (!penPointerItem.isCaptured()) {- dbgTablet << "Pointer wasn't captured";- return false;- }- if (penPointerItem.widgetIsIgnored) {- penPointerItem.widgetIsCaptured = false;- penPointerItem.widgetIsIgnored = false;- return false;- }-- // penUp- QWidget *targetWidget = penPointerItem.activeWidget;- if (!targetWidget) {- dbgTablet << "Previously captured target has been deleted";- penPointerItem.widgetIsCaptured = false;- return false;- }-- const auto devIt = penDevices.find(penInfo.pointerInfo.sourceDevice);- if (devIt == penDevices.end()) {- dbgTablet << "Device not registered???";- return false;- }-- bool handled = sendPositionalTabletEvent(targetWidget, QEvent::TabletRelease, penInfo, *devIt, penPointerItem, true);-- // dbgTablet << "QWidget" << currentPointerIt->activeWidget->windowTitle() << "is releasing capture to pointer" << penInfo.pointerInfo.pointerId;- penPointerItem.widgetIsCaptured = false;- penPointerItem.widgetAcceptsPenEvent = false;- return handled;-}--bool handlePointerMsg(const MSG &msg)-{- if (!api.isLoaded()) {- qWarning() << "Windows 8 Pointer Input API functions not loaded";- return false;- }-- int pointerId = GET_POINTERID_WPARAM(msg.wParam);- POINTER_INPUT_TYPE pointerType;- if (!api.GetPointerType(pointerId, &pointerType)) {- dbgTablet << "GetPointerType failed";- return false;- }- if (pointerType != PT_PEN) {- // dbgTablet << "pointerType" << pointerType << "is not PT_PEN";- return false;- }-- POINTER_PEN_INFO penInfo;- if (!api.GetPointerPenInfo(pointerId, &penInfo)) {- dbgTablet << "GetPointerPenInfo failed";- return false;- }-- switch (msg.message) {- case WM_POINTERDOWN:- // dbgTablet << "WM_POINTERDOWN";- break;- case WM_POINTERUP:- // dbgTablet << "WM_POINTERUP";- break;- case WM_POINTERENTER:- // dbgTablet << "WM_POINTERENTER";- break;- case WM_POINTERLEAVE:- // dbgTablet << "WM_POINTERLEAVE";- break;- case WM_POINTERUPDATE:- // dbgTablet << "WM_POINTERUPDATE";- break;- case WM_POINTERCAPTURECHANGED:- // dbgTablet << "WM_POINTERCAPTURECHANGED";- break;- default:- dbgTablet << "I missed this message: " << msg.message;- break;- }- // dbgTablet << " hwnd: " << penInfo.pointerInfo.hwndTarget;- // dbgTablet << " msg hwnd: " << msg.hwnd;- // dbgTablet << " pointerId: " << pointerId;- // dbgTablet << " sourceDevice:" << penInfo.pointerInfo.sourceDevice;- // dbgTablet << " pointerFlags:" << penInfo.pointerInfo.pointerFlags;- // dbgTablet << " btnChgType: " << penInfo.pointerInfo.ButtonChangeType;- // dbgTablet << " penFlags: " << penInfo.penFlags;- // dbgTablet << " penMask: " << penInfo.penMask;- // dbgTablet << " pressure: " << penInfo.pressure;- // dbgTablet << " rotation: " << penInfo.rotation;- // dbgTablet << " tiltX: " << penInfo.tiltX;- // dbgTablet << " tiltY: " << penInfo.tiltY;- // dbgTablet << " ptPixelLocationRaw: " << penInfo.pointerInfo.ptPixelLocationRaw;- // dbgTablet << " ptHimetricLocationRaw:" << penInfo.pointerInfo.ptHimetricLocationRaw;- // RECT pointerDeviceRect, displayRect;- // if (!api.GetPointerDeviceRects(penInfo.pointerInfo.sourceDevice, &pointerDeviceRect, &displayRect)) {- // dbgTablet << "GetPointerDeviceRects failed";- // return false;- // }- // dbgTablet << " pointerDeviceRect:" << pointerDeviceRect;- // dbgTablet << " displayRect:" << displayRect;- // dbgTablet << " scaled X:" << static_cast<qreal>(penInfo.pointerInfo.ptHimetricLocationRaw.x) / (pointerDeviceRect.right - pointerDeviceRect.left) * (displayRect.right - displayRect.left);- // dbgTablet << " scaled Y:" << static_cast<qreal>(penInfo.pointerInfo.ptHimetricLocationRaw.y) / (pointerDeviceRect.bottom - pointerDeviceRect.top) * (displayRect.bottom - displayRect.top);-- switch (msg.message) {- case WM_POINTERDOWN:- return handlePenDownMsg(penInfo);- case WM_POINTERUP:- return handlePenUpMsg(penInfo);- case WM_POINTERENTER:- return handlePenEnterMsg(penInfo);- case WM_POINTERLEAVE:- return handlePenLeaveMsg(penInfo);- case WM_POINTERUPDATE:- return handlePenUpdateMsg(penInfo);- case WM_POINTERCAPTURECHANGED:- // TODO: Should this event be handled?- dbgTablet << "FIXME: WM_POINTERCAPTURECHANGED isn't handled";- break;- }-- return false;-}--} // namespacediff --git a/libs/ui/input/wintab/kis_tablet_support_win8.h b/libs/ui/input/wintab/kis_tablet_support_win8.hdeleted file mode 100644index 66109f2c63..0000000000--- a/libs/ui/input/wintab/kis_tablet_support_win8.h+++ /dev/null@@ -1,30 +0,0 @@-/*- * SPDX-FileCopyrightText: 2017 Alvin Wong <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#ifndef KIS_TABLET_SUPPORT_WIN8_H-#define KIS_TABLET_SUPPORT_WIN8_H--#include <QAbstractNativeEventFilter>--#include <kritaui_export.h>--class KRITAUI_EXPORT KisTabletSupportWin8 : public QAbstractNativeEventFilter-{- Q_DISABLE_COPY(KisTabletSupportWin8)--public:- static bool isAvailable();- static bool isPenDeviceAvailable();-- KisTabletSupportWin8() = default;- ~KisTabletSupportWin8() = default;-- bool init();- // void registerPointerDeviceNotifications();- virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;-};--#endif // KIS_TABLET_SUPPORT_WIN8_Hdiff --git a/libs/ui/input/wintab/kis_tablet_support_win_p.h b/libs/ui/input/wintab/kis_tablet_support_win_p.hdeleted file mode 100644index 3874dead6d..0000000000--- a/libs/ui/input/wintab/kis_tablet_support_win_p.h+++ /dev/null@@ -1,134 +0,0 @@-/*- * SPDX-FileCopyrightText: 2015 The Qt Company Ltd.- * Contact: https://www.qt.io/licensing/- * SPDX-FileCopyrightText: 2015 Michael Abrahms <[email protected]>- *- * SPDX-License-Identifier: GPL-3.0-or-later- */--#ifndef KIS_TABLET_SUPPORT_WIN_P_H-#define KIS_TABLET_SUPPORT_WIN_P_H---#include <QVector>-#include <QPointF>-#include <QMap>-#include <QRect>--#include "wintab.h"--QT_BEGIN_NAMESPACE--class QDebug;-class QWindow;-class QRect;-class QWidget;--struct QWindowsWinTab32DLL-{- QWindowsWinTab32DLL() : wTOpen(0), wTClose(0), wTInfo(0), wTEnable(0), wTOverlap(0), wTPacketsGet(0), wTGet(0),- wTQueueSizeGet(0), wTQueueSizeSet(0) {}-- bool init();-- typedef HCTX (API *PtrWTOpen)(HWND, LPLOGCONTEXT, BOOL);- typedef BOOL (API *PtrWTClose)(HCTX);- typedef UINT (API *PtrWTInfo)(UINT, UINT, LPVOID);- typedef BOOL (API *PtrWTEnable)(HCTX, BOOL);- typedef BOOL (API *PtrWTOverlap)(HCTX, BOOL);- typedef int (API *PtrWTPacketsGet)(HCTX, int, LPVOID);- typedef BOOL (API *PtrWTGet)(HCTX, LPLOGCONTEXT);- typedef int (API *PtrWTQueueSizeGet)(HCTX);- typedef BOOL (API *PtrWTQueueSizeSet)(HCTX, int);-- PtrWTOpen wTOpen;- PtrWTClose wTClose;- PtrWTInfo wTInfo;- PtrWTEnable wTEnable;- PtrWTOverlap wTOverlap;- PtrWTPacketsGet wTPacketsGet;- PtrWTGet wTGet;- PtrWTQueueSizeGet wTQueueSizeGet;- PtrWTQueueSizeSet wTQueueSizeSet;-};--struct QWindowsTabletDeviceData-{- QWindowsTabletDeviceData() : minPressure(0), maxPressure(0), minTanPressure(0),- maxTanPressure(0), minX(0), maxX(0), minY(0), maxY(0), minZ(0), maxZ(0),- uniqueId(0), currentDevice(0), currentPointerType(0) {}-- QPointF scaleCoordinates(int coordX, int coordY,const QRect &targetArea) const;- qreal scalePressure(qreal p) const { return p / qreal(maxPressure - minPressure); }- qreal scaleTangentialPressure(qreal p) const { return p / qreal(maxTanPressure - minTanPressure); }-- int minPressure;- int maxPressure;- int minTanPressure;- int maxTanPressure;- int minX, maxX, minY, maxY, minZ, maxZ;- qint64 uniqueId;- int currentDevice;- int currentPointerType;- QRect virtualDesktopArea;-- // Added by Krita- QMap<quint8, quint8> buttonsMap;-};--QDebug operator<<(QDebug d, const QWindowsTabletDeviceData &t);--class QWindowsTabletSupport-{- Q_DISABLE_COPY(QWindowsTabletSupport)-- explicit QWindowsTabletSupport(HWND window, HCTX context);--public:- ~QWindowsTabletSupport();-- static QWindowsTabletSupport *create();-- void notifyActivate();- QString description() const;-- bool translateTabletProximityEvent(WPARAM wParam, LPARAM lParam);- bool translateTabletPacketEvent();-- int absoluteRange() const { return m_absoluteRange; }- void setAbsoluteRange(int a) { m_absoluteRange = a; }--- void tabletUpdateCursor(const int pkCursor);- static QWindowsWinTab32DLL m_winTab32DLL;--private:- unsigned options() const;- QWindowsTabletDeviceData tabletInit(const quint64 uniqueId, const UINT cursorType) const;-- const HWND m_window;- const HCTX m_context;- int m_absoluteRange;- bool m_tiltSupport;- QVector<QWindowsTabletDeviceData> m_devices;- int m_currentDevice;--- QWidget *targetWidget{0};-/**- * This is an inelegant solution to record pen / eraser switches.- * On the Surface Pro 3 we are only notified of cursor changes at the last minute.- * The recommended way to handle switches is WT_CSRCHANGE, but that doesn't work- * unless we save packet ID information, and we cannot change the structure of the- * PACKETDATA due to Qt restrictions.- *- * Furthermore, WT_CSRCHANGE only ever appears *after* we receive the packet.- */- UINT currentPkCursor{0};- bool isSurfacePro3{false}; //< Only enable this on SP3 or other devices with the same issue.--};--QT_END_NAMESPACE--#endif // KIS_TABLET_SUPPORT_WIN_P_Hdiff --git a/libs/ui/input/wintab/pktdef.h b/libs/ui/input/wintab/pktdef.hdeleted file mode 100644index 2f8415e782..0000000000--- a/libs/ui/input/wintab/pktdef.h+++ /dev/null@@ -1,262 +0,0 @@-/* -------------------------------- pktdef.h -------------------------------- */-/* Combined 16 & 32-bit version. */--/*-------------------------------------------------------------------------------The text and information contained in this file may be freely used,-copied, or distributed without compensation or licensing restrictions.--This file is copyright 1998-2008 by Wacom Technology-with portions copyright 1991-1998 by LCS/Telegraphics.-------------------------------------------------------------------------------*/-/*--------------------------------------------------------------------------------How to use pktdef.h:--1. Include wintab.h-2. if using just one packet format:- a. Define PACKETDATA and PACKETMODE as or'ed combinations of WTPKT bits- (use the PK_* identifiers).- b. Include pktdef.h.- c. The generated structure typedef will be called PACKET. Use PACKETDATA- and PACKETMODE to fill in the LOGCONTEXT structure.-3. If using multiple packet formats, for each one:- a. Define PACKETNAME. Its text value will be a prefix for this packet's- parameters and names.- b. Define <PACKETNAME>PACKETDATA and <PACKETNAME>PACKETMODE similar to- 2.a. above.- c. Include pktdef.h.- d. The generated structure typedef will be called- <PACKETNAME>PACKET. Compare with 2.c. above and example #2 below.-4. If using extension data for extensions that report their data in the packet,- do the following additional steps for each extension:- a. Before including pktdef.h, define <PACKETNAME>PACKET<EXTENSION>- as either PKEXT_ABSOLUTE or PKEXT_RELATIVE.- b. The generated structure typedef will contain a field for the- extension data.- c. Scan the WTI_EXTENSION categories to find the extension's- packet mask bit.- d. OR the packet mask bit with <PACKETNAME>PACKETDATA and use the- result in the lcPktData field of the LOGCONTEXT structure.- e. If <PACKETNAME>PACKET<EXTENSION> was PKEXT_RELATIVE, OR the- packet mask bit with <PACKETNAME>PACKETMODE and use the result- in the lcPktMode field of the LOGCONTEXT structure.-5. If using extension data for extensions that report their data in the extensions packet,- do the following additional steps for each extension:- a. Before including pktdef.h, define <PACKETNAME>PACKET<EXTENSION> as PKEXT_ABSOLUTE.- b. The generated extension structure typedef will contain a field for the- extension data.- c. Call WTExtSet to activate the extension. Use the context id in the WT_PACKETEXT- message to retrieve the extension data <PACKETNAME>PACKETEXT.---Example #1. -- single packet format--#include <wintab.h>-#define PACKETDATA PK_X | PK_Y | PK_BUTTONS /@ x, y, buttons @/-#define PACKETMODE PK_BUTTONS /@ buttons relative mode @/-#include <pktdef.h>-...- lc.lcPktData = PACKETDATA;- lc.lcPktMode = PACKETMODE;--Example #2. -- multiple formats--#include <wintab.h>-#define PACKETNAME MOE-#define MOEPACKETDATA PK_X | PK_Y | PK_BUTTONS /@ x, y, buttons @/-#define MOEPACKETMODE PK_BUTTONS /@ buttons relative mode @/-#include <pktdef.h>-#define PACKETNAME LARRY-#define LARRYPACKETDATA PK_Y | PK_Z | PK_BUTTONS /@ y, z, buttons @/-#define LARRYPACKETMODE PK_BUTTONS /@ buttons relative mode @/-#include <pktdef.h>-#define PACKETNAME CURLY-#define CURLYPACKETDATA PK_X | PK_Z | PK_BUTTONS /@ x, z, buttons @/-#define CURLYPACKETMODE PK_BUTTONS /@ buttons relative mode @/-#include <pktdef.h>-...- lcMOE.lcPktData = MOEPACKETDATA;- lcMOE.lcPktMode = MOEPACKETMODE;-...- lcLARRY.lcPktData = LARRYPACKETDATA;- lcLARRY.lcPktMode = LARRYPACKETMODE;-...- lcCURLY.lcPktData = CURLYPACKETDATA;- lcCURLY.lcPktMode = CURLYPACKETMODE;--Example #3. -- extension packet data "XFOO".--#include <wintab.h>-#define PACKETDATA PK_X | PK_Y | PK_BUTTONS /@ x, y, buttons @/-#define PACKETMODE PK_BUTTONS /@ buttons relative mode @/-#define PACKETXFOO PKEXT_ABSOLUTE /@ XFOO absolute mode @/-#include <pktdef.h>-...-UINT ScanExts(UINT wTag)-{- UINT i;- UINT wScanTag;-- /@ scan for wTag's info category. @/- for (i = 0; WTInfo(WTI_EXTENSIONS + i, EXT_TAG, &wScanTag); i++) {- if (wTag == wScanTag) {- /@ return category offset from WTI_EXTENSIONS. @/- return i;- }- }- /@ return error code. @/- return 0xFFFF;-}-...- lc.lcPktData = PACKETDATA;- lc.lcPktMode = PACKETMODE;-#ifdef PACKETXFOO- categoryXFOO = ScanExts(WTX_XFOO);- WTInfo(WTI_EXTENSIONS + categoryXFOO, EXT_MASK, &maskXFOO);- lc.lcPktData |= maskXFOO;-#if PACKETXFOO == PKEXT_RELATIVE- lc.lcPktMode |= maskXFOO;-#endif-#endif- WTOpen(hWnd, &lc, TRUE);---------------------------------------------------------------------------------*/-#ifdef __cplusplus-extern "C" {-#endif /* __cplusplus */--#ifndef PACKETNAME- /* if no packet name prefix */- #define __PFX(x) x- #define __IFX(x,y) x ## y-#else- /* add prefixes and infixes to packet format names */- #define __PFX(x) __PFX2(PACKETNAME,x)- #define __PFX2(p,x) __PFX3(p,x)- #define __PFX3(p,x) p ## x- #define __IFX(x,y) __IFX2(x,PACKETNAME,y)- #define __IFX2(x,i,y) __IFX3(x,i,y)- #define __IFX3(x,i,y) x ## i ## y-#endif--#define __SFX2(x,s) __SFX3(x,s)-#define __SFX3(x,s) x ## s--#define __TAG __IFX(tag,PACKET)-#define __TYPES __PFX(PACKET), * __IFX(P,PACKET), NEAR * __IFX(NP,PACKET), FAR * __IFX(LP,PACKET)--#define __TAGE __IFX(tag,PACKETEXT)-#define __TYPESE __PFX(PACKETEXT), * __IFX(P,PACKETEXT), NEAR * __IFX(NP,PACKETEXT), FAR * __IFX(LP,PACKETEXT)--#define __DATA (__PFX(PACKETDATA))-#define __MODE (__PFX(PACKETMODE))-#define __EXT(x) __SFX2(__PFX(PACKET),x)---typedef struct __TAG {- #if (__DATA & PK_CONTEXT)- HCTX pkContext;- #endif- #if (__DATA & PK_STATUS)- UINT pkStatus;- #endif- #if (__DATA & PK_TIME)- DWORD pkTime;- #endif- #if (__DATA & PK_CHANGED)- WTPKT pkChanged;- #endif- #if (__DATA & PK_SERIAL_NUMBER)- UINT pkSerialNumber;- #endif- #if (__DATA & PK_CURSOR)- UINT pkCursor;- #endif- #if (__DATA & PK_BUTTONS)- DWORD pkButtons;- #endif- #if (__DATA & PK_X)- LONG pkX;- #endif- #if (__DATA & PK_Y)- LONG pkY;- #endif- #if (__DATA & PK_Z)- LONG pkZ;- #endif- #if (__DATA & PK_NORMAL_PRESSURE)- #if (__MODE & PK_NORMAL_PRESSURE)- /* relative */- int pkNormalPressure;- #else- /* absolute */- UINT pkNormalPressure;- #endif- #endif- #if (__DATA & PK_TANGENT_PRESSURE)- #if (__MODE & PK_TANGENT_PRESSURE)- /* relative */- int pkTangentPressure;- #else- /* absolute */- UINT pkTangentPressure;- #endif- #endif- #if (__DATA & PK_ORIENTATION)- ORIENTATION pkOrientation;- #endif- #if (__DATA & PK_ROTATION)- ROTATION pkRotation; /* 1.1 */- #endif--#ifndef NOWTEXTENSIONS- /* extensions begin here. */- #if (__EXT(FKEYS) == PKEXT_RELATIVE) || (__EXT(FKEYS) == PKEXT_ABSOLUTE)- UINT pkFKeys;- #endif- #if (__EXT(TILT) == PKEXT_RELATIVE) || (__EXT(TILT) == PKEXT_ABSOLUTE)- TILT pkTilt;- #endif-#endif--} __TYPES ;--#ifndef NOWTEXTENSIONS-typedef struct __TAGE {- EXTENSIONBASE pkBase;-- #if (__EXT(EXPKEYS) == PKEXT_RELATIVE) || (__EXT(EXPKEYS) == PKEXT_ABSOLUTE)- EXPKEYSDATA pkExpKeys; /* 1.4 */- #endif- #if (__EXT(TOUCHSTRIP) == PKEXT_RELATIVE) || (__EXT(TOUCHSTRIP) == PKEXT_ABSOLUTE)- SLIDERDATA pkTouchStrip; /* 1.4 */- #endif- #if (__EXT(TOUCHRING) == PKEXT_RELATIVE) || (__EXT(TOUCHRING) == PKEXT_ABSOLUTE)- SLIDERDATA pkTouchRing; /* 1.4 */- #endif--} __TYPESE ;-#endif--#undef PACKETNAME-#undef __TAG-#undef __TAGE-#undef __TAG2-#undef __TYPES-#undef __TYPESE-#undef __TYPES2-#undef __DATA-#undef __MODE-#undef __PFX-#undef __PFX2-#undef __PFX3-#undef __IFX-#undef __IFX2-#undef __IFX3-#undef __SFX2-#undef __SFX3--#ifdef __cplusplus-}-#endif /* __cplusplus */diff --git a/libs/ui/input/wintab/wacom-properties.h b/libs/ui/input/wintab/wacom-properties.hdeleted file mode 100644index 98cb7d27c3..0000000000--- a/libs/ui/input/wintab/wacom-properties.h+++ /dev/null@@ -1,112 +0,0 @@-/*- * SPDX-FileCopyrightText: 2009 Red Hat Inc.- *- * SPDX-License-Identifier: GPL-2.0-or-later- */--#ifndef _WACOM_PROPERTIES_H_-#define _WACOM_PROPERTIES_H_--/**- * Properties exported by the wacom driver. These properties are- * recognized by the driver and will change its behavior when modified.- */--/* 32 bit, 4 values, top x, top y, bottom x, bottom y */-#define WACOM_PROP_TABLET_AREA "Wacom Tablet Area"--/* 8 bit, 1 value, [0 - 3] (NONE, CW, CCW, HALF) */-#define WACOM_PROP_ROTATION "Wacom Rotation"--/* 32 bit, 4 values */-#define WACOM_PROP_PRESSURECURVE "Wacom Pressurecurve"--/* CARD32, 5 values, tablet id, old serial, old hw device id,- current serial, current device id- read-only- */-#define WACOM_PROP_SERIALIDS "Wacom Serial IDs"--/* CARD32, 1 value */-#define WACOM_PROP_SERIAL_BIND "Wacom Serial ID binding"--/* 8 bit, 4 values, left up, left down, right up, right down- OR- Atom, 4 values , left up, left down, right up, right down- */-#define WACOM_PROP_STRIPBUTTONS "Wacom Strip Buttons"--/* 8 bit, 6 values, rel wheel up, rel wheel down, abs wheel up, abs wheel down, abs wheel 2 up, abs wheel 2 down- OR- Atom, 6 values , rel wheel up, rel wheel down, abs wheel up, abs wheel down, abs wheel 2 up, abs wheel 2 down- */-#define WACOM_PROP_WHEELBUTTONS "Wacom Wheel Buttons"--/* DEPRECATED, DO NOT USE */-#define WACOM_PROP_TWINVIEW_RES "Wacom TwinView Resolution"--/* DEPRECATED. DO NOT USE */-#define WACOM_PROP_DISPLAY_OPTS "Wacom Display Options"--/* DEPRECATED. DO NOT USE */-#define WACOM_PROP_SCREENAREA "Wacom Screen Area"--/* 32 bit, 1 value */-#define WACOM_PROP_PROXIMITY_THRESHOLD "Wacom Proximity Threshold"--/* DEPRECATED. DO NOT USE */-#define WACOM_PROP_CAPACITY "Wacom Capacity"--/* 32 bit, 1 value */-#define WACOM_PROP_PRESSURE_THRESHOLD "Wacom Pressure Threshold"--/* 32 bit, 2 values, suppress, sample */-#define WACOM_PROP_SAMPLE "Wacom Sample and Suppress"--/* BOOL, 1 value */-#define WACOM_PROP_TOUCH "Wacom Enable Touch"--/* BOOL, 1 value, read-only */-#define WACOM_PROP_HARDWARE_TOUCH "Wacom Hardware Touch Switch"--/* 8 bit, 1 values */-#define WACOM_PROP_ENABLE_GESTURE "Wacom Enable Touch Gesture"--/* 32 bit, 3 values, zoom, rotate, tap parameters */-#define WACOM_PROP_GESTURE_PARAMETERS "Wacom Touch Gesture Parameters"--/* BOOL, 1 value,- TRUE == hover click is enabled, FALSE == hover click disabled */-#define WACOM_PROP_HOVER "Wacom Hover Click"--/* Atom, 1 value, read-only */-#define WACOM_PROP_TOOL_TYPE "Wacom Tool Type"--/* Atom, X values where X is the number of physical buttons.- Each value points to an atom containing the sequence of actions performed- if this button is pressed. If the value is None, no action is performed.- */-#define WACOM_PROP_BUTTON_ACTIONS "Wacom Button Actions"--/* 8 bit, 2 values, priv->debugLevel and common->debugLevel. This property- * is for use in the driver only and only enabled if --enable-debug is- * given. No client may rely on this property being present or working.- */-#define WACOM_PROP_DEBUGLEVELS "Wacom Debug Levels"--/* BOOL, 1 value,- TRUE == pressure renormalization enabled, FALSE == pressure renormalization disabled-*/-#define WACOM_PROP_PRESSURE_RECAL "Wacom Pressure Recalibration"--/* The following are tool types used by the driver in WACOM_PROP_TOOL_TYPE- * or in the 'type' field for XI1 clients. Clients may check for one of- * these types to identify tool types.- */-#define WACOM_PROP_XI_TYPE_STYLUS "STYLUS"-#define WACOM_PROP_XI_TYPE_CURSOR "CURSOR"-#define WACOM_PROP_XI_TYPE_ERASER "ERASER"-#define WACOM_PROP_XI_TYPE_PAD "PAD"-#define WACOM_PROP_XI_TYPE_TOUCH "TOUCH"--#endifdiff --git a/libs/ui/input/wintab/wintab.h b/libs/ui/input/wintab/wintab.hdeleted file mode 100644index f27014dce6..0000000000--- a/libs/ui/input/wintab/wintab.h+++ /dev/null@@ -1,928 +0,0 @@-/* -------------------------------- wintab.h -------------------------------- */-/* Combined 16 & 32-bit version. */--/*-------------------------------------------------------------------------------The text and information contained in this file may be freely used,-copied, or distributed without compensation or licensing restrictions.--This file is copyright 1998-2008 by Wacom Technology-with portions copyright 1991-1998 by LCS/Telegraphics.-------------------------------------------------------------------------------*/-#include "windows.h"--#ifndef _INC_WINTAB /* prevent multiple includes */-#define _INC_WINTAB--#ifdef __cplusplus-extern "C" {-#endif /* __cplusplus */--/* -------------------------------------------------------------------------- */-/* Messages */-#ifndef NOWTMESSAGES-- #define WT_DEFBASE 0x7FF0- #define WT_MAXOFFSET 0xF-- #define _WT_PACKET(b) ((b)+0)- #define _WT_CTXOPEN(b) ((b)+1)- #define _WT_CTXCLOSE(b) ((b)+2)- #define _WT_CTXUPDATE(b) ((b)+3)- #define _WT_CTXOVERLAP(b) ((b)+4)- #define _WT_PROXIMITY(b) ((b)+5)- #define _WT_INFOCHANGE(b) ((b)+6)- #define _WT_CSRCHANGE(b) ((b)+7) /* 1.1 */- #define _WT_PACKETEXT(b) ((b)+8) /* 1.4 */- #define _WT_MAX(b) ((b)+WT_MAXOFFSET)-- #define WT_PACKET _WT_PACKET(WT_DEFBASE)- #define WT_CTXOPEN _WT_CTXOPEN(WT_DEFBASE)- #define WT_CTXCLOSE _WT_CTXCLOSE(WT_DEFBASE)- #define WT_CTXUPDATE _WT_CTXUPDATE(WT_DEFBASE)- #define WT_CTXOVERLAP _WT_CTXOVERLAP(WT_DEFBASE)- #define WT_PROXIMITY _WT_PROXIMITY(WT_DEFBASE)- #define WT_INFOCHANGE _WT_INFOCHANGE(WT_DEFBASE)- #define WT_CSRCHANGE _WT_CSRCHANGE(WT_DEFBASE) /* 1.1 */- #define WT_PACKETEXT _WT_PACKETEXT(WT_DEFBASE) /* 1.4 */- #define WT_MAX _WT_MAX(WT_DEFBASE)--#endif--/* -------------------------------------------------------------------------- */-/* -------------------------------------------------------------------------- */-/* Data Types */--/* -------------------------------------------------------------------------- */-/* COMMON DATA DEFS */--DECLARE_HANDLE(HMGR); /* manager handle */-DECLARE_HANDLE(HCTX); /* context handle */-DECLARE_HANDLE(HWTHOOK); /* hook handle */--typedef DWORD WTPKT; /* packet mask */---#ifndef NOWTPKT-- /* WTPKT bits */- #define PK_CONTEXT 0x0001 /* reporting context */- #define PK_STATUS 0x0002 /* status bits */- #define PK_TIME 0x0004 /* time stamp */- #define PK_CHANGED 0x0008 /* change bit vector */- #define PK_SERIAL_NUMBER 0x0010 /* packet serial number */- #define PK_CURSOR 0x0020 /* reporting cursor */- #define PK_BUTTONS 0x0040 /* button information */- #define PK_X 0x0080 /* x axis */- #define PK_Y 0x0100 /* y axis */- #define PK_Z 0x0200 /* z axis */- #define PK_NORMAL_PRESSURE 0x0400 /* normal or tip pressure */- #define PK_TANGENT_PRESSURE 0x0800 /* tangential or barrel pressure */- #define PK_ORIENTATION 0x1000 /* orientation info: tilts */- #define PK_ROTATION 0x2000 /* rotation info; 1.1 */--#endif--typedef DWORD FIX32; /* fixed-point arithmetic type */--#ifndef NOFIX32- #define INT(x) HIWORD(x)- #define FRAC(x) LOWORD(x)-- #define CASTFIX32(x) ((FIX32)((x)*65536L))-- #define ROUND(x) (INT(x) + (FRAC(x) > (WORD)0x8000))-- #define FIX_MUL(c, a, b) \- (c = (((DWORD)FRAC(a) * FRAC(b)) >> 16) + \- (DWORD)INT(a) * FRAC(b) + \- (DWORD)INT(b) * FRAC(a) + \- ((DWORD)INT(a) * INT(b) << 16))-- #ifdef _WINDLL- #define FIX_DIV_SC static- #else- #define FIX_DIV_SC- #endif-- #define FIX_DIV(c, a, b) \- { \- FIX_DIV_SC DWORD temp, rem, btemp; \- \- /* fraction done bytewise */ \- temp = ((a / b) << 16); \- rem = a % b; \- btemp = b; \- if (INT(btemp) < 256) { \- rem <<= 8; \- } \- else { \- btemp >>= 8; \- } \- temp += ((rem / btemp) << 8); \- rem %= btemp; \- rem <<= 8; \- temp += rem / btemp; \- c = temp; \- }-#endif--/* -------------------------------------------------------------------------- */-/* INFO DATA DEFS */--#ifndef NOWTINFO--#ifndef NOWTAXIS--typedef struct tagAXIS {- LONG axMin;- LONG axMax;- UINT axUnits;- FIX32 axResolution;-} AXIS, *PAXIS, NEAR *NPAXIS, FAR *LPAXIS;-- /* unit specifiers */- #define TU_NONE 0- #define TU_INCHES 1- #define TU_CENTIMETERS 2- #define TU_CIRCLE 3--#endif--#ifndef NOWTSYSBUTTONS--/* system button assignment values */-#define SBN_NONE 0x00-#define SBN_LCLICK 0x01-#define SBN_LDBLCLICK 0x02-#define SBN_LDRAG 0x03-#define SBN_RCLICK 0x04-#define SBN_RDBLCLICK 0x05-#define SBN_RDRAG 0x06-#define SBN_MCLICK 0x07-#define SBN_MDBLCLICK 0x08-#define SBN_MDRAG 0x09-/* for Pen Windows */-#define SBN_PTCLICK 0x10-#define SBN_PTDBLCLICK 0x20-#define SBN_PTDRAG 0x30-#define SBN_PNCLICK 0x40-#define SBN_PNDBLCLICK 0x50-#define SBN_PNDRAG 0x60-#define SBN_P1CLICK 0x70-#define SBN_P1DBLCLICK 0x80-#define SBN_P1DRAG 0x90-#define SBN_P2CLICK 0xA0-#define SBN_P2DBLCLICK 0xB0-#define SBN_P2DRAG 0xC0-#define SBN_P3CLICK 0xD0-#define SBN_P3DBLCLICK 0xE0-#define SBN_P3DRAG 0xF0--#endif--#ifndef NOWTCAPABILITIES--/* hardware capabilities */-#define HWC_INTEGRATED 0x0001-#define HWC_TOUCH 0x0002-#define HWC_HARDPROX 0x0004-#define HWC_PHYSID_CURSORS 0x0008 /* 1.1 */-#endif--#ifndef NOWTIFC--#ifndef NOWTCURSORS--/* cursor capabilities */-#define CRC_MULTIMODE 0x0001 /* 1.1 */-#define CRC_AGGREGATE 0x0002 /* 1.1 */-#define CRC_INVERT 0x0004 /* 1.1 */--#endif--/* info categories */-#define WTI_INTERFACE 1- #define IFC_WINTABID 1- #define IFC_SPECVERSION 2- #define IFC_IMPLVERSION 3- #define IFC_NDEVICES 4- #define IFC_NCURSORS 5- #define IFC_NCONTEXTS 6- #define IFC_CTXOPTIONS 7- #define IFC_CTXSAVESIZE 8- #define IFC_NEXTENSIONS 9- #define IFC_NMANAGERS 10- #define IFC_MAX 10---#endif--#ifndef NOWTSTATUS--#define WTI_STATUS 2- #define STA_CONTEXTS 1- #define STA_SYSCTXS 2- #define STA_PKTRATE 3- #define STA_PKTDATA 4- #define STA_MANAGERS 5- #define STA_SYSTEM 6- #define STA_BUTTONUSE 7- #define STA_SYSBTNUSE 8- #define STA_MAX 8--#endif--#ifndef NOWTDEFCONTEXT--#define WTI_DEFCONTEXT 3-#define WTI_DEFSYSCTX 4-#define WTI_DDCTXS 400 /* 1.1 */-#define WTI_DSCTXS 500 /* 1.1 */- #define CTX_NAME 1- #define CTX_OPTIONS 2- #define CTX_STATUS 3- #define CTX_LOCKS 4- #define CTX_MSGBASE 5- #define CTX_DEVICE 6- #define CTX_PKTRATE 7- #define CTX_PKTDATA 8- #define CTX_PKTMODE 9- #define CTX_MOVEMASK 10- #define CTX_BTNDNMASK 11- #define CTX_BTNUPMASK 12- #define CTX_INORGX 13- #define CTX_INORGY 14- #define CTX_INORGZ 15- #define CTX_INEXTX 16- #define CTX_INEXTY 17- #define CTX_INEXTZ 18- #define CTX_OUTORGX 19- #define CTX_OUTORGY 20- #define CTX_OUTORGZ 21- #define CTX_OUTEXTX 22- #define CTX_OUTEXTY 23- #define CTX_OUTEXTZ 24- #define CTX_SENSX 25- #define CTX_SENSY 26- #define CTX_SENSZ 27- #define CTX_SYSMODE 28- #define CTX_SYSORGX 29- #define CTX_SYSORGY 30- #define CTX_SYSEXTX 31- #define CTX_SYSEXTY 32- #define CTX_SYSSENSX 33- #define CTX_SYSSENSY 34- #define CTX_MAX 34--#endif--#ifndef NOWTDEVICES--#define WTI_DEVICES 100- #define DVC_NAME 1- #define DVC_HARDWARE 2- #define DVC_NCSRTYPES 3- #define DVC_FIRSTCSR 4- #define DVC_PKTRATE 5- #define DVC_PKTDATA 6- #define DVC_PKTMODE 7- #define DVC_CSRDATA 8- #define DVC_XMARGIN 9- #define DVC_YMARGIN 10- #define DVC_ZMARGIN 11- #define DVC_X 12- #define DVC_Y 13- #define DVC_Z 14- #define DVC_NPRESSURE 15- #define DVC_TPRESSURE 16- #define DVC_ORIENTATION 17- #define DVC_ROTATION 18 /* 1.1 */- #define DVC_PNPID 19 /* 1.1 */- #define DVC_MAX 19--#endif--#ifndef NOWTCURSORS--#define WTI_CURSORS 200- #define CSR_NAME 1- #define CSR_ACTIVE 2- #define CSR_PKTDATA 3- #define CSR_BUTTONS 4- #define CSR_BUTTONBITS 5- #define CSR_BTNNAMES 6- #define CSR_BUTTONMAP 7- #define CSR_SYSBTNMAP 8- #define CSR_NPBUTTON 9- #define CSR_NPBTNMARKS 10- #define CSR_NPRESPONSE 11- #define CSR_TPBUTTON 12- #define CSR_TPBTNMARKS 13- #define CSR_TPRESPONSE 14- #define CSR_PHYSID 15 /* 1.1 */- #define CSR_MODE 16 /* 1.1 */- #define CSR_MINPKTDATA 17 /* 1.1 */- #define CSR_MINBUTTONS 18 /* 1.1 */- #define CSR_CAPABILITIES 19 /* 1.1 */- #define CSR_TYPE 20 /* 1.2 */- #define CSR_MAX 20--#endif--#ifndef NOWTEXTENSIONS--#define WTI_EXTENSIONS 300- #define EXT_NAME 1- #define EXT_TAG 2- #define EXT_MASK 3- #define EXT_SIZE 4- #define EXT_AXES 5- #define EXT_DEFAULT 6- #define EXT_DEFCONTEXT 7- #define EXT_DEFSYSCTX 8- #define EXT_CURSORS 9- #define EXT_DEVICES 110 /* Allow 100 cursors */- #define EXT_MAX 210 /* Allow 100 devices */--#endif--#endif--/* -------------------------------------------------------------------------- */-/* CONTEXT DATA DEFS */--#define LCNAMELEN 40-#define LC_NAMELEN 40-#ifdef WIN32-typedef struct tagLOGCONTEXTA {- char lcName[LCNAMELEN];- UINT lcOptions;- UINT lcStatus;- UINT lcLocks;- UINT lcMsgBase;- UINT lcDevice;- UINT lcPktRate;- WTPKT lcPktData;- WTPKT lcPktMode;- WTPKT lcMoveMask;- DWORD lcBtnDnMask;- DWORD lcBtnUpMask;- LONG lcInOrgX;- LONG lcInOrgY;- LONG lcInOrgZ;- LONG lcInExtX;- LONG lcInExtY;- LONG lcInExtZ;- LONG lcOutOrgX;- LONG lcOutOrgY;- LONG lcOutOrgZ;- LONG lcOutExtX;- LONG lcOutExtY;- LONG lcOutExtZ;- FIX32 lcSensX;- FIX32 lcSensY;- FIX32 lcSensZ;- BOOL lcSysMode;- int lcSysOrgX;- int lcSysOrgY;- int lcSysExtX;- int lcSysExtY;- FIX32 lcSysSensX;- FIX32 lcSysSensY;-} LOGCONTEXTA, *PLOGCONTEXTA, NEAR *NPLOGCONTEXTA, FAR *LPLOGCONTEXTA;-typedef struct tagLOGCONTEXTW {- WCHAR lcName[LCNAMELEN];- UINT lcOptions;- UINT lcStatus;- UINT lcLocks;- UINT lcMsgBase;- UINT lcDevice;- UINT lcPktRate;- WTPKT lcPktData;- WTPKT lcPktMode;- WTPKT lcMoveMask;- DWORD lcBtnDnMask;- DWORD lcBtnUpMask;- LONG lcInOrgX;- LONG lcInOrgY;- LONG lcInOrgZ;- LONG lcInExtX;- LONG lcInExtY;- LONG lcInExtZ;- LONG lcOutOrgX;- LONG lcOutOrgY;- LONG lcOutOrgZ;- LONG lcOutExtX;- LONG lcOutExtY;- LONG lcOutExtZ;- FIX32 lcSensX;- FIX32 lcSensY;- FIX32 lcSensZ;- BOOL lcSysMode;- int lcSysOrgX;- int lcSysOrgY;- int lcSysExtX;- int lcSysExtY;- FIX32 lcSysSensX;- FIX32 lcSysSensY;-} LOGCONTEXTW, *PLOGCONTEXTW, NEAR *NPLOGCONTEXTW, FAR *LPLOGCONTEXTW;-#ifdef UNICODE-typedef LOGCONTEXTW LOGCONTEXT;-typedef PLOGCONTEXTW PLOGCONTEXT;-typedef NPLOGCONTEXTW NPLOGCONTEXT;-typedef LPLOGCONTEXTW LPLOGCONTEXT;-#else-typedef LOGCONTEXTA LOGCONTEXT;-typedef PLOGCONTEXTA PLOGCONTEXT;-typedef NPLOGCONTEXTA NPLOGCONTEXT;-typedef LPLOGCONTEXTA LPLOGCONTEXT;-#endif /* UNICODE */-#else /* WIN32 */-typedef struct tagLOGCONTEXT {- char lcName[LCNAMELEN];- UINT lcOptions;- UINT lcStatus;- UINT lcLocks;- UINT lcMsgBase;- UINT lcDevice;- UINT lcPktRate;- WTPKT lcPktData;- WTPKT lcPktMode;- WTPKT lcMoveMask;- DWORD lcBtnDnMask;- DWORD lcBtnUpMask;- LONG lcInOrgX;- LONG lcInOrgY;- LONG lcInOrgZ;- LONG lcInExtX;- LONG lcInExtY;- LONG lcInExtZ;- LONG lcOutOrgX;- LONG lcOutOrgY;- LONG lcOutOrgZ;- LONG lcOutExtX;- LONG lcOutExtY;- LONG lcOutExtZ;- FIX32 lcSensX;- FIX32 lcSensY;- FIX32 lcSensZ;- BOOL lcSysMode;- int lcSysOrgX;- int lcSysOrgY;- int lcSysExtX;- int lcSysExtY;- FIX32 lcSysSensX;- FIX32 lcSysSensY;-} LOGCONTEXT, *PLOGCONTEXT, NEAR *NPLOGCONTEXT, FAR *LPLOGCONTEXT;-#endif /* WIN32 */-- /* context option values */- #define CXO_SYSTEM 0x0001- #define CXO_PEN 0x0002- #define CXO_MESSAGES 0x0004- #define CXO_MARGIN 0x8000- #define CXO_MGNINSIDE 0x4000- #define CXO_CSRMESSAGES 0x0008 /* 1.1 */-- /* context status values */- #define CXS_DISABLED 0x0001- #define CXS_OBSCURED 0x0002- #define CXS_ONTOP 0x0004-- /* context lock values */- #define CXL_INSIZE 0x0001- #define CXL_INASPECT 0x0002- #define CXL_SENSITIVITY 0x0004- #define CXL_MARGIN 0x0008- #define CXL_SYSOUT 0x0010--/* -------------------------------------------------------------------------- */-/* EVENT DATA DEFS */--/* For packet structure definition, see pktdef.h */--/* packet status values */-#define TPS_PROXIMITY 0x0001-#define TPS_QUEUE_ERR 0x0002-#define TPS_MARGIN 0x0004-#define TPS_GRAB 0x0008-#define TPS_INVERT 0x0010 /* 1.1 */--typedef struct tagORIENTATION {- int orAzimuth;- int orAltitude;- int orTwist;-} ORIENTATION, *PORIENTATION, NEAR *NPORIENTATION, FAR *LPORIENTATION;--typedef struct tagROTATION { /* 1.1 */- int roPitch;- int roRoll;- int roYaw;-} ROTATION, *PROTATION, NEAR *NPROTATION, FAR *LPROTATION;-// grandfather in obsolete member names.-#define rotPitch roPitch-#define rotRoll roRoll-#define rotYaw roYaw---/* relative buttons */-#define TBN_NONE 0-#define TBN_UP 1-#define TBN_DOWN 2--/* -------------------------------------------------------------------------- */-/* DEVICE CONFIG CONSTANTS */--#ifndef NOWTDEVCFG--#define WTDC_NONE 0-#define WTDC_CANCEL 1-#define WTDC_OK 2-#define WTDC_RESTART 3--#endif--/* -------------------------------------------------------------------------- */-/* HOOK CONSTANTS */--#ifndef NOWTHOOKS--#define WTH_PLAYBACK 1-#define WTH_RECORD 2--#define WTHC_GETLPLPFN (-3)-#define WTHC_LPLPFNNEXT (-2)-#define WTHC_LPFNNEXT (-1)-#define WTHC_ACTION 0-#define WTHC_GETNEXT 1-#define WTHC_SKIP 2--#endif--/* -------------------------------------------------------------------------- */-/* PREFERENCE FUNCTION CONSTANTS */--#ifndef NOWTPREF--#define WTP_LPDEFAULT ((LPVOID)-1L)-#define WTP_DWDEFAULT ((DWORD)-1L)--#endif--/* -------------------------------------------------------------------------- */-/* EXTENSION TAGS AND CONSTANTS */--#ifndef NOWTEXTENSIONS--/* constants for use with pktdef.h */-#define PKEXT_ABSOLUTE 1-#define PKEXT_RELATIVE 2--/* Extension tags. */-#define WTX_OBT 0 /* Out of bounds tracking */-#define WTX_FKEYS 1 /* Function keys */-#define WTX_TILT 2 /* Raw Cartesian tilt; 1.1 */-#define WTX_CSRMASK 3 /* select input by cursor type; 1.1 */-#define WTX_XBTNMASK 4 /* Extended button mask; 1.1 */-#define WTX_EXPKEYS 5 /* ExpressKeys; 1.3 - DEPRECATED: see WTX_EXPKEYS2 */-#define WTX_TOUCHSTRIP 6 /* TouchStrips; 1.4 */-#define WTX_TOUCHRING 7 /* TouchRings; 1.4 */-#define WTX_EXPKEYS2 8 /* ExpressKeys; 1.4 */--typedef struct tagXBTNMASK {- BYTE xBtnDnMask[32];- BYTE xBtnUpMask[32];-} XBTNMASK;--typedef struct tagTILT { /* 1.1 */- int tiltX;- int tiltY;-} TILT;--typedef struct tagEXTENSIONBASE { /* 1.4 */- HCTX nContext;- UINT nStatus;- DWORD nTime;- UINT nSerialNumber;-} EXTENSIONBASE;--typedef struct tagEXPKEYSDATA { /* 1.4 */- BYTE nTablet;- BYTE nControl;- BYTE nLocation;- BYTE nReserved;- DWORD nState;-} EXPKEYSDATA;--typedef struct tagSLIDERDATA { /* 1.4 */- BYTE nTablet;- BYTE nControl;- BYTE nMode;- BYTE nReserved;- DWORD nPosition;-} SLIDERDATA;--typedef struct tagEXTPROPERTY { /* 1.4 */- BYTE version; // Structure version, 0 for now- BYTE tabletIndex; // 0-based index for tablet- BYTE controlIndex; // 0-based index for control- BYTE functionIndex; // 0-based index for control's sub-function- WORD propertyID; // property ID- WORD reserved; // DWORD-alignment filler- DWORD dataSize; // number of bytes in data[] buffer- BYTE data[1]; // raw data-} EXTPROPERTY;--#define TABLET_PROPERTY_CONTROLCOUNT 0 // UINT32: number of physical controls on tablet-#define TABLET_PROPERTY_FUNCCOUNT 1 // UINT32: number of functions of control-#define TABLET_PROPERTY_AVAILABLE 2 // BOOL: control/mode is available for override-#define TABLET_PROPERTY_MIN 3 // UINT32: minimum value-#define TABLET_PROPERTY_MAX 4 // UINT32: maximum value-#define TABLET_PROPERTY_OVERRIDE 5 // BOOL: control is overridden-#define TABLET_PROPERTY_OVERRIDE_NAME 6 // UTF-8: Displayable name when control is overridden-#define TABLET_PROPERTY_OVERRIDE_ICON 7 // Image: Icon to show when control is overridden-#define TABLET_PROPERTY_ICON_WIDTH 8 // UINT32: Pixel width of icon display-#define TABLET_PROPERTY_ICON_HEIGHT 9 // UINT32: Pixel height of icon display-#define TABLET_PROPERTY_ICON_FORMAT 10 // UINT32: UINT32: Pixel format of icon display (see TABLET_ICON_FMT_*)-#define TABLET_PROPERTY_LOCATION 11 // UINT32: Physical location of control (see TABLET_LOC_*)--#define TABLET_ICON_FMT_NONE 0 // No display-#define TABLET_ICON_FMT_4BPP_GRAY 1 // 4bpp grayscale--#define TABLET_LOC_LEFT 0-#define TABLET_LOC_RIGHT 1-#define TABLET_LOC_TOP 2-#define TABLET_LOC_BOTTOM 3-#define TABLET_LOC_TRANSDUCER 4--#endif--/* -------------------------------------------------------------------------- */-/* -------------------------------------------------------------------------- */-/* Functions */-- #ifndef API- #ifndef WINAPI- #define API FAR PASCAL- #else- #define API WINAPI- #endif- #endif--#ifndef NOWTCALLBACKS-- #ifndef CALLBACK- #define CALLBACK FAR PASCAL- #endif-- #ifndef NOWTMANAGERFXNS- /* callback function types */- typedef BOOL (WINAPI * WTENUMPROC)(HCTX, LPARAM); /* changed CALLBACK->WINAPI, 1.1 */- typedef BOOL (WINAPI * WTCONFIGPROC)(HCTX, HWND);- typedef LRESULT (WINAPI * WTHOOKPROC)(int, WPARAM, LPARAM);- typedef WTHOOKPROC FAR *LPWTHOOKPROC;- #endif--#endif---#ifndef NOWTFUNCTIONS-- #ifndef NOWTBASICFXNS- /* BASIC FUNCTIONS */-#ifdef WIN32- UINT API WTInfoA(UINT, UINT, LPVOID);- #define ORD_WTInfoA 20- UINT API WTInfoW(UINT, UINT, LPVOID);- #define ORD_WTInfoW 1020- #ifdef UNICODE- #define WTInfo WTInfoW- #define ORD_WTInfo ORD_WTInfoW- #else- #define WTInfo WTInfoA- #define ORD_WTInfo ORD_WTInfoA- #endif /* !UNICODE */-#else- UINT API WTInfo(UINT, UINT, LPVOID);- #define ORD_WTInfo 20-#endif-#ifdef WIN32- HCTX API WTOpenA(HWND, LPLOGCONTEXTA, BOOL);- #define ORD_WTOpenA 21- HCTX API WTOpenW(HWND, LPLOGCONTEXTW, BOOL);- #define ORD_WTOpenW 1021- #ifdef UNICODE- #define WTOpen WTOpenW- #define ORD_WTOpen ORD_WTOpenW- #else- #define WTOpen WTOpenA- #define ORD_WTOpen ORD_WTOpenA- #endif /* !UNICODE */-#else- HCTX API WTOpen(HWND, LPLOGCONTEXT, BOOL);- #define ORD_WTOpen 21-#endif- BOOL API WTClose(HCTX);- #define ORD_WTClose 22- int API WTPacketsGet(HCTX, int, LPVOID);- #define ORD_WTPacketsGet 23- BOOL API WTPacket(HCTX, UINT, LPVOID);- #define ORD_WTPacket 24- #endif-- #ifndef NOWTVISIBILITYFXNS- /* VISIBILITY FUNCTIONS */- BOOL API WTEnable(HCTX, BOOL);- #define ORD_WTEnable 40- BOOL API WTOverlap(HCTX, BOOL);- #define ORD_WTOverlap 41- #endif-- #ifndef NOWTCTXEDITFXNS- /* CONTEXT EDITING FUNCTIONS */- BOOL API WTConfig(HCTX, HWND);- #define ORD_WTConfig 60-#ifdef WIN32- BOOL API WTGetA(HCTX, LPLOGCONTEXTA);- #define ORD_WTGetA 61- BOOL API WTGetW(HCTX, LPLOGCONTEXTW);- #define ORD_WTGetW 1061- #ifdef UNICODE- #define WTGet WTGetW- #define ORD_WTGet ORD_WTGetW- #else- #define WTGet WTGetA- #define ORD_WTGet ORD_WTGetA- #endif /* !UNICODE */-#else- BOOL API WTGet(HCTX, LPLOGCONTEXT);- #define ORD_WTGet 61-#endif-#ifdef WIN32- BOOL API WTSetA(HCTX, LPLOGCONTEXTA);- #define ORD_WTSetA 62- BOOL API WTSetW(HCTX, LPLOGCONTEXTW);- #define ORD_WTSetW 1062- #ifdef UNICODE- #define WTSet WTSetW- #define ORD_WTSet ORD_WTSetW- #else- #define WTSet WTSetA- #define ORD_WTSet ORD_WTSetA- #endif /* !UNICODE */-#else- BOOL API WTSet(HCTX, LPLOGCONTEXT);- #define ORD_WTSet 62-#endif- BOOL API WTExtGet(HCTX, UINT, LPVOID);- #define ORD_WTExtGet 63- BOOL API WTExtSet(HCTX, UINT, LPVOID);- #define ORD_WTExtSet 64- BOOL API WTSave(HCTX, LPVOID);- #define ORD_WTSave 65- HCTX API WTRestore(HWND, LPVOID, BOOL);- #define ORD_WTRestore 66- #endif-- #ifndef NOWTQUEUEFXNS- /* ADVANCED PACKET AND QUEUE FUNCTIONS */- int API WTPacketsPeek(HCTX, int, LPVOID);- #define ORD_WTPacketsPeek 80- int API WTDataGet(HCTX, UINT, UINT, int, LPVOID, LPINT);- #define ORD_WTDataGet 81- int API WTDataPeek(HCTX, UINT, UINT, int, LPVOID, LPINT);- #define ORD_WTDataPeek 82-#ifndef WIN32-/* OBSOLETE IN WIN32! */- DWORD API WTQueuePackets(HCTX);- #define ORD_WTQueuePackets 83-#endif- int API WTQueueSizeGet(HCTX);- #define ORD_WTQueueSizeGet 84- BOOL API WTQueueSizeSet(HCTX, int);- #define ORD_WTQueueSizeSet 85- #endif-- #ifndef NOWTHMGRFXNS- /* MANAGER HANDLE FUNCTIONS */- HMGR API WTMgrOpen(HWND, UINT);- #define ORD_WTMgrOpen 100- BOOL API WTMgrClose(HMGR);- #define ORD_WTMgrClose 101- #endif-- #ifndef NOWTMGRCTXFXNS- /* MANAGER CONTEXT FUNCTIONS */- BOOL API WTMgrContextEnum(HMGR, WTENUMPROC, LPARAM);- #define ORD_WTMgrContextEnum 120- HWND API WTMgrContextOwner(HMGR, HCTX);- #define ORD_WTMgrContextOwner 121- HCTX API WTMgrDefContext(HMGR, BOOL);- #define ORD_WTMgrDefContext 122- HCTX API WTMgrDefContextEx(HMGR, UINT, BOOL); /* 1.1 */- #define ORD_WTMgrDefContextEx 206- #endif-- #ifndef NOWTMGRCONFIGFXNS- /* MANAGER CONFIG BOX FUNCTIONS */- UINT API WTMgrDeviceConfig(HMGR, UINT, HWND);- #define ORD_WTMgrDeviceConfig 140-#ifndef WIN32-/* OBSOLETE IN WIN32! */- BOOL API WTMgrConfigReplace(HMGR, BOOL, WTCONFIGPROC);- #define ORD_WTMgrConfigReplace 141-#endif- #endif-- #ifndef NOWTMGRHOOKFXNS- /* MANAGER PACKET HOOK FUNCTIONS */-#ifndef WIN32-/* OBSOLETE IN WIN32! */- WTHOOKPROC API WTMgrPacketHook(HMGR, BOOL, int, WTHOOKPROC);- #define ORD_WTMgrPacketHook 160- LRESULT API WTMgrPacketHookDefProc(int, WPARAM, LPARAM, LPWTHOOKPROC);- #define ORD_WTMgrPacketHookDefProc 161-#endif- #endif-- #ifndef NOWTMGRPREFFXNS- /* MANAGER PREFERENCE DATA FUNCTIONS */- BOOL API WTMgrExt(HMGR, UINT, LPVOID);- #define ORD_WTMgrExt 180- BOOL API WTMgrCsrEnable(HMGR, UINT, BOOL);- #define ORD_WTMgrCsrEnable 181- BOOL API WTMgrCsrButtonMap(HMGR, UINT, LPBYTE, LPBYTE);- #define ORD_WTMgrCsrButtonMap 182- BOOL API WTMgrCsrPressureBtnMarks(HMGR, UINT, DWORD, DWORD);- #define ORD_WTMgrCsrPressureBtnMarks 183- BOOL API WTMgrCsrPressureResponse(HMGR, UINT, UINT FAR *, UINT FAR *);- #define ORD_WTMgrCsrPressureResponse 184- BOOL API WTMgrCsrExt(HMGR, UINT, UINT, LPVOID);- #define ORD_WTMgrCsrExt 185- #endif--/* Win32 replacements for non-portable functions. */- #ifndef NOWTQUEUEFXNS- /* ADVANCED PACKET AND QUEUE FUNCTIONS */- BOOL API WTQueuePacketsEx(HCTX, UINT FAR *, UINT FAR *);- #define ORD_WTQueuePacketsEx 200- #endif-- #ifndef NOWTMGRCONFIGFXNS- /* MANAGER CONFIG BOX FUNCTIONS */-#ifdef WIN32- BOOL API WTMgrConfigReplaceExA(HMGR, BOOL, LPSTR, LPSTR);- #define ORD_WTMgrConfigReplaceExA 202- BOOL API WTMgrConfigReplaceExW(HMGR, BOOL, LPWSTR, LPSTR);- #define ORD_WTMgrConfigReplaceExW 1202- #ifdef UNICODE- #define WTMgrConfigReplaceEx WTMgrConfigReplaceExW- #define ORD_WTMgrConfigReplaceEx ORD_WTMgrConfigReplaceExW- #else- #define WTMgrConfigReplaceEx WTMgrConfigReplaceExA- #define ORD_WTMgrConfigReplaceEx ORD_WTMgrConfigReplaceExA- #endif /* !UNICODE */-#else- BOOL API WTMgrConfigReplaceEx(HMGR, BOOL, LPSTR, LPSTR);- #define ORD_WTMgrConfigReplaceEx 202-#endif- #endif-- #ifndef NOWTMGRHOOKFXNS- /* MANAGER PACKET HOOK FUNCTIONS */-#ifdef WIN32- HWTHOOK API WTMgrPacketHookExA(HMGR, int, LPSTR, LPSTR);- #define ORD_WTMgrPacketHookExA 203- HWTHOOK API WTMgrPacketHookExW(HMGR, int, LPWSTR, LPSTR);- #define ORD_WTMgrPacketHookExW 1203- #ifdef UNICODE- #define WTMgrPacketHookEx WTMgrPacketHookExW- #define ORD_WTMgrPacketHookEx ORD_WTMgrPacketHookExW- #else- #define WTMgrPacketHookEx WTMgrPacketHookExA- #define ORD_WTMgrPacketHookEx ORD_WTMgrPacketHookExA- #endif /* !UNICODE */-#else- HWTHOOK API WTMgrPacketHookEx(HMGR, int, LPSTR, LPSTR);- #define ORD_WTMgrPacketHookEx 203-#endif- BOOL API WTMgrPacketUnhook(HWTHOOK);- #define ORD_WTMgrPacketUnhook 204- LRESULT API WTMgrPacketHookNext(HWTHOOK, int, WPARAM, LPARAM);- #define ORD_WTMgrPacketHookNext 205- #endif-- #ifndef NOWTMGRPREFFXNS- /* MANAGER PREFERENCE DATA FUNCTIONS */- BOOL API WTMgrCsrPressureBtnMarksEx(HMGR, UINT, UINT FAR *, UINT FAR *);- #define ORD_WTMgrCsrPressureBtnMarksEx 201- #endif--#endif--#ifdef __cplusplus-}-#endif /* __cplusplus */--#endif /* #define _INC_WINTAB */-diff --git a/libs/ui/kis_config.cc b/libs/ui/kis_config.ccindex 7c5303e095..2b33184f5c 100644--- a/libs/ui/kis_config.cc+++ b/libs/ui/kis_config.cc@@ -1361,14 +1361,10 @@ void KisConfig::setPressureTabletCurve(const QString& curveString) constbool KisConfig::useWin8PointerInput(bool defaultValue) const{#ifdef Q_OS_WIN-#ifdef USE_QT_TABLET_WINDOWSconst QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);return useWin8PointerInputNoApp(&kritarc, defaultValue);-#else- return (defaultValue ? false : m_cfg.readEntry("useWin8PointerInput", false));-#endif#elseQ_UNUSED(defaultValue);return false;@@ -1382,15 +1378,9 @@ void KisConfig::setUseWin8PointerInput(bool value)// Special handling: Only set value if changed// I don't want it to be set if the user hasn't touched itif (useWin8PointerInput() != value) {--#ifdef USE_QT_TABLET_WINDOWSconst QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);setUseWin8PointerInputNoApp(&kritarc, value);-#else- m_cfg.writeEntry("useWin8PointerInput", value);-#endif-}#else