Skip to content

Commit 439c318

Browse files
committed
Allow switching away from spaces with no windows
Now that we can switch from a window to an empty space, it's awkward if we can't switch from an empty space back to a window. We need to change the KeybindingFlags because when you set PER_WINDOW, gnome-shell doesn't activate the keybinding unless a window is selected.
1 parent bde1f57 commit 439c318

File tree

2 files changed

+55
-20
lines changed

2 files changed

+55
-20
lines changed

keybindings.js

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,38 @@ export function setupActions(settings) {
222222
registerMinimapAction("switch-eleventh", (mw, space) => Tiling.activateNthWindow(10, space));
223223
registerMinimapAction("switch-last", Tiling.activateLastWindow);
224224

225-
registerMinimapAction("switch-global-right", (mw, space) => space.switchGlobalRight());
226-
registerMinimapAction("switch-global-left", (mw, space) => space.switchGlobalLeft());
227-
registerMinimapAction("switch-global-up", (mw, space) => space.switchGlobalUp());
228-
registerMinimapAction("switch-global-down", (mw, space) => space.switchGlobalDown());
225+
registerAction("switch-global-right", (_mw, space) => {
226+
space.switchGlobalRight()
227+
}, {
228+
settings: keybindSettings,
229+
opensNavigator: true,
230+
opensMinimap: true,
231+
mutterFlags: Meta.KeyBindingFlags.NONE,
232+
});
233+
registerAction("switch-global-left", (_mw, space) => {
234+
space.switchGlobalLeft()
235+
}, {
236+
settings: keybindSettings,
237+
opensNavigator: true,
238+
opensMinimap: true,
239+
mutterFlags: Meta.KeyBindingFlags.NONE,
240+
});
241+
registerAction("switch-global-up", (_mw, space) => {
242+
space.switchGlobalUp()
243+
}, {
244+
settings: keybindSettings,
245+
opensNavigator: true,
246+
opensMinimap: true,
247+
mutterFlags: Meta.KeyBindingFlags.NONE,
248+
});
249+
registerAction("switch-global-down", (_mw, space) => {
250+
space.switchGlobalDown()
251+
}, {
252+
settings: keybindSettings,
253+
opensNavigator: true,
254+
opensMinimap: true,
255+
mutterFlags: Meta.KeyBindingFlags.NONE,
256+
});
229257

230258
registerMinimapAction("move-left",
231259
(_mw, space) => space.swap(Meta.MotionDirection.LEFT));

tiling.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,22 +1197,9 @@ export class Space extends Array {
11971197
[Meta.MotionDirection.DOWN]: Meta.DisplayDirection.DOWN,
11981198
};
11991199
const dir = motionToDisplayDirection[direction]
1200-
12011200
let space = this;
1202-
let index = space.selectedIndex();
1203-
if (index === -1) {
1204-
return;
1205-
}
1206-
let row = space[index].indexOf(space.selectedWindow);
12071201

1208-
switch (direction) {
1209-
case Meta.MotionDirection.RIGHT:
1210-
index++;
1211-
break;
1212-
case Meta.MotionDirection.LEFT:
1213-
index--;
1214-
}
1215-
if (index < 0 || index >= space.length) {
1202+
const switchMonitor = () => {
12161203
const monitor = focusMonitor();
12171204
const i = display.get_monitor_neighbor_index(monitor.index, dir);
12181205
if (i === -1) {
@@ -1221,7 +1208,9 @@ export class Space extends Array {
12211208

12221209
// Ensure if we change workspaces and then monitors,
12231210
// that the new workspace stays active on the starting monitor.
1224-
space.activateWithFocus(space.selectedWindow, false, true);
1211+
if (space.selectedWindow) {
1212+
space.activateWithFocus(space.selectedWindow, false, true);
1213+
}
12251214

12261215
const newMonitor = Main.layoutManager.monitors[i];
12271216
const newSpace = spaces.monitors.get(newMonitor);
@@ -1247,7 +1236,25 @@ export class Space extends Array {
12471236
const newWindow = sortWindows(newSpace, newColumn)[newColumn.length - 1];
12481237

12491238
ensureViewport(newWindow, newSpace);
1250-
return
1239+
};
1240+
1241+
let index = space.selectedIndex();
1242+
if (index === -1) {
1243+
switchMonitor();
1244+
return;
1245+
}
1246+
let row = space[index].indexOf(space.selectedWindow);
1247+
1248+
switch (direction) {
1249+
case Meta.MotionDirection.RIGHT:
1250+
index++;
1251+
break;
1252+
case Meta.MotionDirection.LEFT:
1253+
index--;
1254+
}
1255+
if (index < 0 || index >= space.length) {
1256+
switchMonitor();
1257+
return;
12511258
}
12521259

12531260
let column = space[index];

0 commit comments

Comments
 (0)