river-options: free options of destroyed outputs
This is done when river's internal Output struct is destroyed, not when the advertised wl_output global is removed. This means that options will persist when an output is disabled and re-enabled.
This commit is contained in:
parent
18bab45d4c
commit
cd005e15f8
3 changed files with 10 additions and 0 deletions
|
@ -67,6 +67,7 @@ pub fn destroy(self: *Self) void {
|
||||||
var it = self.handles.safeIterator(.forward);
|
var it = self.handles.safeIterator(.forward);
|
||||||
while (it.next()) |handle| handle.destroy();
|
while (it.next()) |handle| handle.destroy();
|
||||||
if (self.value == .string) if (self.value.string) |s| util.gpa.free(mem.span(s));
|
if (self.value == .string) if (self.value.string) |s| util.gpa.free(mem.span(s));
|
||||||
|
self.link.remove();
|
||||||
util.gpa.destroy(self);
|
util.gpa.destroy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,13 @@ pub fn init(self: *Self, server: *Server) !void {
|
||||||
server.wl_server.addDestroyListener(&self.server_destroy);
|
server.wl_server.addDestroyListener(&self.server_destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn handleOutputDestroy(self: *Self, output: *Output) void {
|
||||||
|
var it = self.options.safeIterator(.forward);
|
||||||
|
while (it.next()) |option| {
|
||||||
|
if (option.output == output) option.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn handleServerDestroy(listener: *wl.Listener(*wl.Server), wl_server: *wl.Server) void {
|
fn handleServerDestroy(listener: *wl.Listener(*wl.Server), wl_server: *wl.Server) void {
|
||||||
const self = @fieldParentPtr(Self, "server_destroy", listener);
|
const self = @fieldParentPtr(Self, "server_destroy", listener);
|
||||||
self.global.destroy();
|
self.global.destroy();
|
||||||
|
|
|
@ -487,6 +487,8 @@ fn handleDestroy(listener: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) v
|
||||||
|
|
||||||
log.debug(.server, "output '{}' destroyed", .{self.wlr_output.name});
|
log.debug(.server, "output '{}' destroyed", .{self.wlr_output.name});
|
||||||
|
|
||||||
|
root.server.options_manager.handleOutputDestroy(self);
|
||||||
|
|
||||||
// Remove the destroyed output from root if it wasn't already removed
|
// Remove the destroyed output from root if it wasn't already removed
|
||||||
root.removeOutput(self);
|
root.removeOutput(self);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue