diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2020-06-06 15:07:07 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2020-06-06 15:07:07 +0200 |
| commit | e48cf8eab6f2f6c99db94708b38020e87e9ae117 (patch) | |
| tree | 3eae29a923ef3e1ffa0261ba200f0507c616a1a1 /example | |
| parent | 51b00ac6a9058151861a9a00f6f22e8abe755d37 (diff) | |
| download | river-e48cf8eab6f2f6c99db94708b38020e87e9ae117.tar.gz river-e48cf8eab6f2f6c99db94708b38020e87e9ae117.tar.xz | |
river-status: simplify example client
Diffstat (limited to 'example')
| -rw-r--r-- | example/status.zig | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/example/status.zig b/example/status.zig index 98fd808..d4d61a1 100644 --- a/example/status.zig +++ b/example/status.zig @@ -53,6 +53,11 @@ pub fn main() !void { if (river_status_manager == null) return error.RiverStatusManagerNotAdvertised; + for (outputs.items) |wl_output| createOutputStatus(wl_output); + for (seats.items) |wl_seat| createSeatStatus(wl_seat); + outputs.deinit(); + seats.deinit(); + // Loop forever, listening for new events. while (true) if (c.wl_display_dispatch(wl_display) < 0) return error.DispatchFailed; } @@ -71,28 +76,18 @@ fn handleGlobal( *c.zriver_status_manager_v1, c.wl_registry_bind(wl_registry, name, &c.zriver_status_manager_v1_interface, version), ); - for (outputs.items) |wl_output| createOutputStatus(wl_output); - for (seats.items) |wl_seat| createSeatStatus(wl_seat); - outputs.deinit(); - seats.deinit(); } else if (std.cstr.cmp(interface.?, @ptrCast([*:0]const u8, c.wl_output_interface.name.?)) == 0) { const wl_output = @ptrCast( *c.wl_output, c.wl_registry_bind(wl_registry, name, &c.wl_output_interface, version), ); - if (river_status_manager != null) - createOutputStatus(wl_output) - else - outputs.append(wl_output) catch @panic("out of memory"); + outputs.append(wl_output) catch @panic("out of memory"); } else if (std.cstr.cmp(interface.?, @ptrCast([*:0]const u8, c.wl_seat_interface.name.?)) == 0) { const wl_seat = @ptrCast( *c.wl_seat, c.wl_registry_bind(wl_registry, name, &c.wl_seat_interface, version), ); - if (river_status_manager != null) - createSeatStatus(wl_seat) - else - seats.append(wl_seat) catch @panic("out of memory"); + seats.append(wl_seat) catch @panic("out of memory"); } } |
