river-status: only send layout name if changed

This commit is contained in:
Isaac Freund 2023-03-09 23:14:26 +01:00
parent ebfa892d95
commit 0de3f67898
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11

View File

@ -159,13 +159,18 @@ fn handleRequest(layout: *river.LayoutV3, request: river.LayoutV3.Request, self:
if (layout_demand.serial == req.serial) layout_demand.apply(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 { const new_name = mem.sliceTo(req.layout_name, 0);
log.err("out of memory", .{}); if (self.output.layout_name == null or
return; !mem.eql(u8, self.output.layout_name.?, new_name))
}; {
if (self.output.layout_name) |name| util.gpa.free(name); const owned = util.gpa.dupeZ(u8, new_name) catch {
self.output.layout_name = new_name; log.err("out of memory", .{});
self.output.status.sendLayoutName(self.output); return;
};
if (self.output.layout_name) |name| util.gpa.free(name);
self.output.layout_name = owned;
self.output.status.sendLayoutName(self.output);
}
}, },
} }
} }