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

commit7353dda712e26516adf75a58848760382c46c129
parentc2eb4b493a
authorIsaac Freund <[email protected]>
date2024-04-19 13:42
XdgToplevel: update clip on geometry x/y change

Currently if a client commits a geometry with a different x/y value but
does not change the width/height we might not update the clip
coordinates of the surface tree, potentially causing part of the surface
to be unintentionally clipped off.

To fix this, check for change in geometry x/y as well as width/height on
commit if the client is not currently part of an ongoing transaction.

Firefox for example it seems may respond to a configure non-atomically
with multiple commits:

1. commit new buffer and new geometry of a new width/height.
2. commit again with the same width/height but a new geometry x/y.

I don't think this is technically a bug but it doesn't seem like the
most efficient way to do things. I think this may also cause imperfect
frames. In any case, this should no longer cause river to crop off part
of firefox's surface.

 river/XdgToplevel.zig | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/river/XdgToplevel.zig b/river/XdgToplevel.zig
index 438794c..909845a 100644
--- a/river/XdgToplevel.zig
+++ b/river/XdgToplevel.zig
@@ -352,6 +352,11 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
                 view.pending.box.height = toplevel.geometry.height;
                 view.current = view.inflight;
                 view.updateSceneState();
+            } else if (old_geometry.x != toplevel.geometry.x or
+                old_geometry.y != toplevel.geometry.y)
+            {
+                // We need to update the surface clip box to reflect the geometry change.
+                view.updateSceneState();
             }
         },
         // If the client has not yet acked our configure, we need to send a