From 8f4660611f435aea860072d741cf506262f56347 Mon Sep 17 00:00:00 2001
From: Nate Graham <nate@kde.org>
Date: Tue, 3 Aug 2021 09:44:05 -0600
Subject: [PATCH 1/3] Turn off gesture support by default and warn when turning
 it on manually

Gesture support has been disabled by default upstream to work around an
inherent incompatibility with Wacom-provided gestures and touch support
in Qt; see https://bugreports.qt.io/browse/QTBUG-84756.

However the KCM still has it on by default, and its KDED module
propagates that change to effectively turn gestore support on
automatically. This results in touchscreen touch being broken for all
Qt software by default when this repo is installed.

This commit turns gesture support off by default to match the new
upstream setting and prevent broken touch support in Qt software, and
also shows a warning message about this if the user turns it on
manually.

BUG: 440556
FIXED-IN: 5.23
---
 src/common/deviceprofiledefaults.cpp |  2 +-
 src/kcmodule/touchpagewidget.cpp     | 23 ++++++++++++++++++++++-
 src/kcmodule/touchpagewidget.ui      | 26 ++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/src/common/deviceprofiledefaults.cpp b/src/common/deviceprofiledefaults.cpp
index 1425b1c..066c3cb 100644
--- a/src/common/deviceprofiledefaults.cpp
+++ b/src/common/deviceprofiledefaults.cpp
@@ -44,7 +44,7 @@ void setupDefaultStylus(DeviceProfile &stylus) {
 }
 
 void setupDefaultTouch(DeviceProfile &touch) {
-    touch.setProperty(Property::Gesture, QLatin1String("on"));
+    touch.setProperty(Property::Gesture, QLatin1String("off"));
     touch.setProperty(Property::InvertScroll, QLatin1String("off"));
     touch.setProperty(Property::Mode, QLatin1String("absolute"));
     touch.setProperty(Property::Rotate, ScreenRotation::AUTO.key());
diff --git a/src/kcmodule/touchpagewidget.cpp b/src/kcmodule/touchpagewidget.cpp
index ffe748b..f2facb0 100644
--- a/src/kcmodule/touchpagewidget.cpp
+++ b/src/kcmodule/touchpagewidget.cpp
@@ -28,6 +28,7 @@
 #include "tabletareaselectiondialog.h"
 #include "x11wacom.h"
 
+#include <QDesktopServices>
 #include <QRegExp>
 #include <QStringList>
 
@@ -115,6 +116,12 @@ void TouchPageWidget::saveToProfile(ProfileManagementInterface &profileManagemen
 
 void TouchPageWidget::onGesturesModeChanged(int state)
 {
+    if (state == 0) {
+        ui->gesturesWarning->animatedHide();
+    } else {
+        ui->gesturesWarning->animatedShow();
+    }
+
     setGesturesSupportEnabled(state == Qt::Checked);
     onProfileChanged();
 }
@@ -148,11 +155,18 @@ void TouchPageWidget::onTabletMappingClicked()
 
 void TouchPageWidget::onTouchModeChanged(int state)
 {
+    // Show/hide the gestures warning as needed, since its UI gets enabled and
+    // disabled dynamically when touch is turned on or off
+    if (state == 0) {
+        ui->gesturesWarning->animatedHide();
+    } else if (ui->gesturesCheckBox->isChecked()) {
+        ui->gesturesWarning->animatedShow();
+    }
+
     setTouchSupportEnabled(state == Qt::Checked);
     onProfileChanged();
 }
 
-
 void TouchPageWidget::onTrackingModeAbsolute(bool activated)
 {
     if (!activated) {
@@ -387,4 +401,11 @@ void TouchPageWidget::setupUi()
     ui->trackingWarningIcon->setPixmap(QIcon::fromTheme(QLatin1String("dialog-warning")).pixmap(QSize(16,16)));
     ui->trackingWarningIcon->setVisible(false);
     ui->trackingWarningLabel->setVisible(false);
+
+    // Set this here instead of in the UI file because the string property in
+    // the UI file will strip out HTML tags and break our link
+    const QString bugReportURL = QStringLiteral("https://bugreports.qt.io/browse/QTBUG-84756");
+    ui->gesturesWarning->setText(i18n("Enabling gestures here is known to break touch input using a touchscreen. See <a href=\"%1\">%2</a> for details.", bugReportURL, bugReportURL));
+    // Open the link when the user clicks on it
+    connect(ui->gesturesWarning, &KMessageWidget::linkActivated, this, [](const QString &str) { QDesktopServices::openUrl(QUrl(str)); } );
 }
diff --git a/src/kcmodule/touchpagewidget.ui b/src/kcmodule/touchpagewidget.ui
index 9b5f8df..19d9537 100644
--- a/src/kcmodule/touchpagewidget.ui
+++ b/src/kcmodule/touchpagewidget.ui
@@ -11,6 +11,24 @@
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout_9">
+   <item>
+    <widget class="KMessageWidget" name="gesturesWarning">
+     <property name="visible">
+      <bool>false</bool>
+     </property>
+     <property name="closeButtonVisible">
+      <bool>false</bool>
+     </property>
+     <!-- Text is set in the .cpp file  because it has a link in it and HTML
+     markup doesn't get preserved when we insert it here -->
+     <property name="wordWrap">
+      <bool>true</bool>
+     </property>
+     <property name="messageType">
+      <enum>KMessageWidget::Warning</enum>
+     </property>
+    </widget>
+   </item>
    <item>
     <widget class="QCheckBox" name="touchCheckBox">
      <property name="toolTip">
@@ -362,6 +380,14 @@
    </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KMessageWidget</class>
+   <extends>QFrame</extends>
+   <header>kmessagewidget.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
  <resources/>
  <connections>
   <connection>
-- 
GitLab


From a35c2fc5b5e1561e4708fa01925806015082344b Mon Sep 17 00:00:00 2001
From: Nate Graham <nate@kde.org>
Date: Fri, 6 Aug 2021 09:14:14 -0600
Subject: [PATCH 2/3] Remove link; simplify message

---
 src/kcmodule/touchpagewidget.cpp | 8 --------
 src/kcmodule/touchpagewidget.ui  | 5 +++--
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/src/kcmodule/touchpagewidget.cpp b/src/kcmodule/touchpagewidget.cpp
index f2facb0..880b067 100644
--- a/src/kcmodule/touchpagewidget.cpp
+++ b/src/kcmodule/touchpagewidget.cpp
@@ -28,7 +28,6 @@
 #include "tabletareaselectiondialog.h"
 #include "x11wacom.h"
 
-#include <QDesktopServices>
 #include <QRegExp>
 #include <QStringList>
 
@@ -401,11 +400,4 @@ void TouchPageWidget::setupUi()
     ui->trackingWarningIcon->setPixmap(QIcon::fromTheme(QLatin1String("dialog-warning")).pixmap(QSize(16,16)));
     ui->trackingWarningIcon->setVisible(false);
     ui->trackingWarningLabel->setVisible(false);
-
-    // Set this here instead of in the UI file because the string property in
-    // the UI file will strip out HTML tags and break our link
-    const QString bugReportURL = QStringLiteral("https://bugreports.qt.io/browse/QTBUG-84756");
-    ui->gesturesWarning->setText(i18n("Enabling gestures here is known to break touch input using a touchscreen. See <a href=\"%1\">%2</a> for details.", bugReportURL, bugReportURL));
-    // Open the link when the user clicks on it
-    connect(ui->gesturesWarning, &KMessageWidget::linkActivated, this, [](const QString &str) { QDesktopServices::openUrl(QUrl(str)); } );
 }
diff --git a/src/kcmodule/touchpagewidget.ui b/src/kcmodule/touchpagewidget.ui
index 19d9537..9d79a88 100644
--- a/src/kcmodule/touchpagewidget.ui
+++ b/src/kcmodule/touchpagewidget.ui
@@ -13,14 +13,15 @@
   <layout class="QVBoxLayout" name="verticalLayout_9">
    <item>
     <widget class="KMessageWidget" name="gesturesWarning">
+     <property name="text">
+      <string>Enabling gestures may break touch input using a touchscreen.</string>
+     </property>
      <property name="visible">
       <bool>false</bool>
      </property>
      <property name="closeButtonVisible">
       <bool>false</bool>
      </property>
-     <!-- Text is set in the .cpp file  because it has a link in it and HTML
-     markup doesn't get preserved when we insert it here -->
      <property name="wordWrap">
       <bool>true</bool>
      </property>
-- 
GitLab


From be18f8c9e1e70690e0056a6bce297c71fcca62be Mon Sep 17 00:00:00 2001
From: David Edmundson <kde@davidedmundson.co.uk>
Date: Fri, 6 Aug 2021 16:21:51 +0000
Subject: [PATCH 3/3] Apply 2 suggestion(s) to 1 file(s)

---
 src/kcmodule/touchpagewidget.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/kcmodule/touchpagewidget.cpp b/src/kcmodule/touchpagewidget.cpp
index 880b067..8801bd0 100644
--- a/src/kcmodule/touchpagewidget.cpp
+++ b/src/kcmodule/touchpagewidget.cpp
@@ -115,7 +115,7 @@ void TouchPageWidget::saveToProfile(ProfileManagementInterface &profileManagemen
 
 void TouchPageWidget::onGesturesModeChanged(int state)
 {
-    if (state == 0) {
+    if (state == Qt::Unchecked) {
         ui->gesturesWarning->animatedHide();
     } else {
         ui->gesturesWarning->animatedShow();
@@ -156,7 +156,7 @@ void TouchPageWidget::onTouchModeChanged(int state)
 {
     // Show/hide the gestures warning as needed, since its UI gets enabled and
     // disabled dynamically when touch is turned on or off
-    if (state == 0) {
+    if (state == Qt::Unchecked) {
         ui->gesturesWarning->animatedHide();
     } else if (ui->gesturesCheckBox->isChecked()) {
         ui->gesturesWarning->animatedShow();
-- 
GitLab

