[gnome-shell] windowManager: Redo WorkspaceSwitchAction to be a Clutter.SwipeAction
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] windowManager: Redo WorkspaceSwitchAction to be a Clutter.SwipeAction
- Date: Tue, 26 May 2015 17:07:39 +0000 (UTC)
commit 03dbb0f9312e7d08e965243beb9cc5a9ced7ea4d
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri May 22 19:05:10 2015 +0200
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
js/ui/windowManager.js | 48 ++++++++++++++++++++----------------------------
1 files changed, 20 insertions(+), 28 deletions(-)
---
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index 01d5107..ecf6051 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -480,50 +480,42 @@ const TilePreview = new Lang.Class({
const WorkspaceSwitchAction = new Lang.Class({
Name: 'WorkspaceSwitchAction',
- Extends: Clutter.GestureAction,
+ Extends: Clutter.SwipeAction,
_init : function() {
+ const MOTION_THRESHOLD = 50;
+
this.parent();
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() {
this.cancel();
}));
},
- vfunc_gesture_prepare : function(action, actor) {
+ vfunc_gesture_prepare : function(actor) {
let allowedModes = Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW;
- return this.get_n_current_points() == this.get_n_touch_points() &&
- (allowedModes & Main.actionMode);
- },
- vfunc_gesture_end : function(action, actor) {
- const MOTION_THRESHOLD = 50;
+ if (!this.parent(actor))
+ return false;
- // Just check one touchpoint here
- let [startX, startY] = this.get_press_coords(0);
- let [x, y] = this.get_motion_coords(0);
- let offsetX = x - startX;
- let offsetY = y - startY;
- let direction;
+ return (allowedModes & Main.actionMode);
+ },
- if (Math.abs(offsetX) < MOTION_THRESHOLD &&
- Math.abs(offsetY) < MOTION_THRESHOLD)
- return;
+ vfunc_swept : function(actor, direction) {
+ let dir;
- 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;
- }
+ if (direction & Clutter.SwipeDirection.UP)
+ dir = Meta.MotionDirection.DOWN;
+ else if (direction & Clutter.SwipeDirection.DOWN)
+ dir = Meta.MotionDirection.UP;
+ else if (direction & Clutter.SwipeDirection.LEFT)
+ dir = Meta.MotionDirection.RIGHT;
+ else if (direction & Clutter.SwipeDirection.RIGHT)
+ dir = Meta.MotionDirection.LEFT;
- this.emit('activated', direction);
+ this.emit('activated', dir);
}
});
Signals.addSignalMethods(WorkspaceSwitchAction.prototype);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]