windowManager: Avoid code duplication
The various switcher keybindings are handled identically, except for the popup that is shown; update the code to reflect that instead of duplicating the code again and again. https://bugzilla.gnome.org/show_bug.cgi?id=730739
This commit is contained in:
parent
bc4891c3a3
commit
74553fa95e
@ -850,34 +850,34 @@ const WindowManager = new Lang.Class({
|
|||||||
Lang.bind(this, this._showWorkspaceSwitcher));
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
this.setCustomKeybindingHandler('switch-applications',
|
this.setCustomKeybindingHandler('switch-applications',
|
||||||
Shell.ActionMode.NORMAL,
|
Shell.ActionMode.NORMAL,
|
||||||
Lang.bind(this, this._startAppSwitcher));
|
Lang.bind(this, this._startSwitcher));
|
||||||
this.setCustomKeybindingHandler('switch-group',
|
this.setCustomKeybindingHandler('switch-group',
|
||||||
Shell.ActionMode.NORMAL,
|
Shell.ActionMode.NORMAL,
|
||||||
Lang.bind(this, this._startAppSwitcher));
|
Lang.bind(this, this._startSwitcher));
|
||||||
this.setCustomKeybindingHandler('switch-applications-backward',
|
this.setCustomKeybindingHandler('switch-applications-backward',
|
||||||
Shell.ActionMode.NORMAL,
|
Shell.ActionMode.NORMAL,
|
||||||
Lang.bind(this, this._startAppSwitcher));
|
Lang.bind(this, this._startSwitcher));
|
||||||
this.setCustomKeybindingHandler('switch-group-backward',
|
this.setCustomKeybindingHandler('switch-group-backward',
|
||||||
Shell.ActionMode.NORMAL,
|
Shell.ActionMode.NORMAL,
|
||||||
Lang.bind(this, this._startAppSwitcher));
|
Lang.bind(this, this._startSwitcher));
|
||||||
this.setCustomKeybindingHandler('switch-windows',
|
this.setCustomKeybindingHandler('switch-windows',
|
||||||
Shell.ActionMode.NORMAL,
|
Shell.ActionMode.NORMAL,
|
||||||
Lang.bind(this, this._startWindowSwitcher));
|
Lang.bind(this, this._startSwitcher));
|
||||||
this.setCustomKeybindingHandler('switch-windows-backward',
|
this.setCustomKeybindingHandler('switch-windows-backward',
|
||||||
Shell.ActionMode.NORMAL,
|
Shell.ActionMode.NORMAL,
|
||||||
Lang.bind(this, this._startWindowSwitcher));
|
Lang.bind(this, this._startSwitcher));
|
||||||
this.setCustomKeybindingHandler('cycle-windows',
|
this.setCustomKeybindingHandler('cycle-windows',
|
||||||
Shell.ActionMode.NORMAL,
|
Shell.ActionMode.NORMAL,
|
||||||
Lang.bind(this, this._startWindowCycler));
|
Lang.bind(this, this._startSwitcher));
|
||||||
this.setCustomKeybindingHandler('cycle-windows-backward',
|
this.setCustomKeybindingHandler('cycle-windows-backward',
|
||||||
Shell.ActionMode.NORMAL,
|
Shell.ActionMode.NORMAL,
|
||||||
Lang.bind(this, this._startWindowCycler));
|
Lang.bind(this, this._startSwitcher));
|
||||||
this.setCustomKeybindingHandler('cycle-group',
|
this.setCustomKeybindingHandler('cycle-group',
|
||||||
Shell.ActionMode.NORMAL,
|
Shell.ActionMode.NORMAL,
|
||||||
Lang.bind(this, this._startGroupCycler));
|
Lang.bind(this, this._startSwitcher));
|
||||||
this.setCustomKeybindingHandler('cycle-group-backward',
|
this.setCustomKeybindingHandler('cycle-group-backward',
|
||||||
Shell.ActionMode.NORMAL,
|
Shell.ActionMode.NORMAL,
|
||||||
Lang.bind(this, this._startGroupCycler));
|
Lang.bind(this, this._startSwitcher));
|
||||||
this.setCustomKeybindingHandler('switch-panels',
|
this.setCustomKeybindingHandler('switch-panels',
|
||||||
Shell.ActionMode.NORMAL |
|
Shell.ActionMode.NORMAL |
|
||||||
Shell.ActionMode.OVERVIEW |
|
Shell.ActionMode.OVERVIEW |
|
||||||
@ -1756,45 +1756,37 @@ const WindowManager = new Lang.Class({
|
|||||||
this._windowMenuManager.showWindowMenuForWindow(window, menu, rect);
|
this._windowMenuManager.showWindowMenuForWindow(window, menu, rect);
|
||||||
},
|
},
|
||||||
|
|
||||||
_startAppSwitcher : function(display, screen, window, binding) {
|
_startSwitcher: function(display, screen, window, binding) {
|
||||||
|
let constructor = null;
|
||||||
|
switch (binding.get_name()) {
|
||||||
|
case 'switch-applications':
|
||||||
|
case 'switch-applications-backward':
|
||||||
|
case 'switch-group':
|
||||||
|
case 'switch-group-backward':
|
||||||
|
constructor = AltTab.AppSwitcherPopup;
|
||||||
|
break;
|
||||||
|
case 'switch-windows':
|
||||||
|
case 'switch-windows-backward':
|
||||||
|
constructor = AltTab.WindowSwitcherPopup;
|
||||||
|
break;
|
||||||
|
case 'cycle-windows':
|
||||||
|
case 'cycle-windows-backward':
|
||||||
|
constructor = AltTab.WindowCyclerPopup;
|
||||||
|
break;
|
||||||
|
case 'cycle-group':
|
||||||
|
case 'cycle-group-backward':
|
||||||
|
constructor = AltTab.GroupCyclerPopup;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!constructor)
|
||||||
|
return;
|
||||||
|
|
||||||
/* prevent a corner case where both popups show up at once */
|
/* prevent a corner case where both popups show up at once */
|
||||||
if (this._workspaceSwitcherPopup != null)
|
if (this._workspaceSwitcherPopup != null)
|
||||||
this._workspaceSwitcherPopup.destroy();
|
this._workspaceSwitcherPopup.destroy();
|
||||||
|
|
||||||
let tabPopup = new AltTab.AppSwitcherPopup();
|
let tabPopup = new constructor();
|
||||||
|
|
||||||
if (!tabPopup.show(binding.is_reversed(), binding.get_name(), binding.get_mask()))
|
|
||||||
tabPopup.destroy();
|
|
||||||
},
|
|
||||||
|
|
||||||
_startWindowSwitcher : function(display, screen, window, binding) {
|
|
||||||
/* prevent a corner case where both popups show up at once */
|
|
||||||
if (this._workspaceSwitcherPopup != null)
|
|
||||||
this._workspaceSwitcherPopup.destroy();
|
|
||||||
|
|
||||||
let tabPopup = new AltTab.WindowSwitcherPopup();
|
|
||||||
|
|
||||||
if (!tabPopup.show(binding.is_reversed(), binding.get_name(), binding.get_mask()))
|
|
||||||
tabPopup.destroy();
|
|
||||||
},
|
|
||||||
|
|
||||||
_startWindowCycler : function(display, screen, window, binding) {
|
|
||||||
/* prevent a corner case where both popups show up at once */
|
|
||||||
if (this._workspaceSwitcherPopup != null)
|
|
||||||
this._workspaceSwitcherPopup.destroy();
|
|
||||||
|
|
||||||
let tabPopup = new AltTab.WindowCyclerPopup();
|
|
||||||
|
|
||||||
if (!tabPopup.show(binding.is_reversed(), binding.get_name(), binding.get_mask()))
|
|
||||||
tabPopup.destroy();
|
|
||||||
},
|
|
||||||
|
|
||||||
_startGroupCycler : function(display, screen, window, binding) {
|
|
||||||
/* prevent a corner case where both popups show up at once */
|
|
||||||
if (this._workspaceSwitcherPopup != null)
|
|
||||||
this._workspaceSwitcherPopup.destroy();
|
|
||||||
|
|
||||||
let tabPopup = new AltTab.GroupCyclerPopup();
|
|
||||||
|
|
||||||
if (!tabPopup.show(binding.is_reversed(), binding.get_name(), binding.get_mask()))
|
if (!tabPopup.show(binding.is_reversed(), binding.get_name(), binding.get_mask()))
|
||||||
tabPopup.destroy();
|
tabPopup.destroy();
|
||||||
|
Loading…
Reference in New Issue
Block a user