WindowManager: Show switcher popup for switch-to-workspace-n keybindings
Currently we show the workspace popup for relative targets ("up", "down"), but not when targetting a specific workspace directly. There is not really a good reason for that difference, and as we are about to introduce a new shortcut to target the last workspace (which does vary with dynamic workspaces), it makes sense to unify the behavior and always show the switcher. https://bugzilla.gnome.org/show_bug.cgi?id=659288
This commit is contained in:
parent
731e8bfe2b
commit
8727661c1c
@ -136,42 +136,90 @@ const WindowManager = new Lang.Class({
|
|||||||
Shell.KeyBindingMode.NORMAL |
|
Shell.KeyBindingMode.NORMAL |
|
||||||
Shell.KeyBindingMode.OVERVIEW,
|
Shell.KeyBindingMode.OVERVIEW,
|
||||||
Lang.bind(this, this._showWorkspaceSwitcher));
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
this.allowKeybinding('switch-to-workspace-1',
|
this.setCustomKeybindingHandler('switch-to-workspace-1',
|
||||||
Shell.KeyBindingMode.NORMAL |
|
Shell.KeyBindingMode.NORMAL |
|
||||||
Shell.KeyBindingMode.OVERVIEW);
|
Shell.KeyBindingMode.OVERVIEW,
|
||||||
this.allowKeybinding('switch-to-workspace-2',
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('switch-to-workspace-2',
|
||||||
Shell.KeyBindingMode.NORMAL |
|
Shell.KeyBindingMode.NORMAL |
|
||||||
Shell.KeyBindingMode.OVERVIEW);
|
Shell.KeyBindingMode.OVERVIEW,
|
||||||
this.allowKeybinding('switch-to-workspace-3',
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('switch-to-workspace-3',
|
||||||
Shell.KeyBindingMode.NORMAL |
|
Shell.KeyBindingMode.NORMAL |
|
||||||
Shell.KeyBindingMode.OVERVIEW);
|
Shell.KeyBindingMode.OVERVIEW,
|
||||||
this.allowKeybinding('switch-to-workspace-4',
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('switch-to-workspace-4',
|
||||||
Shell.KeyBindingMode.NORMAL |
|
Shell.KeyBindingMode.NORMAL |
|
||||||
Shell.KeyBindingMode.OVERVIEW);
|
Shell.KeyBindingMode.OVERVIEW,
|
||||||
this.allowKeybinding('switch-to-workspace-5',
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('switch-to-workspace-5',
|
||||||
Shell.KeyBindingMode.NORMAL |
|
Shell.KeyBindingMode.NORMAL |
|
||||||
Shell.KeyBindingMode.OVERVIEW);
|
Shell.KeyBindingMode.OVERVIEW,
|
||||||
this.allowKeybinding('switch-to-workspace-6',
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('switch-to-workspace-6',
|
||||||
Shell.KeyBindingMode.NORMAL |
|
Shell.KeyBindingMode.NORMAL |
|
||||||
Shell.KeyBindingMode.OVERVIEW);
|
Shell.KeyBindingMode.OVERVIEW,
|
||||||
this.allowKeybinding('switch-to-workspace-7',
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('switch-to-workspace-7',
|
||||||
Shell.KeyBindingMode.NORMAL |
|
Shell.KeyBindingMode.NORMAL |
|
||||||
Shell.KeyBindingMode.OVERVIEW);
|
Shell.KeyBindingMode.OVERVIEW,
|
||||||
this.allowKeybinding('switch-to-workspace-8',
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('switch-to-workspace-8',
|
||||||
Shell.KeyBindingMode.NORMAL |
|
Shell.KeyBindingMode.NORMAL |
|
||||||
Shell.KeyBindingMode.OVERVIEW);
|
Shell.KeyBindingMode.OVERVIEW,
|
||||||
this.allowKeybinding('switch-to-workspace-9',
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('switch-to-workspace-9',
|
||||||
Shell.KeyBindingMode.NORMAL |
|
Shell.KeyBindingMode.NORMAL |
|
||||||
Shell.KeyBindingMode.OVERVIEW);
|
Shell.KeyBindingMode.OVERVIEW,
|
||||||
this.allowKeybinding('switch-to-workspace-10',
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('switch-to-workspace-10',
|
||||||
Shell.KeyBindingMode.NORMAL |
|
Shell.KeyBindingMode.NORMAL |
|
||||||
Shell.KeyBindingMode.OVERVIEW);
|
Shell.KeyBindingMode.OVERVIEW,
|
||||||
this.allowKeybinding('switch-to-workspace-11',
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('switch-to-workspace-11',
|
||||||
Shell.KeyBindingMode.NORMAL |
|
Shell.KeyBindingMode.NORMAL |
|
||||||
Shell.KeyBindingMode.OVERVIEW);
|
Shell.KeyBindingMode.OVERVIEW,
|
||||||
this.allowKeybinding('switch-to-workspace-12',
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('switch-to-workspace-12',
|
||||||
Shell.KeyBindingMode.NORMAL |
|
Shell.KeyBindingMode.NORMAL |
|
||||||
Shell.KeyBindingMode.OVERVIEW);
|
Shell.KeyBindingMode.OVERVIEW,
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('move-to-workspace-1',
|
||||||
|
Shell.KeyBindingMode.NORMAL,
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('move-to-workspace-2',
|
||||||
|
Shell.KeyBindingMode.NORMAL,
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('move-to-workspace-3',
|
||||||
|
Shell.KeyBindingMode.NORMAL,
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('move-to-workspace-4',
|
||||||
|
Shell.KeyBindingMode.NORMAL,
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('move-to-workspace-5',
|
||||||
|
Shell.KeyBindingMode.NORMAL,
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('move-to-workspace-6',
|
||||||
|
Shell.KeyBindingMode.NORMAL,
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('move-to-workspace-7',
|
||||||
|
Shell.KeyBindingMode.NORMAL,
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('move-to-workspace-8',
|
||||||
|
Shell.KeyBindingMode.NORMAL,
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('move-to-workspace-9',
|
||||||
|
Shell.KeyBindingMode.NORMAL,
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('move-to-workspace-10',
|
||||||
|
Shell.KeyBindingMode.NORMAL,
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('move-to-workspace-11',
|
||||||
|
Shell.KeyBindingMode.NORMAL,
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
this.setCustomKeybindingHandler('move-to-workspace-12',
|
||||||
|
Shell.KeyBindingMode.NORMAL,
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
this.setCustomKeybindingHandler('switch-applications',
|
this.setCustomKeybindingHandler('switch-applications',
|
||||||
Shell.KeyBindingMode.NORMAL,
|
Shell.KeyBindingMode.NORMAL,
|
||||||
Lang.bind(this, this._startAppSwitcher));
|
Lang.bind(this, this._startAppSwitcher));
|
||||||
@ -724,19 +772,31 @@ const WindowManager = new Lang.Class({
|
|||||||
if (screen.n_workspaces == 1)
|
if (screen.n_workspaces == 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let [action,,,direction] = binding.get_name().split('-');
|
let [action,,,target] = binding.get_name().split('-');
|
||||||
let direction = Meta.MotionDirection[direction.toUpperCase()];
|
|
||||||
let newWs;
|
let newWs;
|
||||||
|
let direction;
|
||||||
|
|
||||||
|
if (isNaN(target)) {
|
||||||
|
direction = Meta.MotionDirection[target.toUpperCase()];
|
||||||
|
newWs = screen.get_active_workspace().get_neighbor(direction);
|
||||||
|
} else if (target > 0) {
|
||||||
|
target--;
|
||||||
|
newWs = screen.get_workspace_by_index(target);
|
||||||
|
|
||||||
|
if (screen.get_active_workspace().index() > target)
|
||||||
|
direction = Meta.MotionDirection.UP;
|
||||||
|
else
|
||||||
|
direction = Meta.MotionDirection.DOWN;
|
||||||
|
}
|
||||||
|
|
||||||
if (direction != Meta.MotionDirection.UP &&
|
if (direction != Meta.MotionDirection.UP &&
|
||||||
direction != Meta.MotionDirection.DOWN)
|
direction != Meta.MotionDirection.DOWN)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (action == 'switch')
|
if (action == 'switch')
|
||||||
newWs = this.actionMoveWorkspace(direction);
|
this.actionMoveWorkspace(newWs);
|
||||||
else
|
else
|
||||||
newWs = this.actionMoveWindow(window, direction);
|
this.actionMoveWindow(window, newWs);
|
||||||
|
|
||||||
if (!Main.overview.visible) {
|
if (!Main.overview.visible) {
|
||||||
if (this._workspaceSwitcherPopup == null) {
|
if (this._workspaceSwitcherPopup == null) {
|
||||||
@ -749,31 +809,27 @@ const WindowManager = new Lang.Class({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
actionMoveWorkspace: function(direction) {
|
actionMoveWorkspace: function(workspace) {
|
||||||
let activeWorkspace = global.screen.get_active_workspace();
|
let activeWorkspace = global.screen.get_active_workspace();
|
||||||
let toActivate = activeWorkspace.get_neighbor(direction);
|
|
||||||
|
|
||||||
if (activeWorkspace != toActivate)
|
if (activeWorkspace != workspace)
|
||||||
toActivate.activate(global.get_current_time());
|
workspace.activate(global.get_current_time());
|
||||||
|
|
||||||
return toActivate;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
actionMoveWindow: function(window, direction) {
|
actionMoveWindow: function(window, workspace) {
|
||||||
let activeWorkspace = global.screen.get_active_workspace();
|
let activeWorkspace = global.screen.get_active_workspace();
|
||||||
let toActivate = activeWorkspace.get_neighbor(direction);
|
|
||||||
|
|
||||||
if (activeWorkspace != toActivate) {
|
if (activeWorkspace != workspace) {
|
||||||
// This won't have any effect for "always sticky" windows
|
// This won't have any effect for "always sticky" windows
|
||||||
// (like desktop windows or docks)
|
// (like desktop windows or docks)
|
||||||
|
|
||||||
this._movingWindow = window;
|
this._movingWindow = window;
|
||||||
window.change_workspace(toActivate);
|
window.change_workspace(workspace);
|
||||||
|
|
||||||
global.display.clear_mouse_mode();
|
global.display.clear_mouse_mode();
|
||||||
toActivate.activate_with_focus (window, global.get_current_time());
|
workspace.activate_with_focus (window, global.get_current_time());
|
||||||
}
|
}
|
||||||
|
|
||||||
return toActivate;
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user