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

commitaf3ad5eaeb4a340fb433d3fca808e097137bd013
parent0be01ced3f
authorIsaac Freund <[email protected]>
date2023-03-06 20:43
xdg-shell: determine tiled state by float state

How river currently sets this isn't really in accordance with the spirit
of the protocol. It was originally done this way to get gtk3 windows to
look a little bit better with borders drawn around them. However, I've
come to believe that river shouldn't just ignore standards like this.

The right way to do things would be to either implement the
xdg-decoration protocol for gtk properly or to be pragmatic and accept
some programs are intended to be used with CSD and that's OK.

 river/XdgToplevel.zig | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/river/XdgToplevel.zig b/river/XdgToplevel.zig
index d5e84f9..1a9b983 100644
--- a/river/XdgToplevel.zig
+++ b/river/XdgToplevel.zig
@@ -98,15 +98,20 @@ pub fn configure(self: *Self) bool {
     const inflight = &self.view.inflight;
     const current = &self.view.current;
 
+    const inflight_fullscreen = inflight.output != null and inflight.output.?.inflight.fullscreen == self.view;
+    const current_fullscreen = current.output != null and current.output.?.current.fullscreen == self.view;
+
+    const inflight_float = inflight.float or (inflight.output != null and inflight.output.?.layout == null);
+    const current_float = current.float or (current.output != null and current.output.?.layout == null);
+
     // 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().
     if (inflight.box.width == current.box.width and
         inflight.box.height == current.box.height and
         (inflight.focus != 0) == (current.focus != 0) and
-        (inflight.output != null and inflight.output.?.inflight.fullscreen == self.view) ==
-        (current.output != null and current.output.?.current.fullscreen == self.view) and
-        inflight.borders == current.borders and
+        inflight_fullscreen == current_fullscreen and
+        inflight_float == current_float and
         inflight.resizing == current.resizing)
     {
         return false;
@@ -114,13 +119,12 @@ pub fn configure(self: *Self) bool {
 
     _ = self.xdg_toplevel.setActivated(inflight.focus != 0);
 
-    const fullscreen = inflight.output != null and inflight.output.?.inflight.fullscreen == self.view;
-    _ = self.xdg_toplevel.setFullscreen(fullscreen);
+    _ = self.xdg_toplevel.setFullscreen(inflight_fullscreen);
 
-    if (inflight.borders) {
-        _ = self.xdg_toplevel.setTiled(.{ .top = true, .bottom = true, .left = true, .right = true });
-    } else {
+    if (inflight_float) {
         _ = self.xdg_toplevel.setTiled(.{ .top = false, .bottom = false, .left = false, .right = false });
+    } else {
+        _ = self.xdg_toplevel.setTiled(.{ .top = true, .bottom = true, .left = true, .right = true });
     }
 
     _ = self.xdg_toplevel.setResizing(inflight.resizing);