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

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