git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit312b58d0d9bf80fcdc16c51a33dce6b279eac84f
parent63a5afeaf6
authorIsaac Freund <[email protected]>
date2020-07-31 20:22
view: remember floating dimesions

When a floating view is returned to the layout or made fullscreen, it
now saves the dimesions it had while floating and returns to that same
position/size if made to float again.

 river/command/toggle_float.zig      | 7 ++++++-
 river/command/toggle_fullscreen.zig | 4 ++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/river/command/toggle_float.zig b/river/command/toggle_float.zig
index 8f57454..ac33d45 100644
--- a/river/command/toggle_float.zig
+++ b/river/command/toggle_float.zig
@@ -41,10 +41,15 @@ pub fn toggleFloat(
 
         view.pending.float = !view.pending.float;
 
-        // If switching from layout to float, restore the previous floating dimensions
         if (view.pending.float) {
+            // If switching from layout to float, restore the previous floating
+            // dimensions.
             view.pending.box = view.float_box;
             view.configure();
+        } else {
+            // If switching from float to layout save the floating dimensions
+            // for next time.
+            view.float_box = view.current.box;
         }
 
         view.output.root.arrange();
diff --git a/river/command/toggle_fullscreen.zig b/river/command/toggle_fullscreen.zig
index 6e2ac2d..92f99f3 100644
--- a/river/command/toggle_fullscreen.zig
+++ b/river/command/toggle_fullscreen.zig
@@ -41,6 +41,10 @@ pub fn toggleFullscreen(
         view.setFullscreen(!view.pending.fullscreen);
 
         if (view.pending.fullscreen) {
+            // If transitioning from float -> fullscreen, save the floating
+            // dimensions.
+            if (view.pending.float) view.float_box = view.current.box;
+
             const output = view.output;
             view.pending.box = Box.fromWlrBox(
                 c.wlr_output_layout_get_box(output.root.wlr_output_layout, output.wlr_output).*,