[gnome-shell] viewSelection: Handle touchpad 3-finger pinches
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] viewSelection: Handle touchpad 3-finger pinches
- Date: Fri, 4 Nov 2016 15:37:07 +0000 (UTC)
commit 0b05b7a52748ea9aae3e1063382e3b2c1152263b
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Apr 15 16:48:25 2016 +0100
viewSelection: Handle touchpad 3-finger pinches
In order to show the overview, just like touchscreens do.
https://bugzilla.gnome.org/show_bug.cgi?id=765937
js/ui/viewSelector.js | 36 ++++++++++++++++++++++++++++++++----
1 files changed, 32 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 412e9d6..182d344 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -23,6 +23,7 @@ const EdgeDragAction = imports.ui.edgeDragAction;
const IconGrid = imports.ui.iconGrid;
const SHELL_KEYBINDINGS_SCHEMA = 'org.gnome.shell.keybindings';
+const PINCH_GESTURE_THRESHOLD = 0.7;
const ViewPage = {
WINDOWS: 1,
@@ -51,6 +52,28 @@ function getTermsForSearchString(searchString) {
return terms;
}
+const TouchpadShowOverviewAction = new Lang.Class({
+ Name: 'TouchpadShowOverviewAction',
+
+ _init: function(actor) {
+ actor.connect('captured-event', Lang.bind(this, this._handleEvent));
+ },
+
+ _handleEvent: function(actor, event) {
+ if (event.type() != Clutter.EventType.TOUCHPAD_PINCH)
+ return Clutter.EVENT_PROPAGATE;
+
+ if (event.get_touchpad_gesture_finger_count() != 3)
+ return Clutter.EVENT_PROPAGATE;
+
+ if (event.get_gesture_phase() == Clutter.TouchpadGesturePhase.END)
+ this.emit('activated', event.get_gesture_pinch_scale ());
+
+ return Clutter.EVENT_STOP;
+ }
+});
+Signals.addSignalMethods(TouchpadShowOverviewAction.prototype);
+
const ShowOverviewAction = new Lang.Class({
Name: 'ShowOverviewAction',
Extends: Clutter.GestureAction,
@@ -230,11 +253,16 @@ const ViewSelector = new Lang.Class({
global.stage.add_action(gesture);
gesture = new ShowOverviewAction();
- gesture.connect('activated', Lang.bind(this, function(action, areaDiff) {
- if (areaDiff < 0.7)
- Main.overview.show();
- }));
+ gesture.connect('activated', Lang.bind(this, this._pinchGestureActivated));
global.stage.add_action(gesture);
+
+ gesture = new TouchpadShowOverviewAction(global.stage);
+ gesture.connect('activated', Lang.bind(this, this._pinchGestureActivated));
+ },
+
+ _pinchGestureActivated: function(action, scale) {
+ if (scale < PINCH_GESTURE_THRESHOLD)
+ Main.overview.show();
},
_toggleAppsPage: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]