WindowManager: handle move-to-workspace keybindings
Install a custom handler for move-to-workspace-* keybindings that shows the workspace switcher, which gives the user a sense of direction when navigating with the keyboard. https://bugzilla.gnome.org/show_bug.cgi?id=674104
This commit is contained in:
parent
de72065a4a
commit
04dbf15d9b
@ -125,6 +125,14 @@ const WindowManager = new Lang.Class({
|
|||||||
Lang.bind(this, this._showWorkspaceSwitcher));
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
Meta.keybindings_set_custom_handler('switch-to-workspace-down',
|
Meta.keybindings_set_custom_handler('switch-to-workspace-down',
|
||||||
Lang.bind(this, this._showWorkspaceSwitcher));
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
Meta.keybindings_set_custom_handler('move-to-workspace-left',
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
Meta.keybindings_set_custom_handler('move-to-workspace-right',
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
Meta.keybindings_set_custom_handler('move-to-workspace-up',
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
|
Meta.keybindings_set_custom_handler('move-to-workspace-down',
|
||||||
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
Meta.keybindings_set_custom_handler('switch-windows',
|
Meta.keybindings_set_custom_handler('switch-windows',
|
||||||
Lang.bind(this, this._startAppSwitcher));
|
Lang.bind(this, this._startAppSwitcher));
|
||||||
Meta.keybindings_set_custom_handler('switch-group',
|
Meta.keybindings_set_custom_handler('switch-group',
|
||||||
@ -563,24 +571,40 @@ const WindowManager = new Lang.Class({
|
|||||||
if (this._workspaceSwitcherPopup == null)
|
if (this._workspaceSwitcherPopup == null)
|
||||||
this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
|
this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
|
||||||
|
|
||||||
if (binding.get_name() == 'switch-to-workspace-up')
|
let [action,,,direction] = binding.get_name().split('-');
|
||||||
this.actionMoveWorkspace(Meta.MotionDirection.UP);
|
let direction = Meta.MotionDirection[direction.toUpperCase()];
|
||||||
else if (binding.get_name() == 'switch-to-workspace-down')
|
|
||||||
this.actionMoveWorkspace(Meta.MotionDirection.DOWN);
|
if (action == 'switch')
|
||||||
else if (binding.get_name() == 'switch-to-workspace-left')
|
this.actionMoveWorkspace(direction);
|
||||||
this.actionMoveWorkspace(Meta.MotionDirection.LEFT);
|
else
|
||||||
else if (binding.get_name() == 'switch-to-workspace-right')
|
this.actionMoveWindow(window, direction);
|
||||||
this.actionMoveWorkspace(Meta.MotionDirection.RIGHT);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
actionMoveWorkspace: function(direction) {
|
actionMoveWorkspace: function(direction) {
|
||||||
let activeWorkspace = global.screen.get_active_workspace();
|
let activeWorkspace = global.screen.get_active_workspace();
|
||||||
let toActivate = activeWorkspace.get_neighbor(direction);
|
let toActivate = activeWorkspace.get_neighbor(direction);
|
||||||
|
|
||||||
if (toActivate && activeWorkspace != toActivate)
|
if (activeWorkspace != toActivate)
|
||||||
toActivate.activate(global.get_current_time());
|
toActivate.activate(global.get_current_time());
|
||||||
|
|
||||||
if (!Main.overview.visible)
|
if (!Main.overview.visible)
|
||||||
this._workspaceSwitcherPopup.display(direction, toActivate.index());
|
this._workspaceSwitcherPopup.display(direction, toActivate.index());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
actionMoveWindow: function(window, direction) {
|
||||||
|
let activeWorkspace = global.screen.get_active_workspace();
|
||||||
|
let toActivate = activeWorkspace.get_neighbor(direction);
|
||||||
|
|
||||||
|
if (activeWorkspace != toActivate) {
|
||||||
|
// This won't have any effect for "always sticky" windows
|
||||||
|
// (like desktop windows or docks)
|
||||||
|
window.change_workspace(toActivate);
|
||||||
|
|
||||||
|
global.display.clear_mouse_mode();
|
||||||
|
toActivate.activate_with_focus (window, global.get_current_time());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Main.overview.visible)
|
||||||
|
this._workspaceSwitcherPopup.display(direction, toActivate.index());
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user