OutputStatus: rework implementation

This was motivated by the view tags not being proplerly updated by
Root.commitTransaction() when there were no views on an output.
This commit is contained in:
Isaac Freund
2023-02-28 17:45:08 +01:00
parent be4330288d
commit 005bde367c
5 changed files with 159 additions and 140 deletions

View File

@ -159,11 +159,13 @@ fn handleRequest(layout: *river.LayoutV3, request: river.LayoutV3.Request, self:
if (layout_demand.serial == req.serial) layout_demand.apply(self);
}
if (self.output.layout_name) |name| {
util.gpa.free(name);
}
self.output.layout_name = util.gpa.dupeZ(u8, mem.span(req.layout_name)) catch null;
self.output.sendLayoutName();
const new_name = util.gpa.dupeZ(u8, mem.sliceTo(req.layout_name, 0)) catch {
log.err("out of memory", .{});
return;
};
if (self.output.layout_name) |name| util.gpa.free(name);
self.output.layout_name = new_name;
self.output.status.sendLayoutName(self.output);
},
}
}
@ -194,7 +196,7 @@ pub fn destroy(self: *Self) void {
if (self.output.layout_name) |name| {
util.gpa.free(name);
self.output.layout_name = null;
self.output.sendLayoutNameClear();
self.output.status.sendLayoutNameClear(self.output);
}
}