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 keybindings to switch to ws from all monitors #645

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 12 additions & 2 deletions keybindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,18 @@ export function setupActions(settings) {
registerNavigatorAction('move-previous-workspace', Tiling.movePreviousSpace);
registerNavigatorAction('move-previous-workspace-backward', Tiling.movePreviousSpaceBackwards);

registerNavigatorAction('switch-down-workspace', Tiling.selectDownSpace);
registerNavigatorAction('switch-up-workspace', Tiling.selectUpSpace);
registerNavigatorAction('switch-down-workspace', (mw, space) => {
Tiling.selectDownSpace(mw, space, false);
});
registerNavigatorAction('switch-up-workspace', (mw, space) => {
Tiling.selectUpSpace(mw, space, false);
});
registerNavigatorAction('switch-down-workspace-from-all-monitors', (mw, space) => {
Tiling.selectDownSpace(mw, space, true);
});
registerNavigatorAction('switch-up-workspace-from-all-monitors', (mw, space) => {
Tiling.selectUpSpace(mw, space, true);
});

registerNavigatorAction('move-down-workspace', Tiling.moveDownSpace);
registerNavigatorAction('move-up-workspace', Tiling.moveUpSpace);
Expand Down
2 changes: 2 additions & 0 deletions prefsKeybinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const actions = {
'move-previous-workspace-backward',
'switch-up-workspace',
'switch-down-workspace',
'switch-up-workspace-from-all-monitors',
'switch-down-workspace-from-all-monitors',
'move-up-workspace',
'move-down-workspace',
],
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
14 changes: 12 additions & 2 deletions schemas/org.gnome.shell.extensions.paperwm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,22 @@

<key type="as" name="switch-down-workspace">
<default><![CDATA[['<Super>Page_Down']]]></default>
<summary>Switch to workspace below</summary>
<summary>Switch to workspace below (ws only from current monitor)</summary>
</key>

<key type="as" name="switch-up-workspace">
<default><![CDATA[['<Super>Page_Up']]]></default>
<summary>Switch to workspace above</summary>
<summary>Switch to workspace above (ws only from current monitor)</summary>
</key>

<key type="as" name="switch-down-workspace-from-all-monitors">
<default><![CDATA[[]]]></default>
<summary>Switch to workspace below (ws from all monitors)</summary>
</key>

<key type="as" name="switch-up-workspace-from-all-monitors">
<default><![CDATA[[]]]></default>
<summary>Switch to workspace above (ws from all monitors)</summary>
</key>

<key type="as" name="move-down-workspace">
Expand Down
40 changes: 33 additions & 7 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -2252,8 +2252,25 @@ export const Spaces = class Spaces extends Map {
for (let i = 0; i < nWorkspaces; i++) {
let space = this.spaceOf(workspaceManager.get_workspace_by_index(i));
if (space.monitor === monitor ||
(space.length === 0 && this.monitors.get(space.monitor) !== space))
(space.length === 0 && this.monitors.get(space.monitor) !== space)) {
// include workspace if it is the current one
// or if it is empty and not active on another monitor
out.push(space);
}
}
return out;
}

_getOrderedSpacesFromAllMonitors(monitor) {
let nWorkspaces = workspaceManager.n_workspaces;
let out = [];
for (let i = 0; i < nWorkspaces; i++) {
let space = this.spaceOf(workspaceManager.get_workspace_by_index(i));
if (this.monitors.get(space.monitor) !== space || space.monitor == monitor) {
Lythenas marked this conversation as resolved.
Show resolved Hide resolved
// include workspace if it is the current one
// or if it is not active on another monitor
out.push(space);
}
}
return out;
}
Expand Down Expand Up @@ -2326,14 +2343,19 @@ export const Spaces = class Spaces extends Map {
}
}

selectSequenceSpace(direction, move) {
selectSequenceSpace(direction, move, fromAllMonitors=false) {
// if in stack preview do not run sequence preview
if (inPreview === PreviewMode.STACK) {
return;
}

let currentSpace = this.activeSpace;
let monitorSpaces = this._getOrderedSpaces(currentSpace.monitor);
var monitorSpaces;
if (fromAllMonitors) {
monitorSpaces = this._getOrderedSpacesFromAllMonitors(currentSpace.monitor);
} else {
monitorSpaces = this._getOrderedSpaces(currentSpace.monitor);
}

let from = monitorSpaces.indexOf(this.selectedSpace);
let newSpace = this.selectedSpace;
Expand Down Expand Up @@ -2380,6 +2402,10 @@ export const Spaces = class Spaces extends Map {
const padding_percentage = 4;
let last = monitorSpaces.length - 1;
monitorSpaces.forEach((space, i) => {
// need to set monitor here so it shows up during selection, when it
// was previously on another monitor
space.setMonitor(currentSpace.monitor);

let padding = (space.height * scale / 100) * padding_percentage;
let center = (space.height - (space.height * scale)) / 2;
let space_y;
Expand Down Expand Up @@ -4199,12 +4225,12 @@ export function movePreviousSpaceBackwards(mw, space) {
spaces.selectStackSpace(Meta.MotionDirection.UP, true);
}

export function selectDownSpace(mw, space) {
spaces.selectSequenceSpace(Meta.MotionDirection.DOWN);
export function selectDownSpace(mw, space, fromAllMonitors) {
spaces.selectSequenceSpace(Meta.MotionDirection.DOWN, false, fromAllMonitors);
}

export function selectUpSpace(mw, space) {
spaces.selectSequenceSpace(Meta.MotionDirection.UP);
export function selectUpSpace(mw, space, fromAllMonitors) {
spaces.selectSequenceSpace(Meta.MotionDirection.UP, false, fromAllMonitors);
}

export function moveDownSpace(mw, space) {
Expand Down