9062cd
From 0d9210e9c19c1bd9535ffb75b4834c2ccd8db6c2 Mon Sep 17 00:00:00 2001
9062cd
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
9062cd
Date: Thu, 21 Apr 2022 16:34:50 +0200
9062cd
Subject: [PATCH 1/2] window-list: Fix primary button action on touch
9062cd
9062cd
If a click event was triggered via touch rather than a pointer
9062cd
device, the button parameter is 0 rather than a mouse button
9062cd
number.
9062cd
9062cd
Account for that to make sure that touch events are not misinterpreted
9062cd
as right clicks.
9062cd
9062cd
https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/issues/146
9062cd
9062cd
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/233>
9062cd
---
9062cd
 extensions/window-list/extension.js | 4 ++--
9062cd
 1 file changed, 2 insertions(+), 2 deletions(-)
9062cd
9062cd
diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js
9062cd
index e122cf5f..43885378 100644
9062cd
--- a/extensions/window-list/extension.js
9062cd
+++ b/extensions/window-list/extension.js
9062cd
@@ -381,7 +381,7 @@ class WindowButton extends BaseButton {
9062cd
             return;
9062cd
         }
9062cd
 
9062cd
-        if (button === 1)
9062cd
+        if (!button || button === 1)
9062cd
             _minimizeOrActivateWindow(this.metaWindow);
9062cd
         else
9062cd
             _openMenu(this._contextMenu);
9062cd
@@ -623,7 +623,7 @@ class AppButton extends BaseButton {
9062cd
         if (contextMenuWasOpen)
9062cd
             this._contextMenu.close();
9062cd
 
9062cd
-        if (button === 1) {
9062cd
+        if (!button || button === 1) {
9062cd
             if (menuWasOpen)
9062cd
                 return;
9062cd
 
9062cd
-- 
9062cd
2.36.1
9062cd
9062cd
9062cd
From b080bb7ee88d0e5b35dc4a967d2e44eab7921b6f Mon Sep 17 00:00:00 2001
9062cd
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
9062cd
Date: Thu, 5 May 2022 20:55:20 +0200
9062cd
Subject: [PATCH 2/2] window-list: Open menu on long press
9062cd
9062cd
Right-click isn't available on touch, so implement long-press as
9062cd
an alternative.
9062cd
9062cd
https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/issues/146
9062cd
9062cd
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/233>
9062cd
---
9062cd
 extensions/window-list/extension.js | 42 +++++++++++++++++++++++++++++
9062cd
 1 file changed, 42 insertions(+)
9062cd
9062cd
diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js
9062cd
index 43885378..3d1cd053 100644
9062cd
--- a/extensions/window-list/extension.js
9062cd
+++ b/extensions/window-list/extension.js
9062cd
@@ -266,6 +266,48 @@ const BaseButton = GObject.registerClass({
9062cd
         this._updateVisibility();
9062cd
     }
9062cd
 
9062cd
+    _setLongPressTimeout() {
9062cd
+        if (this._longPressTimeoutId)
9062cd
+            return;
9062cd
+
9062cd
+        const { longPressDuration } = Clutter.Settings.get_default();
9062cd
+        this._longPressTimeoutId =
9062cd
+            GLib.timeout_add(GLib.PRIORITY_DEFAULT, longPressDuration, () => {
9062cd
+                delete this._longPressTimeoutId;
9062cd
+
9062cd
+                if (this._canOpenPopupMenu() && !this._contextMenu.isOpen)
9062cd
+                    _openMenu(this._contextMenu);
9062cd
+                return GLib.SOURCE_REMOVE;
9062cd
+            });
9062cd
+    }
9062cd
+
9062cd
+    _removeLongPressTimeout() {
9062cd
+        if (!this._longPressTimeoutId)
9062cd
+            return;
9062cd
+        GLib.source_remove(this._longPressTimeoutId);
9062cd
+        delete this._longPressTimeoutId;
9062cd
+    }
9062cd
+
9062cd
+    vfunc_button_press_event(buttonEvent) {
9062cd
+        if (buttonEvent.button === 1)
9062cd
+            this._setLongPressTimeout();
9062cd
+        return super.vfunc_button_press_event(buttonEvent);
9062cd
+    }
9062cd
+
9062cd
+    vfunc_button_release_event(buttonEvent) {
9062cd
+        this._removeLongPressTimeout();
9062cd
+
9062cd
+        return super.vfunc_button_release_event(buttonEvent);
9062cd
+    }
9062cd
+
9062cd
+    vfunc_touch_event(touchEvent) {
9062cd
+        if (touchEvent.type === Clutter.EventType.TOUCH_BEGIN)
9062cd
+            this._setLongPressTimeout();
9062cd
+        else if (touchEvent.type === Clutter.EventType.TOUCH_END)
9062cd
+            this._removeLongPressTimeout();
9062cd
+        return super.vfunc_touch_event(touchEvent);
9062cd
+    }
9062cd
+
9062cd
     activate() {
9062cd
         if (this.active)
9062cd
             return;
9062cd
-- 
9062cd
2.36.1
9062cd