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