GNOME Bugzilla – Bug 618062
linearView: Cancel workspace scrolling when the user stops dragging
Last modified: 2010-05-10 19:29:32 UTC
We should provide a way to cancel the drag action, see patch.
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.
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()
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"
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
Attachment 160748 [details] pushed as 44c2027 - linearView: Cancel workspace scrolling when the user stops dragging, with the changes from the review.