Blame SOURCES/0001-fileItem-Ignore-double-click-distance-clicking-on-it.patch

d2679a
From f78b19068654412ca9e73a229e1537d080759c47 Mon Sep 17 00:00:00 2001
d2679a
From: Carlos Garnacho <carlosg@gnome.org>
d2679a
Date: Wed, 27 Jan 2021 16:55:10 +0100
d2679a
Subject: [PATCH] fileItem: Ignore double click distance clicking on items
d2679a
d2679a
Imitate the behavior of Nautilus canvas WRT double clicks being
d2679a
handled on all of the icon(s) without accounting for the double
d2679a
click distance. As the extension does already lean on Nautilus
d2679a
look & feel, it seems to make sense doing this.
d2679a
d2679a
This is not as crucial for mice as it is for touchscreens, where
d2679a
the default 5px limit may be a bit on the short side depending
d2679a
on device sensitivity.
d2679a
---
d2679a
 extensions/desktop-icons/fileItem.js | 26 +++++++++++++++++++++++---
d2679a
 1 file changed, 23 insertions(+), 3 deletions(-)
d2679a
d2679a
diff --git a/extensions/desktop-icons/fileItem.js b/extensions/desktop-icons/fileItem.js
d2679a
index d6d43c9..5d3195f 100644
d2679a
--- a/extensions/desktop-icons/fileItem.js
d2679a
+++ b/extensions/desktop-icons/fileItem.js
d2679a
@@ -65,6 +65,9 @@ var FileItem = class {
d2679a
         this._setMetadataCancellable = null;
d2679a
         this._queryFileInfoCancellable = null;
d2679a
         this._isSpecial = this._fileExtra != Prefs.FileType.NONE;
d2679a
+        this._lastClickTime = 0;
d2679a
+        this._lastClickButton = 0;
d2679a
+        this._clickCount = 0;
d2679a
 
d2679a
         this._file = file;
d2679a
 
d2679a
@@ -642,7 +645,24 @@ var FileItem = class {
d2679a
         DesktopIconsUtil.launchTerminal(this.file.get_path());
d2679a
     }
d2679a
 
d2679a
+    _updateClickState(event) {
d2679a
+        let settings = Clutter.Settings.get_default();
d2679a
+        if ((event.get_button() == this._lastClickButton) &&
d2679a
+            ((event.get_time() - this._lastClickTime) < settings.double_click_time))
d2679a
+            this._clickCount++;
d2679a
+        else
d2679a
+            this._clickCount = 1;
d2679a
+
d2679a
+        this._lastClickTime = event.get_time();
d2679a
+        this._lastClickButton = event.get_button();
d2679a
+    }
d2679a
+
d2679a
+    _getClickCount() {
d2679a
+        return this._clickCount;
d2679a
+    }
d2679a
+
d2679a
     _onPressButton(actor, event) {
d2679a
+        this._updateClickState(event);
d2679a
         let button = event.get_button();
d2679a
         if (button == 3) {
d2679a
             if (!this.isSelected)
d2679a
@@ -661,7 +681,7 @@ var FileItem = class {
d2679a
                 this._actionTrash.setSensitive(!specialFilesSelected);
d2679a
             return Clutter.EVENT_STOP;
d2679a
         } else if (button == 1) {
d2679a
-            if (event.get_click_count() == 1) {
d2679a
+            if (this._getClickCount() == 1) {
d2679a
                 let [x, y] = event.get_coords();
d2679a
                 this._primaryButtonPressed = true;
d2679a
                 this._buttonPressInitialX = x;
d2679a
@@ -710,12 +730,12 @@ var FileItem = class {
d2679a
                 this._primaryButtonPressed = false;
d2679a
                 let shiftPressed = !!(event.get_state() & Clutter.ModifierType.SHIFT_MASK);
d2679a
                 let controlPressed = !!(event.get_state() & Clutter.ModifierType.CONTROL_MASK);
d2679a
-                if ((event.get_click_count() == 1) && Prefs.CLICK_POLICY_SINGLE && !shiftPressed && !controlPressed)
d2679a
+                if ((this._getClickCount() == 1) && Prefs.CLICK_POLICY_SINGLE && !shiftPressed && !controlPressed)
d2679a
                     this.doOpen();
d2679a
                 this.emit('selected', shiftPressed || controlPressed, false, true);
d2679a
                 return Clutter.EVENT_STOP;
d2679a
             }
d2679a
-            if ((event.get_click_count() == 2) && (!Prefs.CLICK_POLICY_SINGLE))
d2679a
+            if ((this._getClickCount() == 2) && (!Prefs.CLICK_POLICY_SINGLE))
d2679a
                 this.doOpen();
d2679a
         }
d2679a
         return Clutter.EVENT_PROPAGATE;
d2679a
-- 
d2679a
2.29.2
d2679a