[gnome-shell/wip/gestures: 7/10] Add workspaceSwitchAction Clutter.GestureAction
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/gestures: 7/10] Add workspaceSwitchAction Clutter.GestureAction
- Date: Fri, 27 Jun 2014 22:05:25 +0000 (UTC)
commit a50a463eb388c186e641ad506f49ab7f8474bee6
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Jun 25 18:12:41 2014 +0200
Add workspaceSwitchAction Clutter.GestureAction
This gesture implements 4-finger drag, that will be used for workspace
switching.
js/js-resources.gresource.xml | 1 +
js/ui/workspaceSwitchAction.js | 52 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml
index 3515ba8..3fed6a4 100644
--- a/js/js-resources.gresource.xml
+++ b/js/js-resources.gresource.xml
@@ -91,6 +91,7 @@
<file>ui/windowMenu.js</file>
<file>ui/windowManager.js</file>
<file>ui/workspace.js</file>
+ <file>ui/workspaceSwitchAction.js</file>
<file>ui/workspaceSwitcherPopup.js</file>
<file>ui/workspaceThumbnail.js</file>
<file>ui/workspacesView.js</file>
diff --git a/js/ui/workspaceSwitchAction.js b/js/ui/workspaceSwitchAction.js
new file mode 100644
index 0000000..3cd509e
--- /dev/null
+++ b/js/ui/workspaceSwitchAction.js
@@ -0,0 +1,52 @@
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+
+const Signals = imports.signals;
+const Lang = imports.lang;
+const Meta = imports.gi.Meta;
+const Clutter = imports.gi.Clutter;
+
+let MOTION_THRESHOLD = 50;
+
+const WorkspaceSwitchAction = new Lang.Class({
+ Name: 'WorkspaceSwitchAction',
+ Extends: Clutter.GestureAction,
+
+ _init : function() {
+ this.parent();
+ this.set_n_touch_points (4);
+ global.display.connect('grab-op-begin', Lang.bind(this, this.cancel));
+ global.display.connect('grab-op-end', Lang.bind(this, this.cancel));
+ },
+
+ vfunc_gesture_prepare : function(action, actor) {
+ return this.get_n_current_points() == this.get_n_touch_points();
+ },
+
+ vfunc_gesture_end : function(action, actor) {
+ // 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;
+
+ if (Math.abs(offsetX) < MOTION_THRESHOLD &&
+ 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]