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.
This commit is contained in:
Tor Hedin Brønner
2018-06-27 10:22:07 +02:00
parent b48ed8b2bd
commit 07ab09ec84
+10 -5
View File
@@ -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);