xdg-decoration: clean up initialization

This commit is contained in:
Isaac Freund 2020-08-21 19:54:15 +02:00
parent 5098553fb4
commit 163fa47822
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
2 changed files with 9 additions and 12 deletions

View file

@ -28,17 +28,15 @@ server: *Server,
wlr_xdg_toplevel_decoration: *c.wlr_xdg_toplevel_decoration_v1,
listen_destroy: c.wl_listener,
listen_request_mode: c.wl_listener,
listen_destroy: c.wl_listener = undefined,
listen_request_mode: c.wl_listener = undefined,
pub fn init(
self: *Self,
server: *Server,
wlr_xdg_toplevel_decoration: *c.wlr_xdg_toplevel_decoration_v1,
) void {
self.server = server;
self.wlr_xdg_toplevel_decoration = wlr_xdg_toplevel_decoration;
self.* = .{ .server = server, .wlr_xdg_toplevel_decoration = wlr_xdg_toplevel_decoration };
self.listen_destroy.notify = handleDestroy;
c.wl_signal_add(&self.wlr_xdg_toplevel_decoration.events.destroy, &self.listen_destroy);

View file

@ -29,15 +29,14 @@ server: *Server,
wlr_xdg_decoration_manager: *c.wlr_xdg_decoration_manager_v1,
decorations: std.SinglyLinkedList(Decoration),
listen_new_toplevel_decoration: c.wl_listener,
listen_new_toplevel_decoration: c.wl_listener = undefined,
pub fn init(self: *Self, server: *Server) !void {
self.wlr_xdg_decoration_manager = c.wlr_xdg_decoration_manager_v1_create(server.wl_display) orelse
return error.OutOfMemory;
self.server = server;
self.* = .{
.server = server,
.wlr_xdg_decoration_manager = c.wlr_xdg_decoration_manager_v1_create(server.wl_display) orelse
return error.OutOfMemory,
};
self.listen_new_toplevel_decoration.notify = handleNewToplevelDecoration;
c.wl_signal_add(