From 0d1fc33d982b30d60722650b87293ab5e16eb6a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Br=C3=B8nner?= Date: Sat, 23 Sep 2017 11:29:01 +0200 Subject: [PATCH] Update selectedWindow when a window in a inactive WS is closed/moved --- tiling.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tiling.js b/tiling.js index 47d2585..a0028a1 100644 --- a/tiling.js +++ b/tiling.js @@ -431,6 +431,20 @@ remove_handler = (workspace, meta_window) => { delete meta_window[focus_signal]; } + if (space.selectedWindow === meta_window) { + // Window closed or moved when other workspace is active so no new focus + // has been assigned in this workspace. + // Ideally we'd get the window that will get focus when this workspace + // is activated again, but the function mutter use doesn't seem to be + // exposed to javascript. + + // Use the top window in the MRU list as a proxy: + let mru_list = global.display.get_tab_list(Meta.TabList.NORMAL, workspace); + // The mru list might contain needy windows from other workspaces + space.selectedWindow = + mru_list.filter(w => w.get_workspace() === workspace)[0]; + } + // Force a new ensure, since the focus_handler is run before window-removed ensure_viewport(space.selectedWindow, true) }