From 2df2151afab926999c8ccca26c5870641eab0d69 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Thu, 2 Jun 2022 12:21:57 +0200 Subject: [PATCH] river-status: only send mode event if client bound version 3 --- river/Seat.zig | 3 +-- river/SeatStatus.zig | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/river/Seat.zig b/river/Seat.zig index 9582313..36d8060 100644 --- a/river/Seat.zig +++ b/river/Seat.zig @@ -363,8 +363,7 @@ pub fn enterMode(self: *Self, mode_id: u32) void { var it = self.status_trackers.first; while (it) |node| : (it = node.next) { - const seat_status = node.data.seat_status; - seat_status.sendMode(server.config.modes.items[mode_id].name); + node.data.sendMode(server.config.modes.items[mode_id].name); } } diff --git a/river/SeatStatus.zig b/river/SeatStatus.zig index d06c7dd..f6fe5dd 100644 --- a/river/SeatStatus.zig +++ b/river/SeatStatus.zig @@ -37,7 +37,7 @@ pub fn init(self: *Self, seat: *Seat, seat_status: *zriver.SeatStatusV1) void { seat_status.setHandler(*Self, handleRequest, handleDestroy, self); // Send all info once on bind - seat_status.sendMode(server.config.modes.items[seat.mode_id].name); + self.sendMode(server.config.modes.items[seat.mode_id].name); self.sendOutput(.focused); self.sendFocusedView(); } @@ -72,3 +72,9 @@ pub fn sendFocusedView(self: Self) void { ""; self.seat_status.sendFocusedView(title); } + +pub fn sendMode(self: Self, mode: [*:0]const u8) void { + if (self.seat_status.getVersion() >= 3) { + self.seat_status.sendMode(mode); + } +}