After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 618062 - linearView: Cancel workspace scrolling when the user stops dragging
linearView: Cancel workspace scrolling when the user stops dragging
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2010-05-07 22:07 UTC by drago01
Modified: 2010-05-10 19:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
linearView: Cancel workspace scrolling when the user stops dragging (2.50 KB, patch)
2010-05-07 22:08 UTC, drago01
needs-work Details | Review
linearView: Cancel workspace scrolling when the user stops dragging (2.80 KB, patch)
2010-05-10 17:44 UTC, drago01
committed Details | Review

Description drago01 2010-05-07 22:07:40 UTC
We should provide a way to cancel the drag action, see patch.
Comment 1 drago01 2010-05-07 22:08:02 UTC
Created attachment 160544 [details] [review]
linearView: Cancel workspace scrolling when the user stops dragging

Currently there is no way for the user to cancel a workspace drag action,
which means the user has to complete the drag action before and move back
to the other workspace manually afterwards.

So cancel the drag action when the user stops.
Comment 2 Owen Taylor 2010-05-10 17:09:28 UTC
Review of attachment 160544 [details] [review]:

Hmm, in testing this simple approach does seem to be successful in distinguish "throw" from "not throw" - it feels good to me. (Testing with a mouse - don't know if it would be different on a touch device.)

One thing that does need fixing is if the user drags over more than half-way over to the next workspace before releasing - then releasing at stop should go to that workspace rather than cancelling.

::: js/ui/workspacesView.js
@@ +835,3 @@
 
+                // switch workspaces according to the drag direction, snap back when the user stops
+                if (this._lastMotion > 0 && this._lastMotion > global.get_current_time() - 2) {

What's the significance of the 2 (milliseconds) here? Needs a comment

I'd use event.get_time() rather than global.get_current_time() - it's clearer that you are comparing the timestamp of the button release event to the timestamp of the last motion event.

@@ +862,3 @@
                 this._scroll.adjustment.value += (dx / primary.width);
                 this._dragX = stageX;
+                this._lastMotion = global.get_current_time();

Again, use event.get_time()
Comment 3 drago01 2010-05-10 17:44:25 UTC
Created attachment 160748 [details] [review]
linearView: Cancel workspace scrolling when the user stops dragging

*) Don't stop dragging more than half-way into the next workspace but switch to it
*) Use event.get_time() rather than global.get_current_time()
*) Add comment explaining the magic value "2"
Comment 4 Owen Taylor 2010-05-10 18:57:00 UTC
Review of attachment 160748 [details] [review]:

OK to commit with the fixes noted below.

::: js/ui/workspacesView.js
@@ +833,3 @@
                 let activate = this._dragIndex;
                 let last = global.screen.n_workspaces - 1;
+                let noStop = Math.abs(activate - this._scroll.adjustment.value) > 0.5;

Needs a comment - e.g.

 // If the user has moved more than half a workspace, we want to "settle"
 // to the new workspace even if the user stops dragging rather "throws"
 // by releasing during the drag.

@@ +837,3 @@
+                // switch workspaces according to the drag direction, snap back when the user stops
+                // we use a small delay of 2 here to detect "quick throw" actions; the value has been
+                // found by try and error

This doesn't really get to the fact that 2ms is absolutely tiny on the scale of actions - it's not really a "delay". Maybe something like:

 // We detect if the user is stopped by comparing the timestamp of the button
 // release with the timestamp of the last motion. Experimentally, a difference
 // of 0 or 1 millisecond indicates that the mouse is in motion, a larger
 // difference indicates that the mouse is stopped.

@@ +865,3 @@
                 this._scroll.adjustment.value += (dx / primary.width);
                 this._dragX = stageX;
+                this._lastMotion = event.get_time();

Better as _lastMotionTime
Comment 5 drago01 2010-05-10 19:29:29 UTC
Attachment 160748 [details] pushed as 44c2027 - linearView: Cancel workspace scrolling when the user stops dragging, with the changes from the review.