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