From 07ab09ec849a3dfaa60c5e1c4d982cdf11e382f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Hedin=20Br=C3=B8nner?= Date: Tue, 26 Jun 2018 14:04:54 +0200 Subject: [PATCH] Fix moving selected window to another monitor/space Let focus follow the selected window. This caused issues in the past, but seems to work now. It actually makes the switch more reliable, squashing a weird bug where changing to another after moving a window would trigger the native switch workspace animation. In `moveSizeHandler` we need to check the coordinates of the window against the monitor because `metaWindow.get_monitor()` reports the old monitor. We also need to force ensure when inserting a window into a workspace that's not active. --- tiling.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tiling.js b/tiling.js index bc02646..b6a0b96 100644 --- a/tiling.js +++ b/tiling.js @@ -687,8 +687,8 @@ class Spaces extends Map { metaWindow.change_workspace(space.workspace); // This doesn't play nice with the clickoverlay, disable for now - // if (focus) - // Main.activateWindow(metaWindow); + if (focus) + Main.activateWindow(metaWindow); } } @@ -984,11 +984,12 @@ function insertWindow(metaWindow, {existing}) { }); } - if (space.workspace === global.screen.get_active_workspace()) { + if (metaWindow === global.display.focus_window || + space.workspace === global.screen.get_active_workspace()) { ensureViewport(metaWindow, space, true); Main.activateWindow(metaWindow); } else { - ensureViewport(space.selectedWindow, space); + ensureViewport(space.selectedWindow, space, true); } } @@ -1284,11 +1285,15 @@ function moveSizeHandler(metaWindow) { let frame = metaWindow.get_frame_rect(); let monitor = space.monitor; + if (frame.x + frame.width <= monitor.x || + frame.y + frame.height <= monitor.y || + frame.x >= monitor.x + monitor.width || + frame.y >= monitor.y + monitor.height) + return; const x = frame.x - monitor.x; let onComplete = !noAnimate && (() => space.emit('move-done')); move_to(space, metaWindow, {x: x, onComplete}); - updateSelection(space, noAnimate); } var moveSizeHandlerWrapper = utils.dynamic_function_ref("moveSizeHandler", Me);