windowManager: Redo WorkspaceSwitchAction to be a Clutter.SwipeAction
Just reuse this gesture rather than implementing edge detection ourselves. As a plus, we might get touchpad swipe support when Clutter handles it. https://bugzilla.gnome.org/show_bug.cgi?id=749742
This commit is contained in:
parent
249619fabd
commit
03dbb0f931
@ -480,50 +480,42 @@ const TilePreview = new Lang.Class({
|
|||||||
|
|
||||||
const WorkspaceSwitchAction = new Lang.Class({
|
const WorkspaceSwitchAction = new Lang.Class({
|
||||||
Name: 'WorkspaceSwitchAction',
|
Name: 'WorkspaceSwitchAction',
|
||||||
Extends: Clutter.GestureAction,
|
Extends: Clutter.SwipeAction,
|
||||||
|
|
||||||
_init : function() {
|
_init : function() {
|
||||||
|
const MOTION_THRESHOLD = 50;
|
||||||
|
|
||||||
this.parent();
|
this.parent();
|
||||||
this.set_n_touch_points(4);
|
this.set_n_touch_points(4);
|
||||||
|
this.set_threshold_trigger_distance(MOTION_THRESHOLD, MOTION_THRESHOLD);
|
||||||
|
|
||||||
global.display.connect('grab-op-begin', Lang.bind(this, function() {
|
global.display.connect('grab-op-begin', Lang.bind(this, function() {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
vfunc_gesture_prepare : function(action, actor) {
|
vfunc_gesture_prepare : function(actor) {
|
||||||
let allowedModes = Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW;
|
let allowedModes = Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW;
|
||||||
return this.get_n_current_points() == this.get_n_touch_points() &&
|
|
||||||
(allowedModes & Main.actionMode);
|
if (!this.parent(actor))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return (allowedModes & Main.actionMode);
|
||||||
},
|
},
|
||||||
|
|
||||||
vfunc_gesture_end : function(action, actor) {
|
vfunc_swept : function(actor, direction) {
|
||||||
const MOTION_THRESHOLD = 50;
|
let dir;
|
||||||
|
|
||||||
// Just check one touchpoint here
|
if (direction & Clutter.SwipeDirection.UP)
|
||||||
let [startX, startY] = this.get_press_coords(0);
|
dir = Meta.MotionDirection.DOWN;
|
||||||
let [x, y] = this.get_motion_coords(0);
|
else if (direction & Clutter.SwipeDirection.DOWN)
|
||||||
let offsetX = x - startX;
|
dir = Meta.MotionDirection.UP;
|
||||||
let offsetY = y - startY;
|
else if (direction & Clutter.SwipeDirection.LEFT)
|
||||||
let direction;
|
dir = Meta.MotionDirection.RIGHT;
|
||||||
|
else if (direction & Clutter.SwipeDirection.RIGHT)
|
||||||
|
dir = Meta.MotionDirection.LEFT;
|
||||||
|
|
||||||
if (Math.abs(offsetX) < MOTION_THRESHOLD &&
|
this.emit('activated', dir);
|
||||||
Math.abs(offsetY) < MOTION_THRESHOLD)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (Math.abs(offsetY) > Math.abs(offsetX)) {
|
|
||||||
if (offsetY > 0)
|
|
||||||
direction = Meta.MotionDirection.UP;
|
|
||||||
else
|
|
||||||
direction = Meta.MotionDirection.DOWN;
|
|
||||||
} else {
|
|
||||||
if (offsetX > 0)
|
|
||||||
direction = Meta.MotionDirection.LEFT;
|
|
||||||
else
|
|
||||||
direction = Meta.MotionDirection.RIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.emit('activated', direction);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Signals.addSignalMethods(WorkspaceSwitchAction.prototype);
|
Signals.addSignalMethods(WorkspaceSwitchAction.prototype);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user