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

commitc4d663bda982dcaad3c5b1224dda660c98815be0
parentb9d855e17d
authorVäinö Mäkelä <[email protected]>
date2023-05-08 20:36
XdgToplevel: keep wlroots updated on view sizes

When sending a configure, wlroots will send the same size that was sent
on the previous configure unless a new size is set. If a client resizes
their window itself, the size wlroots has in
XdgToplevel.scheduled will be obsolete and needs to be updated by river.

 river/XdgToplevel.zig | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/river/XdgToplevel.zig b/river/XdgToplevel.zig
index bcb7bb6..0b5296c 100644
--- a/river/XdgToplevel.zig
+++ b/river/XdgToplevel.zig
@@ -139,6 +139,11 @@ pub fn configure(self: *Self) bool {
 
     _ = self.xdg_toplevel.setResizing(inflight.resizing);
 
+    // We need to call this wlroots function even if the inflight dimensions
+    // match the current dimensions in order to prevent wlroots internal state
+    // from getting out of sync in the case where a client has resized itself.
+    const configure_serial = self.xdg_toplevel.setSize(inflight.box.width, inflight.box.height);
+
     // Only track configures with the transaction system if they affect the dimensions of the view.
     if (inflight.box.width == current.box.width and
         inflight.box.height == current.box.height)
@@ -147,7 +152,7 @@ pub fn configure(self: *Self) bool {
     }
 
     self.configure_state = .{
-        .inflight = self.xdg_toplevel.setSize(inflight.box.width, inflight.box.height),
+        .inflight = configure_serial,
     };
 
     return true;