switchGestures: Do not hard-code allowed modes
The touch/touchpad gestures to switch workspace currently hard-code the modes in which we want the gestures to work. While these modes are correct, the existing switch animation only works in NORMAL mode, not in the overview where the window group is hidden. The easiest way to address this is to handle both cases completely separately, namely use separate actions in- and outside the overview. Make the existing usable in that way by making the list of allowed modes a constructor parameter. https://gitlab.gnome.org/GNOME/gnome-shell/issues/516
This commit is contained in:
parent
e83f2344f6
commit
b77e4975f0
@ -456,7 +456,8 @@ var TilePreview = class {
|
||||
};
|
||||
|
||||
var TouchpadWorkspaceSwitchAction = class {
|
||||
constructor(actor) {
|
||||
constructor(actor, allowedModes) {
|
||||
this._allowedModes = allowedModes;
|
||||
this._dx = 0;
|
||||
this._dy = 0;
|
||||
this._enabled = true;
|
||||
@ -496,15 +497,13 @@ var TouchpadWorkspaceSwitchAction = class {
|
||||
}
|
||||
|
||||
_handleEvent(actor, event) {
|
||||
let allowedModes = Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW;
|
||||
|
||||
if (event.type() != Clutter.EventType.TOUCHPAD_SWIPE)
|
||||
return Clutter.EVENT_PROPAGATE;
|
||||
|
||||
if (event.get_touchpad_gesture_finger_count() != 4)
|
||||
return Clutter.EVENT_PROPAGATE;
|
||||
|
||||
if ((allowedModes & Main.actionMode) == 0)
|
||||
if ((this._allowedModes & Main.actionMode) == 0)
|
||||
return Clutter.EVENT_PROPAGATE;
|
||||
|
||||
if (!this._enabled)
|
||||
@ -540,10 +539,11 @@ var WorkspaceSwitchAction = GObject.registerClass({
|
||||
'motion': { param_types: [GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] },
|
||||
'cancel': { param_types: [] }},
|
||||
}, class WorkspaceSwitchAction extends Clutter.SwipeAction {
|
||||
_init() {
|
||||
_init(allowedModes) {
|
||||
super._init();
|
||||
this.set_n_touch_points(4);
|
||||
this._swept = false;
|
||||
this._allowedModes = allowedModes;
|
||||
|
||||
global.display.connect('grab-op-begin', () => {
|
||||
this.cancel();
|
||||
@ -551,14 +551,12 @@ var WorkspaceSwitchAction = GObject.registerClass({
|
||||
}
|
||||
|
||||
vfunc_gesture_prepare(actor) {
|
||||
let allowedModes = Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW;
|
||||
|
||||
this._swept = false;
|
||||
|
||||
if (!super.vfunc_gesture_prepare(actor))
|
||||
return false;
|
||||
|
||||
return (allowedModes & Main.actionMode);
|
||||
return (this._allowedModes & Main.actionMode);
|
||||
}
|
||||
|
||||
vfunc_gesture_progress(actor) {
|
||||
@ -1060,14 +1058,15 @@ var WindowManager = class {
|
||||
global.workspace_manager.override_workspace_layout(Meta.DisplayCorner.TOPLEFT,
|
||||
false, -1, 1);
|
||||
|
||||
let gesture = new WorkspaceSwitchAction();
|
||||
let allowedModes = Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW;
|
||||
let gesture = new WorkspaceSwitchAction(allowedModes);
|
||||
gesture.connect('motion', this._switchWorkspaceMotion.bind(this));
|
||||
gesture.connect('activated', this._actionSwitchWorkspace.bind(this));
|
||||
gesture.connect('cancel', this._switchWorkspaceCancel.bind(this));
|
||||
global.stage.add_action(gesture);
|
||||
|
||||
// This is not a normal Clutter.GestureAction, doesn't need add_action()
|
||||
gesture = new TouchpadWorkspaceSwitchAction(global.stage);
|
||||
gesture = new TouchpadWorkspaceSwitchAction(global.stage, allowedModes);
|
||||
gesture.connect('motion', this._switchWorkspaceMotion.bind(this));
|
||||
gesture.connect('activated', this._actionSwitchWorkspace.bind(this));
|
||||
gesture.connect('cancel', this._switchWorkspaceCancel.bind(this));
|
||||
|
Loading…
Reference in New Issue
Block a user