river-status: clean up initialization
This commit is contained in:
parent
997b151df2
commit
0b2c992f4d
3 changed files with 15 additions and 27 deletions
|
@ -27,16 +27,13 @@ const Output = @import("Output.zig");
|
|||
const View = @import("View.zig");
|
||||
const ViewStack = @import("view_stack.zig").ViewStack;
|
||||
|
||||
const implementation = c.struct_zriver_output_status_v1_interface{
|
||||
.destroy = destroy,
|
||||
};
|
||||
const implementation = c.struct_zriver_output_status_v1_interface{ .destroy = destroy };
|
||||
|
||||
output: *Output,
|
||||
wl_resource: *c.wl_resource,
|
||||
|
||||
pub fn init(self: *Self, output: *Output, wl_resource: *c.wl_resource) void {
|
||||
self.output = output;
|
||||
self.wl_resource = wl_resource;
|
||||
self.* = .{ .output = output, .wl_resource = wl_resource };
|
||||
|
||||
c.wl_resource_set_implementation(wl_resource, &implementation, self, handleResourceDestroy);
|
||||
|
||||
|
|
|
@ -26,21 +26,13 @@ const Seat = @import("Seat.zig");
|
|||
const Output = @import("Output.zig");
|
||||
const View = @import("View.zig");
|
||||
|
||||
const FocusState = enum {
|
||||
focused,
|
||||
unfocused,
|
||||
};
|
||||
|
||||
const implementation = c.struct_zriver_seat_status_v1_interface{
|
||||
.destroy = destroy,
|
||||
};
|
||||
const implementation = c.struct_zriver_seat_status_v1_interface{ .destroy = destroy };
|
||||
|
||||
seat: *Seat,
|
||||
wl_resource: *c.wl_resource,
|
||||
|
||||
pub fn init(self: *Self, seat: *Seat, wl_resource: *c.wl_resource) void {
|
||||
self.seat = seat;
|
||||
self.wl_resource = wl_resource;
|
||||
self.* = .{ .seat = seat, .wl_resource = wl_resource };
|
||||
|
||||
c.wl_resource_set_implementation(wl_resource, &implementation, self, handleResourceDestroy);
|
||||
|
||||
|
@ -60,7 +52,7 @@ fn destroy(wl_client: ?*c.wl_client, wl_resource: ?*c.wl_resource) callconv(.C)
|
|||
c.wl_resource_destroy(wl_resource);
|
||||
}
|
||||
|
||||
pub fn sendOutput(self: Self, state: FocusState) void {
|
||||
pub fn sendOutput(self: Self, state: enum { focused, unfocused }) void {
|
||||
const wl_client = c.wl_resource_get_client(self.wl_resource);
|
||||
const output_resources = &self.seat.focused_output.wlr_output.resources;
|
||||
var output_resource = c.wl_resource_from_link(output_resources.next);
|
||||
|
|
|
@ -37,21 +37,20 @@ const implementation = c.struct_zriver_status_manager_v1_interface{
|
|||
.get_river_seat_status = getRiverSeatStatus,
|
||||
};
|
||||
|
||||
// TODO: remove this field, move allocator to util or something
|
||||
server: *Server,
|
||||
wl_global: *c.wl_global,
|
||||
|
||||
listen_display_destroy: c.wl_listener,
|
||||
listen_display_destroy: c.wl_listener = undefined,
|
||||
|
||||
pub fn init(self: *Self, server: *Server) !void {
|
||||
self.server = server;
|
||||
self.wl_global = c.wl_global_create(
|
||||
server.wl_display,
|
||||
&c.zriver_status_manager_v1_interface,
|
||||
protocol_version,
|
||||
self,
|
||||
bind,
|
||||
) orelse return error.OutOfMemory;
|
||||
self.* = .{
|
||||
.wl_global = c.wl_global_create(
|
||||
server.wl_display,
|
||||
&c.zriver_status_manager_v1_interface,
|
||||
protocol_version,
|
||||
self,
|
||||
bind,
|
||||
) orelse return error.OutOfMemory,
|
||||
};
|
||||
|
||||
self.listen_display_destroy.notify = handleDisplayDestroy;
|
||||
c.wl_display_add_destroy_listener(server.wl_display, &self.listen_display_destroy);
|
||||
|
|
Loading…
Reference in a new issue