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
This commit is contained in:
parent
7e5274619a
commit
0b05b7a527
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user