cycleWindowWidth: Remember and prefer the originial position

This commit is contained in:
Tor Hedin Brønner
2019-10-25 16:24:12 +02:00
parent 8e6e8a54e6
commit a87f2d60fd
2 changed files with 15 additions and 3 deletions

View File

@@ -152,7 +152,7 @@ function init() {
dynamic_function_ref("setDevGlobals",
Utils));
registerPaperAction("cycle-width",
registerNavigatorAction("cycle-width",
dynamic_function_ref("cycleWindowWidth",
Tiling),
Meta.KeyBindingFlags.PER_WINDOW);

View File

@@ -2580,12 +2580,11 @@ function toggleMaximizeHorizontally(metaWindow) {
}
}
function cycleWindowWidth(metaWindow) {
function cycleWindowWidth(metaWindow, space, {context} = {}) {
let steps = prefs.cycle_width_steps;
let frame = metaWindow.get_frame_rect();
let monitor = Main.layoutManager.monitors[metaWindow.get_monitor()];
let space = spaces.spaceOfWindow(metaWindow);
let workArea = space.workArea();
workArea.x += space.monitor.x;
@@ -2605,6 +2604,19 @@ function cycleWindowWidth(metaWindow) {
// Move the window so it remains fully visible
targetX = workArea.x + workArea.width - minimumMargin() - targetWidth;
}
} else {
context.targetX = context.targetX || space.targetX;
if (space.targetX + space.cloneContainer.width === space.width) {
space.targetX -= targetWidth - frame.width;
} else {
// Prefer the original position
space.targetX = context.targetX;
}
Tweener.addTween(space.cloneContainer,
{ x: space.targetX,
time: prefs.animation_time,
onComplete: space.moveDone.bind(space)
});
}
if (metaWindow.get_maximized() === Meta.MaximizeFlags.BOTH) {