swipe-scrolling: Take threshold into account during drag
On button-release, a threshold is used to determine if the gesture should be considered a click and thus ignored. While the drag is active though, the controlled actor is dragged immediately. As a result, dragging by a tiny amount does not trigger a snap back when the action is interpreted as a click. As a fix, do not update the dragged actor's position until the same threshold is passed. https://bugzilla.gnome.org/show_bug.cgi?id=640494
This commit is contained in:
parent
b9e1d917da
commit
eb8fc738af
@ -276,6 +276,8 @@ Overview.prototype = {
|
|||||||
|
|
||||||
_onCapturedEvent: function(actor, event) {
|
_onCapturedEvent: function(actor, event) {
|
||||||
let stageX, stageY;
|
let stageX, stageY;
|
||||||
|
let threshold = Gtk.Settings.get_default().gtk_dnd_drag_threshold;
|
||||||
|
|
||||||
switch(event.type()) {
|
switch(event.type()) {
|
||||||
case Clutter.EventType.BUTTON_RELEASE:
|
case Clutter.EventType.BUTTON_RELEASE:
|
||||||
[stageX, stageY] = event.get_coords();
|
[stageX, stageY] = event.get_coords();
|
||||||
@ -328,7 +330,6 @@ Overview.prototype = {
|
|||||||
|
|
||||||
// See if the user has moved the mouse enough to trigger
|
// See if the user has moved the mouse enough to trigger
|
||||||
// a drag
|
// a drag
|
||||||
let threshold = Gtk.Settings.get_default().gtk_dnd_drag_threshold;
|
|
||||||
if (Math.abs(stageX - this._dragStartX) < threshold &&
|
if (Math.abs(stageX - this._dragStartX) < threshold &&
|
||||||
Math.abs(stageY - this._dragStartY) < threshold) {
|
Math.abs(stageY - this._dragStartY) < threshold) {
|
||||||
// no motion? It's a click!
|
// no motion? It's a click!
|
||||||
@ -371,6 +372,16 @@ Overview.prototype = {
|
|||||||
let dy = this._dragY - stageY;
|
let dy = this._dragY - stageY;
|
||||||
let primary = global.get_primary_monitor();
|
let primary = global.get_primary_monitor();
|
||||||
|
|
||||||
|
this._dragX = stageX;
|
||||||
|
this._dragY = stageY;
|
||||||
|
this._lastMotionTime = event.get_time();
|
||||||
|
|
||||||
|
// See if the user has moved the mouse enough to trigger
|
||||||
|
// a drag
|
||||||
|
if (Math.abs(stageX - this._dragStartX) < threshold &&
|
||||||
|
Math.abs(stageY - this._dragStartY) < threshold)
|
||||||
|
return true;
|
||||||
|
|
||||||
if (this._scrollDirection == SwipeScrollDirection.HORIZONTAL) {
|
if (this._scrollDirection == SwipeScrollDirection.HORIZONTAL) {
|
||||||
if (St.Widget.get_default_direction() == St.TextDirection.RTL)
|
if (St.Widget.get_default_direction() == St.TextDirection.RTL)
|
||||||
this._scrollAdjustment.value -= (dx / primary.width) * this._scrollAdjustment.page_size;
|
this._scrollAdjustment.value -= (dx / primary.width) * this._scrollAdjustment.page_size;
|
||||||
@ -380,10 +391,6 @@ Overview.prototype = {
|
|||||||
this._scrollAdjustment.value += (dy / primary.height) * this._scrollAdjustment.page_size;
|
this._scrollAdjustment.value += (dy / primary.height) * this._scrollAdjustment.page_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._dragX = stageX;
|
|
||||||
this._dragY = stageY;
|
|
||||||
this._lastMotionTime = event.get_time();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Block enter/leave events to avoid prelights
|
// Block enter/leave events to avoid prelights
|
||||||
|
Loading…
Reference in New Issue
Block a user