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

Add commands switch-(up/down)-or-else-workspace #850

Merged
merged 5 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions keybindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ export function setupActions(settings) {
registerMinimapAction("switch-up-loop", (mw, space) => space.switchUp(true));
registerMinimapAction("switch-down-loop", (mw, space) => space.switchDown(true));

registerNavigatorAction("switch-up-or-else-workspace", Tiling.switchUpOrElseWorkspace);
registerNavigatorAction("switch-down-or-else-workspace", Tiling.switchDownOrElseWorkspace);

registerMinimapAction("switch-first", Tiling.activateFirstWindow);
registerMinimapAction("switch-last", Tiling.activateLastWindow);

Expand Down
2 changes: 2 additions & 0 deletions prefsKeybinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const actions = {
'switch-global-right',
'switch-global-up',
'switch-global-down',
'switch-up-or-else-workspace',
'switch-down-or-else-workspace',
'switch-first',
'switch-last',
'live-alt-tab',
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
20 changes: 14 additions & 6 deletions schemas/org.gnome.shell.extensions.paperwm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,27 +198,27 @@
</key>

<key type="as" name="switch-next-loop">
<default><![CDATA[['']]]></default>
<default><![CDATA[[]]]></default>
<summary>Switch to the next window (with wrap-around)</summary>
</key>
<key type="as" name="switch-previous-loop">
<default><![CDATA[['']]]></default>
<default><![CDATA[[]]]></default>
<summary>Switch to the previous window (with wrap-around)</summary>
</key>
<key type="as" name="switch-right-loop">
<default><![CDATA[['']]]></default>
<default><![CDATA[[]]]></default>
<summary>Switch to the right window (with wrap-around)</summary>
</key>
<key type="as" name="switch-left-loop">
<default><![CDATA[['']]]></default>
<default><![CDATA[[]]]></default>
<summary>Switch to the left window (with wrap-around)</summary>
</key>
<key type="as" name="switch-up-loop">
<default><![CDATA[['']]]></default>
<default><![CDATA[[]]]></default>
<summary>Switch to the window above (with wrap-around)</summary>
</key>
<key type="as" name="switch-down-loop">
<default><![CDATA[['']]]></default>
<default><![CDATA[[]]]></default>
<summary>Switch to the window below (with wrap-around)</summary>
</key>

Expand All @@ -238,6 +238,14 @@
<default><![CDATA[[]]]></default>
<summary>Switch to the below window (no monitor boundary)</summary>
</key>
<key type="as" name="switch-up-or-else-workspace">
<default><![CDATA[[]]]></default>
<summary>Switch to the above window (no workspace boundary)</summary>
</key>
<key type="as" name="switch-down-or-else-workspace">
<default><![CDATA[[]]]></default>
<summary>Switch to the below window (no workspace boundary)</summary>
</key>

<key type="as" name="switch-first">
<default><![CDATA[['<Super>Home']]]></default>
Expand Down
26 changes: 19 additions & 7 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -1058,15 +1058,15 @@ export class Space extends Array {
return true;
}

switchLeft(loop) { this.switch(Meta.MotionDirection.LEFT, loop); }
switchRight(loop) { this.switch(Meta.MotionDirection.RIGHT, loop); }
switchUp(loop) { this.switch(Meta.MotionDirection.UP, loop); }
switchDown(loop) { this.switch(Meta.MotionDirection.DOWN, loop); }
switchLeft(loop) { return this.switch(Meta.MotionDirection.LEFT, loop); }
switchRight(loop) { return this.switch(Meta.MotionDirection.RIGHT, loop); }
switchUp(loop) { return this.switch(Meta.MotionDirection.UP, loop); }
switchDown(loop) { return this.switch(Meta.MotionDirection.DOWN, loop); }
switch(direction, loop) {
let space = this;
let index = space.selectedIndex();
if (index === -1) {
return;
return false;
}
let row = space[index].indexOf(space.selectedWindow);
switch (direction) {
Expand All @@ -1085,7 +1085,7 @@ export class Space extends Array {
index = 0;
}
} else if (index < 0 || index >= space.length) {
return;
return false;
}

let column = space[index];
Expand All @@ -1110,11 +1110,13 @@ export class Space extends Array {
row = 0;
}
} else if (row < 0 || row >= column.length) {
return;
return false;
}

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

return true;
}

switchGlobalLeft() { this.switchGlobal(Meta.MotionDirection.LEFT); }
Expand Down Expand Up @@ -4951,6 +4953,16 @@ export function selectUpSpace(mw, space, fromAllMonitors) {
spaces.selectSequenceSpace(Meta.MotionDirection.UP, false, fromAllMonitors);
}

export function switchDownOrElseWorkspace(mw, space) {
if (!space.switchDown(false))
selectDownSpace(mw, space, false);
}

export function switchUpOrElseWorkspace(mw, space) {
if (!space.switchUp(false))
selectUpSpace(mw, space, false);
}

export function moveDownSpace(_mw, _space) {
spaces.selectSequenceSpace(Meta.MotionDirection.DOWN, true);
}
Expand Down