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

commit445e66aed6cc56f2d15f7276d6a61eac68c33a91
parent3a11b9913e
authorIsaac Freund <[email protected]>
date2024-06-28 13:14
river: remove float special casing

 river/Output.zig       | 13 ++++---------
 river/Root.zig         | 19 ++-----------------
 river/View.zig         |  3 ---
 river/XdgToplevel.zig  | 24 ++++--------------------
 river/XwaylandView.zig | 19 ++-----------------
 5 files changed, 12 insertions(+), 66 deletions(-)

diff --git a/river/Output.zig b/river/Output.zig
index c6c3011..2e561fe 100644
--- a/river/Output.zig
+++ b/river/Output.zig
@@ -46,8 +46,6 @@ pub const PendingState = struct {
     focus_stack: wl.list.Head(View, .pending_focus_stack_link),
     /// The stack of views acted upon by window management commands such
     /// as focus-view, zoom, etc.
-    ///
-    /// This includes both floating/fullscreen views and those arranged in the layout.
     wm_stack: wl.list.Head(View, .pending_wm_stack_link),
 };
 
@@ -78,17 +76,15 @@ layers: struct {
     background: *wlr.SceneTree,
     /// Bottom layer shell layer
     bottom: *wlr.SceneTree,
-    /// Views in the layout
-    layout: *wlr.SceneTree,
-    /// Floating views
-    float: *wlr.SceneTree,
+    /// Windows and shell surfaces of the window manager
+    wm: *wlr.SceneTree,
     /// Top layer shell layer
     top: *wlr.SceneTree,
     /// Fullscreen views
     fullscreen: *wlr.SceneTree,
     /// Overlay layer shell layer
     overlay: *wlr.SceneTree,
-    /// Popups from xdg-shell and input-method-v2 clients.
+    /// Popups from xdg-shell and input-method-v2 clients
     popups: *wlr.SceneTree,
 },
 
@@ -226,8 +222,7 @@ pub fn create(wlr_output: *wlr.Output) !void {
             ),
             .background = try normal_content.createSceneTree(),
             .bottom = try normal_content.createSceneTree(),
-            .layout = try normal_content.createSceneTree(),
-            .float = try normal_content.createSceneTree(),
+            .wm = try normal_content.createSceneTree(),
             .top = try normal_content.createSceneTree(),
             .fullscreen = try normal_content.createSceneTree(),
             .overlay = try normal_content.createSceneTree(),
