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

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