navigator: rewrite finish/destroy code

- 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.
This commit is contained in:
Tor Hedin Brønner
2020-01-25 21:28:22 +01:00
parent 7e25f9ad53
commit 2f58d796ed

View File

@@ -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);
}
}