river-status: add mode event to seat status

This allows clients such as a status bar to display the currently active
mode.
This commit is contained in:
Isaac Freund
2022-05-31 18:09:03 +02:00
parent 03e8da669c
commit d657dc791b
10 changed files with 49 additions and 27 deletions

View File

@ -63,10 +63,10 @@ keyboards: std.TailQueue(Keyboard) = .{},
switches: std.TailQueue(Switch) = .{},
/// ID of the current keymap mode
mode_id: usize = 0,
mode_id: u32 = 0,
/// ID of previous keymap mode, used when returning from "locked" mode
prev_mode_id: usize = 0,
prev_mode_id: u32 = 0,
/// Timer for repeating keyboard mappings
mapping_repeat_timer: *wl.EventSource,
@ -358,6 +358,16 @@ pub fn handleViewUnmap(self: *Self, view: *View) void {
if (self.focused == .view and self.focused.view == view) self.focus(null);
}
pub fn enterMode(self: *Self, mode_id: u32) void {
self.mode_id = mode_id;
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);
}
}
/// Is there a user-defined mapping for passed keycode, modifiers and keyboard state?
pub fn hasMapping(
self: *Self,