windowManager: Add shortcuts to open new window of nth pinned app

Add new shortcuts to open a new instance of an app by pressing
Super + Ctrl + Number. This is analogous to ctrl-activating
(LMB/Enter) an app icon.

Close https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4129

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1829>
This commit is contained in:
Leleat 2021-05-04 12:58:00 +02:00 committed by Marge Bot
parent d3a18be0f2
commit d429ab5e08
3 changed files with 142 additions and 5 deletions

View File

@ -41,5 +41,41 @@
description="Activate pinned app 9" description="Activate pinned app 9"
hidden="true"/> hidden="true"/>
<KeyListEntry name="open-new-window-application-1"
description="Open new window of pinned app 1"
hidden="true"/>
<KeyListEntry name="open-new-window-application-2"
description="Open new window of pinned app 2"
hidden="true"/>
<KeyListEntry name="open-new-window-application-3"
description="Open new window of pinned app 3"
hidden="true"/>
<KeyListEntry name="open-new-window-application-4"
description="Open new window of pinned app 4"
hidden="true"/>
<KeyListEntry name="open-new-window-application-5"
description="Open new window of pinned app 5"
hidden="true"/>
<KeyListEntry name="open-new-window-application-6"
description="Open new window of pinned app 6"
hidden="true"/>
<KeyListEntry name="open-new-window-application-7"
description="Open new window of pinned app 7"
hidden="true"/>
<KeyListEntry name="open-new-window-application-8"
description="Open new window of pinned app 8"
hidden="true"/>
<KeyListEntry name="open-new-window-application-9"
description="Open new window of pinned app 9"
hidden="true"/>
</KeyListEntries> </KeyListEntries>

View File

@ -235,6 +235,42 @@
<default>["&lt;Super&gt;9"]</default> <default>["&lt;Super&gt;9"]</default>
<summary>Switch to application 9</summary> <summary>Switch to application 9</summary>
</key> </key>
<key name="open-new-window-application-1" type="as">
<default>["&lt;Super&gt;&lt;Control&gt;1"]</default>
<summary>Open a new instance of application 1</summary>
</key>
<key name="open-new-window-application-2" type="as">
<default>["&lt;Super&gt;&lt;Control&gt;2"]</default>
<summary>Open a new instance of application 2</summary>
</key>
<key name="open-new-window-application-3" type="as">
<default>["&lt;Super&gt;&lt;Control&gt;3"]</default>
<summary>Open a new instance of application 3</summary>
</key>
<key name="open-new-window-application-4" type="as">
<default>["&lt;Super&gt;&lt;Control&gt;4"]</default>
<summary>Open a new instance of application 4</summary>
</key>
<key name="open-new-window-application-5" type="as">
<default>["&lt;Super&gt;&lt;Control&gt;5"]</default>
<summary>Open a new instance of application 5</summary>
</key>
<key name="open-new-window-application-6" type="as">
<default>["&lt;Super&gt;&lt;Control&gt;6"]</default>
<summary>Open a new instance of application 6</summary>
</key>
<key name="open-new-window-application-7" type="as">
<default>["&lt;Super&gt;&lt;Control&gt;7"]</default>
<summary>Open a new instance of application 7</summary>
</key>
<key name="open-new-window-application-8" type="as">
<default>["&lt;Super&gt;&lt;Control&gt;8"]</default>
<summary>Open a new instance of application 8</summary>
</key>
<key name="open-new-window-application-9" type="as">
<default>["&lt;Super&gt;&lt;Control&gt;9"]</default>
<summary>Open a new instance of application 9</summary>
</key>
<key name="show-screenshot-ui" type="as"> <key name="show-screenshot-ui" type="as">
<default>["Print"]</default> <default>["Print"]</default>
<summary>Take a screenshot interactively</summary> <summary>Take a screenshot interactively</summary>

View File

@ -819,6 +819,60 @@ export class WindowManager {
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
this._switchToApplication.bind(this)); this._switchToApplication.bind(this));
this.addKeybinding('open-new-window-application-1',
new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
this._openNewApplicationWindow.bind(this));
this.addKeybinding('open-new-window-application-2',
new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
this._openNewApplicationWindow.bind(this));
this.addKeybinding('open-new-window-application-3',
new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
this._openNewApplicationWindow.bind(this));
this.addKeybinding('open-new-window-application-4',
new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
this._openNewApplicationWindow.bind(this));
this.addKeybinding('open-new-window-application-5',
new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
this._openNewApplicationWindow.bind(this));
this.addKeybinding('open-new-window-application-6',
new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
this._openNewApplicationWindow.bind(this));
this.addKeybinding('open-new-window-application-7',
new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
this._openNewApplicationWindow.bind(this));
this.addKeybinding('open-new-window-application-8',
new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
this._openNewApplicationWindow.bind(this));
this.addKeybinding('open-new-window-application-9',
new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
this._openNewApplicationWindow.bind(this));
global.stage.connect('scroll-event', (stage, event) => { global.stage.connect('scroll-event', (stage, event) => {
const allowedModes = Shell.ActionMode.NORMAL; const allowedModes = Shell.ActionMode.NORMAL;
if ((allowedModes & Main.actionMode) === 0) if ((allowedModes & Main.actionMode) === 0)
@ -1656,19 +1710,30 @@ export class WindowManager {
return Main.sessionMode.hasOverview; return Main.sessionMode.hasOverview;
} }
_switchToApplication(display, window, binding) { _getNthFavoriteApp(n) {
if (!this._allowFavoriteShortcuts()) if (!this._allowFavoriteShortcuts())
return; return null;
let [, , , target] = binding.get_name().split('-'); const apps = AppFavorites.getAppFavorites().getFavorites();
let apps = AppFavorites.getAppFavorites().getFavorites(); return apps[n];
let app = apps[target - 1]; }
_switchToApplication(display, window, binding) {
const [, , , target] = binding.get_name().split('-');
const app = this._getNthFavoriteApp(target - 1);
if (app) { if (app) {
Main.overview.hide(); Main.overview.hide();
app.activate(); app.activate();
} }
} }
_openNewApplicationWindow(display, window, binding) {
const [, , , , target] = binding.get_name().split('-');
const app = this._getNthFavoriteApp(target - 1);
if (app)
app.open_new_window(-1);
}
_toggleCalendar() { _toggleCalendar() {
Main.panel.toggleCalendar(); Main.panel.toggleCalendar();
} }