XdgToplevel: work around buggy clients

Unfortunately, clients in the wild sometimes get the
configure/ack_configure/commit sequence wrong, committing the configured
surface with a size different than the one they ack'd only to later in
separate commit adpat the surface size to that requested by the
compositor.

Improve river's handling of such buggy clients to keep river's ssd
borders and internal state consistent with whatever the clients actually
commit regardless of the correctness of the clients. Log a shame message
for such clients to make me feel better about working around their bugs.
This commit is contained in:
Isaac Freund 2024-02-22 10:24:36 +01:00
parent 9b2d99fa79
commit 95da9b5875
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
2 changed files with 18 additions and 13 deletions

View File

@ -324,10 +324,6 @@ pub fn commitTransaction(view: *Self) void {
}
pub fn updateCurrent(view: *Self) void {
// Applied already in View.commitTransaction()
assert(view.current.tags == view.inflight.tags);
assert(view.current.output == view.inflight.output);
view.current = view.inflight;
const box = &view.current.box;

View File

@ -348,19 +348,28 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
const no_layout = view.current.output != null and view.current.output.?.layout == null;
if (size_changed) {
log.info(
log.debug(
"client initiated size change: {}x{} -> {}x{}",
.{ old_geometry.width, old_geometry.height, self.geometry.width, self.geometry.height },
);
if ((view.current.float or no_layout) and !view.current.fullscreen) {
view.current.box.width = self.geometry.width;
view.current.box.height = self.geometry.height;
view.pending.box.width = self.geometry.width;
view.pending.box.height = self.geometry.height;
server.root.applyPending();
} else {
log.err("client is buggy and initiated size change while tiled or fullscreen", .{});
if (!(view.current.float or no_layout) and !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
// before updating the size of the surface. This obviously makes river's
// efforts towards frame perfection futile for such clients. However, in the
// interest of best serving river's users we will fix up their size here after
// logging a shame message.
log.err("client with app-id '{s}' is buggy and initiated size change while tiled or fullscreen, shame on it", .{
view.getAppId() orelse "",
});
}
view.inflight.box.width = self.geometry.width;
view.inflight.box.height = self.geometry.height;
view.pending.box.width = self.geometry.width;
view.pending.box.height = self.geometry.height;
view.updateCurrent();
}
},
// If the client has not yet acked our configure, we need to send a