Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added switch-global-* actions #775

Merged
merged 12 commits into from
Feb 8, 2024
5 changes: 5 additions & 0 deletions keybindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ export function setupActions(settings) {
registerMinimapAction("switch-up", (mw, space) => space.switchUp());
registerMinimapAction("switch-down", (mw, space) => space.switchDown());

registerMinimapAction("switch-global-right", (mw, space) => space.switchGlobalRight());
registerMinimapAction("switch-global-left", (mw, space) => space.switchGlobalLeft());
registerMinimapAction("switch-global-up", (mw, space) => space.switchGlobalUp());
registerMinimapAction("switch-global-down", (mw, space) => space.switchGlobalDown());

registerMinimapAction("move-left",
(mw, space) => space.swap(Meta.MotionDirection.LEFT));
registerMinimapAction("move-right",
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"url": "https://github.com/paperwm/PaperWM",
"settings-schema": "org.gnome.shell.extensions.paperwm",
"shell-version": [ "45" ],
"version-name": "45.7.0"
"version-name": "45.9.2"
}
4 changes: 2 additions & 2 deletions navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class ActionDispatcher {
}

if (!Tiling.inGrab && action.options.opensMinimap) {
nav._showMinimap(space);
nav.showMinimap(space);
}
action.handler(metaWindow, space, { navigator: this.navigator });
if (space !== Tiling.spaces.selectedSpace) {
Expand Down Expand Up @@ -286,7 +286,7 @@ class NavigatorClass {
this.space.startAnimate();
}

_showMinimap(space) {
showMinimap(space) {
let minimap = this.minimaps.get(space);
if (!minimap) {
let minimapId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 200, () => {
Expand Down
4 changes: 4 additions & 0 deletions prefsKeybinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const actions = {
'switch-right',
'switch-up',
'switch-down',
'switch-global-left',
'switch-global-right',
'switch-global-up',
'switch-global-down',
'switch-first',
'switch-last',
'live-alt-tab',
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
17 changes: 17 additions & 0 deletions schemas/org.gnome.shell.extensions.paperwm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,23 @@
<summary>Switch to the below window</summary>
</key>

<key type="as" name="switch-global-right">
<default><![CDATA[[]]]></default>
<summary>Switch to the right window (no monitor boundary)</summary>
</key>
<key type="as" name="switch-global-left">
<default><![CDATA[[]]]></default>
<summary>Switch to the left window (no monitor boundary)</summary>
</key>
<key type="as" name="switch-global-up">
<default><![CDATA[[]]]></default>
<summary>Switch to the above window (no monitor boundary)</summary>
</key>
<key type="as" name="switch-global-down">
<default><![CDATA[[]]]></default>
<summary>Switch to the below window (no monitor boundary)</summary>
</key>

<key type="as" name="switch-first">
<default><![CDATA[['<Super>Home']]]></default>
<summary>Switch to the first window</summary>
Expand Down
78 changes: 78 additions & 0 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,84 @@ export class Space extends Array {
ensureViewport(metaWindow, space);
}

switchGlobalLeft() { this.switchGlobal(Meta.MotionDirection.LEFT); }
switchGlobalRight() { this.switchGlobal(Meta.MotionDirection.RIGHT); }
switchGlobalUp() { this.switchGlobal(Meta.MotionDirection.UP); }
switchGlobalDown() { this.switchGlobal(Meta.MotionDirection.DOWN); }
switchGlobal(direction) {
let space = this;
let index = space.selectedIndex();
if (index === -1) {
return;
}
let row = space[index].indexOf(space.selectedWindow);

switch (direction) {
case Meta.MotionDirection.RIGHT:
index++;
break;
case Meta.MotionDirection.LEFT:
index--;
}
if (index < 0 || index >= space.length) {
let monitor = focusMonitor();
let dir = index < 0
? Meta.DisplayDirection.LEFT : Meta.DisplayDirection.RIGHT;
let i = display.get_monitor_neighbor_index(monitor.index, dir);
if (i === -1)
return;

let newMonitor = Main.layoutManager.monitors[i];
space = spaces.monitors.get(newMonitor);
if (dir === Meta.DisplayDirection.LEFT) {
index = space.length - 1;
} else {
index = 0;
}
if (space[index].length <= row)
row = space[index].length - 1;
space.activate(false, false);
Navigator.finishNavigation();
Navigator.getNavigator().showMinimap(space);
}

let column = space[index];
if (column.length <= row)
row = column.length - 1;

switch (direction) {
case Meta.MotionDirection.UP:
row--;
break;
case Meta.MotionDirection.DOWN:
row++;
}
if (row < 0 || row >= column.length) {
let monitor = focusMonitor();
let dir = row < 0
? Meta.DisplayDirection.UP : Meta.DisplayDirection.DOWN;
let i = display.get_monitor_neighbor_index(monitor.index, dir);
if (i === -1)
return;

let newMonitor = Main.layoutManager.monitors[i];
space = spaces.monitors.get(newMonitor);
if (space.length <= index)
index = space.length - 1;
if (dir === Meta.DisplayDirection.UP) {
row = space[index].length - 1;
} else {
row = 0;
}
space.activate(false, false);
Navigator.finishNavigation();
Navigator.getNavigator().showMinimap(space);
}

let metaWindow = space.getWindow(index, row);
ensureViewport(metaWindow, space);
}

/**
* Return the x position of the visible element of this window.
*/
Expand Down