From 2f58d796edb37eb31cc5e9ce5507dfac8bcd5c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Hedin=20Br=C3=B8nner?= Date: Sat, 25 Jan 2020 21:28:22 +0100 Subject: [PATCH] navigator: rewrite finish/destroy code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Activate destination workspace if it isn't active, fake it if not. If a «stuck» window have focus, consider it selected. If selected window or one its transient window has focus, fake focus handler. Otherwise activate it. --- navigator.js | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/navigator.js b/navigator.js index ffb7679..5e9be50 100644 --- a/navigator.js +++ b/navigator.js @@ -278,36 +278,29 @@ var Navigator = class Navigator { monitor.clickOverlay.activate(); } - if (this.space === from && force) { + if (this.space === from) { // Animate the selected space into full view - normally this // happens on workspace switch, but activating the same workspace // again doesn't trigger a switch signal - Tiling.spaces.animateToSpace(this.space); + force && Tiling.spaces.animateToSpace(this.space); + } else { + this.space.workspace.activate(global.get_current_time()); } selected = this.space.indexOf(selected) !== -1 ? selected : this.space.selectedWindow; - if (Tiling.inGrab && Tiling.inGrab.dnd) { - Tiling.spaces.monitors.set(this.monitor, this.space); - Tiling.spaces.animateToSpace(this.space); - } else { - if (selected && - (!force || - !(display.focus_window && display.focus_window.is_on_all_workspaces())) ) { + let focus = display.focus_window; + if (focus && focus.is_on_all_workspaces()) + selected = focus; - let hasFocus = selected.has_focus(); - selected.foreach_transient(mw => hasFocus = mw.has_focus() || hasFocus); - if (!hasFocus) { - Main.activateWindow(selected); - } else { - // Typically on cancel - the `focus` signal won't run - // automatically, so we run it manually - this.space.workspace.activate(global.get_current_time()); - Tiling.focus_handler(selected); - } + if (selected) { + let hasFocus = selected && selected.has_focus(); + selected.foreach_transient(mw => hasFocus = mw.has_focus() || hasFocus); + if (hasFocus) { + Tiling.focus_handler(selected) } else { - this.space.workspace.activate(global.get_current_time()); + Main.activateWindow(selected); } }