[gnome-shell/wip/carlosg/app-grid-gestures: 3/5] dnd: Add timeoutThreshold setting
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/app-grid-gestures: 3/5] dnd: Add timeoutThreshold setting
- Date: Thu, 18 Mar 2021 19:50:51 +0000 (UTC)
commit 5906de7bd4f349edbec3e1fde44186ad79134d8d
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Mar 18 18:58:12 2021 +0100
dnd: Add timeoutThreshold setting
This setting (by default, 0) sets a time threshold in order to allow
DnD. If the drag is shorter than this threshold, DnD will be cancelled,
and event handling left to the next handlers.
js/ui/dnd.js | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/dnd.js b/js/ui/dnd.js
index 0af1e7ecc7..51cdc3168f 100644
--- a/js/ui/dnd.js
+++ b/js/ui/dnd.js
@@ -72,6 +72,7 @@ function removeDragMonitor(monitor) {
var _Draggable = class _Draggable {
constructor(actor, params) {
params = Params.parse(params, { manualMode: false,
+ timeoutThreshold: 0,
restoreOnSuccess: false,
dragActorMaxSize: undefined,
dragActorOpacity: undefined });
@@ -99,6 +100,7 @@ var _Draggable = class _Draggable {
this._restoreOnSuccess = params.restoreOnSuccess;
this._dragActorMaxSize = params.dragActorMaxSize;
this._dragActorOpacity = params.dragActorOpacity;
+ this._dragTimeoutThreshold = params.timeoutThreshold;
this._buttonDown = false; // The mouse button has been pressed and has not yet been released.
this._animationInProgress = false; // The drag is over and the item is in the process of animating
to its original position (snapping back or reverting).
@@ -118,6 +120,8 @@ var _Draggable = class _Draggable {
let [stageX, stageY] = event.get_coords();
this._dragStartX = stageX;
this._dragStartY = stageY;
+ this._dragStartTime = event.get_time();
+ this._dragThresholdIgnored = false;
return Clutter.EVENT_PROPAGATE;
}
@@ -139,6 +143,8 @@ var _Draggable = class _Draggable {
this._buttonDown = true;
this._grabActor(event.get_device(), event.get_event_sequence());
+ this._dragStartTime = event.get_time();
+ this._dragThresholdIgnored = false;
let [stageX, stageY] = event.get_coords();
this._dragStartX = stageX;
@@ -478,14 +484,23 @@ var _Draggable = class _Draggable {
_maybeStartDrag(event) {
let [stageX, stageY] = event.get_coords();
+ if (this._dragThresholdIgnored)
+ return Clutter.EVENT_PROPAGATE;
+
// See if the user has moved the mouse enough to trigger a drag
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
let threshold = St.Settings.get().drag_threshold * scaleFactor;
if (!currentDraggable &&
(Math.abs(stageX - this._dragStartX) > threshold ||
Math.abs(stageY - this._dragStartY) > threshold)) {
- this.startDrag(stageX, stageY, event.get_time(), this._touchSequence, event.get_device());
- this._updateDragPosition(event);
+ if ((event.get_time() - this._dragStartTime) > this._dragTimeoutThreshold) {
+ this.startDrag(stageX, stageY, event.get_time(), this._touchSequence, event.get_device());
+ this._updateDragPosition(event);
+ } else {
+ this._dragThresholdIgnored = true;
+ this._ungrabActor();
+ return Clutter.EVENT_PROPAGATE;
+ }
}
return true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]