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 #687

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,17 @@ Pressing <kbd>Super</kbd><kbd>Page_Down</kbd> and <kbd>Super</kbd><kbd>Page_Up</

![Sequential workspace navigation](https://github.com/paperwm/media/blob/master/sequence.png)

By default <kbd>Super</kbd><kbd>Page_Down</kbd> and <kbd>Super</kbd><kbd>Page_Down</kbd> are bound to the keybindings "Switch to workspace below/above (**ws from current monitor**)". That means using the keybindings you can select all workspaces that were previously shown on the current monitor and all empty once.

Alternatively you can change these keybindings to "Switch to workspace below/above (**ws from all monitors**)" in the settings. That way you can switch to **all** workspaces (that are not currently shown on another monitor). Depending on your workflow this might feel more natural.

The workspace name is shown in the top left corner replacing the `Activities` button adding a few enhancements. Scrolling on the name will let you browse the workspace stack just like <kbd>Super</kbd><kbd>Above_Tab</kbd>. Left clicking on the name opens Gnome overview, while right clicking the name lets you access and change the workspace name.

> If you prefer to use another workspace indicator (or prefer none at all), you can hide this workspace name element from Gnome topbar by executing the following command from a terminal:
>
>
> ```
> dconf write /org/gnome/shell/extensions/paperwm/show-workspace-indicator false
> ```
> ```

Swiping down on the trackpad vertically with three fingers will initiate the workspace stack, and then allow you navigate the workspace stack with 3-finger vertical swipes (only available in Wayland). See the [Touchpad Gestures](#touchpad-gestures) section for more information on gesture support in PaperWM.

Expand All @@ -138,7 +142,8 @@ PaperWM currently works best using the workspaces span monitors preference, this
| <kbd>Super</kbd><kbd>Shift</kbd><kbd>Above_Tab</kbd> | Cycle backwards through the most recently used workspaces |
| <kbd>Super</kbd><kbd>Ctrl</kbd><kbd>Above_Tab</kbd> | Cycle through the most recently used, taking the active window with you |
| <kbd>Super</kbd><kbd>Ctrl</kbd><kbd>Shift</kbd><kbd>Above_Tab</kbd> | Cycle backwards through the most recently used, taking the active window with you |
| <kbd>Super</kbd><kbd>Page_Down</kbd>/<kbd>Page_Up</kbd> | Cycle sequentially through workspaces |
| <kbd>Super</kbd><kbd>Page_Down</kbd>/<kbd>Page_Up</kbd> | Cycle sequentially through workspaces (from current monitor only) |
| *no default keybinding* | Cycle sequentially through workspaces (from all monitors) |
| <kbd>Super</kbd><kbd>Ctrl</kbd><kbd>Page_Down</kbd>/<kbd>Page_Up</kbd> | Cycle sequentially through workspaces, taking the active window with you |


Expand Down
14 changes: 12 additions & 2 deletions keybindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,18 @@ function setupActions() {
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 @@ -63,6 +63,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
53 changes: 41 additions & 12 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -1523,11 +1523,15 @@ border-radius: ${borderWidth}px;
Gestures.horizontalScroll.bind(this));
}

setMonitor(monitor, animate = false) {
setMonitor(monitor, animate = false, options = {}) {
const commit = options?.commit ?? true;

// Remake the background when we move monitors. The size/scale will be
// incorrect when using fractional scaling.
if (monitor !== this.monitor) {
this.monitor = monitor;
if (commit) {
this.monitor = monitor;
}
this.createBackground();
this.updateBackground();
this.updateColor();
Expand Down Expand Up @@ -1566,8 +1570,7 @@ border-radius: ${borderWidth}px;
background.set_size(this.width, this.height);

this.cloneClip.set_size(monitor.width, monitor.height);
this.cloneClip.set_clip(0, 0,
this.width, this.height);
this.cloneClip.set_clip(0, 0, this.width, this.height);
// transforms break if there's no height
this.cloneContainer.height = this.monitor.height;

Expand Down Expand Up @@ -2156,8 +2159,25 @@ var 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) {
// 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 @@ -2230,22 +2250,27 @@ var 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);
let monitorSpaces;
if (fromAllMonitors) {
monitorSpaces = this._getOrderedSpacesFromAllMonitors(currentSpace.monitor);
} else {
monitorSpaces = this._getOrderedSpaces(currentSpace.monitor);
}

let from = monitorSpaces.indexOf(this.selectedSpace);
let newSpace = this.selectedSpace;
let to = from;

if (move && this.selectedSpace.selectedWindow) {
const navigator = Navigator.getNavigator();
if (!navigator._moving ||
if (navigator._moving === null ||
(Array.isArray(navigator._moving) && navigator._moving.length === 0)) {
takeWindow(this.selectedSpace.selectedWindow,
this.selectedSpace,
Expand Down Expand Up @@ -2284,6 +2309,10 @@ var 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, false, { commit: false });

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

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

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

function moveDownSpace(mw, space) {
Expand Down