Compare commits
2 Commits
citadel
...
wip/garnac
Author | SHA1 | Date | |
---|---|---|---|
|
708a198abf | ||
|
8270d84b80 |
@ -477,6 +477,64 @@ const TilePreview = new Lang.Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const TouchpadWorkspaceSwitchAction = new Lang.Class({
|
||||||
|
Name: 'TouchpadWorkspaceSwitchAction',
|
||||||
|
|
||||||
|
_checkActivated: function() {
|
||||||
|
const MOTION_THRESHOLD = 50;
|
||||||
|
let allowedModes = Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW;
|
||||||
|
let dir;
|
||||||
|
|
||||||
|
if ((allowedModes & Main.actionMode) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (this._dy < MOTION_THRESHOLD)
|
||||||
|
dir = Meta.MotionDirection.DOWN;
|
||||||
|
else if (this._dy > MOTION_THRESHOLD)
|
||||||
|
dir = Meta.MotionDirection.UP;
|
||||||
|
else if (this._dx < MOTION_THRESHOLD)
|
||||||
|
dir = Meta.MotionDirection.RIGHT;
|
||||||
|
else if (this._dx > MOTION_THRESHOLD)
|
||||||
|
dir = Meta.MotionDirection.LEFT;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.emit('activated', dir);
|
||||||
|
},
|
||||||
|
|
||||||
|
_handleEvent: function(actor, event) {
|
||||||
|
if (event.type() != Clutter.EventType.TOUCHPAD_SWIPE_BEGIN &&
|
||||||
|
event.type() != Clutter.EventType.TOUCHPAD_SWIPE_UPDATE &&
|
||||||
|
event.type() != Clutter.EventType.TOUCHPAD_SWIPE_END)
|
||||||
|
return Clutter.EVENT_PROPAGATE;
|
||||||
|
|
||||||
|
if (event.get_gesture_swipe_finger_count() != 4)
|
||||||
|
return Clutter.EVENT_PROPAGATE;
|
||||||
|
|
||||||
|
if (event.type() == Clutter.EventType.TOUCHPAD_SWIPE_UPDATE) {
|
||||||
|
let [dx, dy] = event.get_gesture_motion_delta(event);
|
||||||
|
|
||||||
|
this._dx += dx;
|
||||||
|
this._dy += dy;
|
||||||
|
} else {
|
||||||
|
if (event.type() == Clutter.EventType.TOUCHPAD_SWIPE_END)
|
||||||
|
this._checkActivated();
|
||||||
|
|
||||||
|
this._dx = 0;
|
||||||
|
this._dy = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Clutter.EVENT_STOP;
|
||||||
|
},
|
||||||
|
|
||||||
|
_init: function(actor) {
|
||||||
|
this._dx = 0;
|
||||||
|
this._dy = 0;
|
||||||
|
actor.connect('captured-event', Lang.bind(this, this._handleEvent));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
Signals.addSignalMethods(TouchpadWorkspaceSwitchAction.prototype);
|
||||||
|
|
||||||
const WorkspaceSwitchAction = new Lang.Class({
|
const WorkspaceSwitchAction = new Lang.Class({
|
||||||
Name: 'WorkspaceSwitchAction',
|
Name: 'WorkspaceSwitchAction',
|
||||||
Extends: Clutter.SwipeAction,
|
Extends: Clutter.SwipeAction,
|
||||||
@ -866,15 +924,22 @@ const WindowManager = new Lang.Class({
|
|||||||
false, -1, 1);
|
false, -1, 1);
|
||||||
|
|
||||||
let gesture = new WorkspaceSwitchAction();
|
let gesture = new WorkspaceSwitchAction();
|
||||||
gesture.connect('activated', Lang.bind(this, function(action, direction) {
|
gesture.connect('activated', Lang.bind(this, this._actionSwitchWorkspace));
|
||||||
let newWs = global.screen.get_active_workspace().get_neighbor(direction);
|
|
||||||
this.actionMoveWorkspace(newWs);
|
|
||||||
}));
|
|
||||||
global.stage.add_action(gesture);
|
global.stage.add_action(gesture);
|
||||||
|
|
||||||
|
// This is not a normal Clutter.GestureAction, doesn't need add_action()
|
||||||
|
gesture = new TouchpadWorkspaceSwitchAction(global.stage);
|
||||||
|
gesture.connect('activated', Lang.bind(this, this._actionSwitchWorkspace));
|
||||||
|
|
||||||
gesture = new AppSwitchAction();
|
gesture = new AppSwitchAction();
|
||||||
gesture.connect('activated', Lang.bind(this, this._switchApp));
|
gesture.connect('activated', Lang.bind(this, this._switchApp));
|
||||||
global.stage.add_action(gesture);
|
global.stage.add_action(gesture);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
_actionSwitchWorkspace: function(action, direction) {
|
||||||
|
let newWs = global.screen.get_active_workspace().get_neighbor(direction);
|
||||||
|
this.actionMoveWorkspace(newWs);
|
||||||
},
|
},
|
||||||
|
|
||||||
_lookupIndex: function (windows, metaWindow) {
|
_lookupIndex: function (windows, metaWindow) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user