Skip to content
Draft
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
36 changes: 32 additions & 4 deletions keybindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,38 @@ export function setupActions(settings) {
registerMinimapAction("switch-eleventh", (mw, space) => Tiling.activateNthWindow(10, space));
registerMinimapAction("switch-last", Tiling.activateLastWindow);

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());
registerAction("switch-global-right", (_mw, space) => {
space.switchGlobalRight()
}, {
settings: keybindSettings,
opensNavigator: true,
opensMinimap: true,
mutterFlags: Meta.KeyBindingFlags.NONE,
});
registerAction("switch-global-left", (_mw, space) => {
space.switchGlobalLeft()
}, {
settings: keybindSettings,
opensNavigator: true,
opensMinimap: true,
mutterFlags: Meta.KeyBindingFlags.NONE,
});
registerAction("switch-global-up", (_mw, space) => {
space.switchGlobalUp()
}, {
settings: keybindSettings,
opensNavigator: true,
opensMinimap: true,
mutterFlags: Meta.KeyBindingFlags.NONE,
});
registerAction("switch-global-down", (_mw, space) => {
space.switchGlobalDown()
}, {
settings: keybindSettings,
opensNavigator: true,
opensMinimap: true,
mutterFlags: Meta.KeyBindingFlags.NONE,
});

registerMinimapAction("move-left",
(_mw, space) => space.swap(Meta.MotionDirection.LEFT));
Expand Down
62 changes: 38 additions & 24 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -1197,22 +1197,9 @@ export class Space extends Array {
[Meta.MotionDirection.DOWN]: Meta.DisplayDirection.DOWN,
};
const dir = motionToDisplayDirection[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) {
const switchMonitor = () => {
const monitor = focusMonitor();
const i = display.get_monitor_neighbor_index(monitor.index, dir);
if (i === -1) {
Expand All @@ -1221,26 +1208,53 @@ export class Space extends Array {

// Ensure if we change workspaces and then monitors,
// that the new workspace stays active on the starting monitor.
space.activateWithFocus(space.selectedWindow, false, true);
if (space.selectedWindow) {
space.activateWithFocus(space.selectedWindow, false, true);
}

const newMonitor = Main.layoutManager.monitors[i];
const newSpace = spaces.monitors.get(newMonitor);

newSpace.activate(false, false);
Navigator.finishNavigation();

// New monitor is empty, just move the mouse there
if (newSpace.length === 0) {
Utils.warpPointerToMonitor(newMonitor);
return;
}

Navigator.getNavigator().showMinimap(newSpace);

const visibleColumns = newSpace.filter((column) => newSpace.isVisible(column[0]));
if (visibleColumns.length === 0) {
return;
}

const newColumn = dir === Meta.DisplayDirection.LEFT
? visibleColumns[visibleColumns.length - 1]
: visibleColumns[0];
const newRow = Math.min(row, newColumn.length - 1);
const newWindow = newColumn[newRow];
const newIndex = dir === Meta.DisplayDirection.LEFT ? visibleColumns.length - 1 : 0;
const newColumn = visibleColumns[newIndex];
const newWindow = sortWindows(newSpace, newColumn)[newColumn.length - 1];

newSpace.activate(false, false);
Navigator.finishNavigation();
Navigator.getNavigator().showMinimap(newSpace);
ensureViewport(newWindow, newSpace);
return
};

let index = space.selectedIndex();
if (index === -1) {
switchMonitor();
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) {
switchMonitor();
return;
}

let column = space[index];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: apply to switching vertically, too. So far I was just focused on horizontally because that's what I use; I don't have any monitors laid out vertically.

Expand Down