Refactor output handling

This commit is contained in:
Isaac Freund
2020-03-23 12:22:48 +01:00
parent f423f5317b
commit 774fcf53a8
2 changed files with 99 additions and 94 deletions

View File

@ -69,7 +69,7 @@ pub const Server = struct {
/// Create the socket, set WAYLAND_DISPLAY, and start the backend
pub fn start(self: @This()) !void {
// Add a Unix socket to the Wayland display.
const socket = c.wl_display_add_socket_auto(self.wl_display) orelse;
const socket = c.wl_display_add_socket_auto(self.wl_display) orelse
return error.CantAddSocket;
// Start the backend. This will enumerate outputs and inputs, become the DRM
@ -114,4 +114,12 @@ pub const Server = struct {
}
return true;
}
fn handle_new_output(listener: [*c]c.wl_listener, data: ?*c_void) callconv(.C) void {
var server = @fieldParentPtr(Server, "new_output", listener);
var wlr_output = @ptrCast(*c.wlr_output, @alignCast(@alignOf(*c.wlr_output), data));
// TODO: Handle failure
server.outputs.append(Output.init(server, wlr_output) orelse return);
}
};