code: Add Root.all_outputs

This commit is contained in:
Marten Ringwelski 2020-11-16 09:17:08 +01:00 committed by Isaac Freund
parent 10373da634
commit 157dccbbbb
2 changed files with 15 additions and 0 deletions

View File

@ -513,6 +513,14 @@ fn handleDestroy(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
root.removeOutput(node);
}
var it = root.all_outputs.first;
while (it) |all_node| : (it = all_node.next) {
if (all_node.data == self) {
root.all_outputs.remove(all_node);
break;
}
}
// Remove all listeners
c.wl_list_remove(&self.listen_destroy.link);
c.wl_list_remove(&self.listen_frame.link);

View File

@ -66,7 +66,14 @@ fn handleNewOutput(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void
c.wlr_output_destroy(wlr_output);
return;
};
const ptr_node = util.gpa.create(std.TailQueue(*Output).Node) catch {
util.gpa.destroy(node);
c.wlr_output_destroy(wlr_output);
return;
};
ptr_node.data = &node.data;
self.root.all_outputs.append(ptr_node);
self.root.addOutput(node);
}