diff --git a/keybindings.js b/keybindings.js index d73ec0b..ff2cfda 100644 --- a/keybindings.js +++ b/keybindings.js @@ -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); diff --git a/tiling.js b/tiling.js index 19b76b6..c7e3771 100644 --- a/tiling.js +++ b/tiling.js @@ -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) {