From 3c2471cb11ef802fc603fdcc31c845e70ee82ff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Hedin=20Br=C3=B8nner?= Date: Thu, 15 Feb 2018 20:37:26 +0100 Subject: [PATCH] Focus the right neighbour when closing a window Mutter hands focus to the "highest" window when a window is closed. This means we need to raise windows from the edges in towards the selected window, making the neighbours of the selected window the next highest windows. In particular since we propagate backwards last, the right neighbour will get priority. --- tiling.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tiling.js b/tiling.js index 3e7761b..7b9e007 100644 --- a/tiling.js +++ b/tiling.js @@ -518,10 +518,16 @@ function propogate_forward(space, n, x, gap) { stackWindow(space, i, DIRECTION.Right); } StackOverlay.rightOverlay.setTarget(meta_window); + + // Set stack levels in the correct order, as the the "highest" window + // will have priority when handing out focus + let selected = space.selectedIndex(); + for (let i=n; i > selected; i--) { + space[i].raise(); + } return; } meta_window._isStacked = false; - meta_window.raise(); gap = gap || window_gap; let actor = meta_window.get_compositor_private(); @@ -549,10 +555,14 @@ function propogate_backward(space, n, x, gap) { stackWindow(space, i, DIRECTION.Left); } StackOverlay.leftOverlay.setTarget(meta_window); + + let selected = space.selectedIndex(); + for (let i=n; i <= selected; i++) { + space[i].raise(); + } return; } meta_window._isStacked = false; - meta_window.raise(); gap = gap || window_gap; let actor = meta_window.get_compositor_private();