aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <mail@isaacfreund.com>2023-03-09 23:14:26 +0100
committerIsaac Freund <mail@isaacfreund.com>2023-03-09 23:14:26 +0100
commit0de3f678984c55ff87bbf2d2f1d162072c16d560 (patch)
treeed25048c9e576a5fbcdbbe9aed0b2b93eb8301d9
parentebfa892d95688aa9a5f1e3c822515765cb9a2169 (diff)
downloadriver-0de3f678984c55ff87bbf2d2f1d162072c16d560.tar.gz
river-0de3f678984c55ff87bbf2d2f1d162072c16d560.tar.xz
river-status: only send layout name if changed
-rw-r--r--river/Layout.zig19
1 files changed, 12 insertions, 7 deletions
diff --git a/river/Layout.zig b/river/Layout.zig
index 351c116..34a96c0 100644
--- a/river/Layout.zig
+++ b/river/Layout.zig
@@ -159,13 +159,18 @@ fn handleRequest(layout: *river.LayoutV3, request: river.LayoutV3.Request, self:
if (layout_demand.serial == req.serial) layout_demand.apply(self);
}
- 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);
+ const new_name = mem.sliceTo(req.layout_name, 0);
+ if (self.output.layout_name == null or
+ !mem.eql(u8, self.output.layout_name.?, new_name))
+ {
+ const owned = util.gpa.dupeZ(u8, new_name) catch {
+ log.err("out of memory", .{});
+ return;
+ };
+ if (self.output.layout_name) |name| util.gpa.free(name);
+ self.output.layout_name = owned;
+ self.output.status.sendLayoutName(self.output);
+ }
},
}
}