diff --git a/river/Root.zig b/river/Root.zig
index 4f043d9..ad6afa7 100644
--- a/river/Root.zig
+++ b/river/Root.zig
@@ -452,15 +452,6 @@ pub fn applyPending(root: *Root) void {
                 while (it.next()) |view| {
                     assert(view.pending.output == output);
 
-                    if (view.current.float and !view.pending.float) {
-                        // If switching from float to non-float, save the dimensions.
-                        view.float_box = view.current.box;
-                    } else if (!view.current.float and view.pending.float) {
-                        // If switching from non-float to float, apply the saved float dimensions.
-                        view.pending.box = view.float_box;
-                        view.pending.clampToOutput();
-                    }
-
                     if (!view.current.fullscreen and view.pending.fullscreen) {
                         view.post_fullscreen_box = view.pending.box;
                         view.pending.box = .{ .x = 0, .y = 0, .width = undefined, .height = undefined };
@@ -601,17 +592,11 @@ fn commitTransaction(root: *Root) void {
             if (view.current.output != view.inflight.output or
                 (output.current.fullscreen == view and output.inflight.fullscreen != view))
             {
-                if (view.inflight.float) {
-                    view.tree.node.reparent(output.layers.float);
-                }
+                view.tree.node.reparent(output.layers.wm);
                 view.popup_tree.node.reparent(output.layers.popups);
             }
 
-            if (view.current.float != view.inflight.float) {
-                if (view.inflight.float) {
-                    view.tree.node.reparent(output.layers.float);
-                }
-            }
+            view.tree.node.reparent(output.layers.wm);
 
             view.commitTransaction();
 
diff --git a/river/View.zig b/river/View.zig
index 53e021b..74353df 100644
--- a/river/View.zig
+++ b/river/View.zig
@@ -66,7 +66,6 @@ pub const State = struct {
     /// Number of seats currently focusing the view
     focus: u32 = 0,
 
-    float: bool = false,
     fullscreen: bool = false,
     urgent: bool = false,
     ssd: bool = false,
@@ -513,8 +512,6 @@ pub fn setPendingOutput(view: *View, output: *Output) void {
     if (view.pending.fullscreen) {
         view.pending.box = .{ .x = 0, .y = 0, .width = undefined, .height = undefined };
         output.wlr_output.effectiveResolution(&view.pending.box.width, &view.pending.box.height);
-    } else if (view.pending.float) {
-        view.pending.clampToOutput();
     }
 }
 
diff --git a/river/XdgToplevel.zig b/river/XdgToplevel.zig
index d9bfd7e..481659a 100644
--- a/river/XdgToplevel.zig
+++ b/river/XdgToplevel.zig
@@ -125,9 +125,6 @@ pub fn configure(toplevel: *XdgToplevel) bool {
     const inflight = &toplevel.view.inflight;
     const current = &toplevel.view.current;
 
-    const inflight_float = inflight.float;
-    const current_float = current.float;
-
     // We avoid a special case for newly mapped views which we have not yet
     // configured by setting the current width/height to the initial width/height
     // of the view in handleMap().
@@ -135,7 +132,6 @@ pub fn configure(toplevel: *XdgToplevel) bool {
         inflight.box.height == current.box.height and
         (inflight.focus != 0) == (current.focus != 0) and
         inflight.fullscreen == current.fullscreen and
-        inflight_float == current_float and
         inflight.ssd == current.ssd and
         inflight.resizing == current.resizing)
     {
@@ -161,7 +157,8 @@ pub fn configure(toplevel: *XdgToplevel) bool {
     _ = wlr_toplevel.setFullscreen(inflight.fullscreen);
     _ = wlr_toplevel.setResizing(inflight.resizing);
 
-    if (inflight_float) {
+    // TODO
+    if (true) {
         _ = wlr_toplevel.setTiled(.{ .top = false, .bottom = false, .left = false, .right = false });
     } else {
         _ = wlr_toplevel.setTiled(.{ .top = true, .bottom = true, .left = true, .right = true });
@@ -246,16 +243,6 @@ fn handleMap(listener: *wl.Listener(void)) void {
     view.inflight.box = view.pending.box;
     view.current.box = view.pending.box;
 
-    const state = &toplevel.wlr_toplevel.current;
-    const has_fixed_size = state.min_width != 0 and state.min_height != 0 and
-        (state.min_width == state.max_width or state.min_height == state.max_height);
-
-    if (toplevel.wlr_toplevel.parent != null or has_fixed_size) {
-        // If the toplevel.wlr_toplevel has a parent or has a fixed size make it float.
-        // This will be overwritten in View.map() if the view is matched by a rule.
-        view.pending.float = true;
-    }
-
     toplevel.view.pending.fullscreen = toplevel.wlr_toplevel.requested.fullscreen;
 
     view.map() catch {
@@ -347,7 +334,8 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
                     "client initiated size change: {}x{} -> {}x{}",
                     .{ old_geometry.width, old_geometry.height, toplevel.geometry.width, toplevel.geometry.height },
                 );
-                if (!view.current.float and !view.current.fullscreen) {
+                // TODO check tiled state
+                if (!view.current.fullscreen) {
                     // It seems that a disappointingly high number of clients have a buggy
                     // response to configure events. They ack the configure immediately but then
                     // proceed to make one or more wl_surface.commit requests with the old size
@@ -426,8 +414,6 @@ fn handleRequestMove(
 
     if (view.pending.fullscreen) return;
 
-    if (!view.pending.float) return;
-
     // Moving windows with touch or tablet tool is not yet supported.
     if (seat.wlr_seat.validatePointerGrabSerial(null, event.serial)) {
         switch (seat.cursor.mode) {
@@ -444,8 +430,6 @@ fn handleRequestResize(listener: *wl.Listener(*wlr.XdgToplevel.event.Resize), ev
 
     if (view.pending.fullscreen) return;
 
-    if (!view.pending.float) return;
-
     // Resizing windows with touch or tablet tool is not yet supported.
     if (seat.wlr_seat.validatePointerGrabSerial(null, event.serial)) {
         switch (seat.cursor.mode) {
diff --git a/river/XwaylandView.zig b/river/XwaylandView.zig
index ba40554..c70d03f 100644
--- a/river/XwaylandView.zig
+++ b/river/XwaylandView.zig
@@ -188,19 +188,6 @@ pub fn handleMap(listener: *wl.Listener(void)) void {
     view.inflight.box = view.pending.box;
     view.current.box = view.pending.box;
 
-    // A value of -1 seems to indicate being unset for these size hints.
-    const has_fixed_size = if (xwayland_view.xwayland_surface.size_hints) |size_hints|
-        size_hints.min_width > 0 and size_hints.min_height > 0 and
-            (size_hints.min_width == size_hints.max_width or size_hints.min_height == size_hints.max_height)
-    else
-        false;
-
-    if (xwayland_view.xwayland_surface.parent != null or has_fixed_size) {
-        // If the toplevel has a parent or has a fixed size make it float by default.
-        // This will be overwritten in View.map() if the view is matched by a rule.
-        view.pending.float = true;
-    }
-
     // This will be overwritten in View.map() if the view is matched by a rule.
     view.pending.ssd = !xwayland_surface.decorations.no_border;
 
@@ -246,10 +233,8 @@ fn handleRequestConfigure(
     }
 
     // Allow xwayland views to set their own dimensions (but not position) if floating
-    if (xwayland_view.view.pending.float) {
-        xwayland_view.view.pending.box.width = event.width;
-        xwayland_view.view.pending.box.height = event.height;
-    }
+    xwayland_view.view.pending.box.width = event.width;
+    xwayland_view.view.pending.box.height = event.height;
     server.root.applyPending();
 }