From fa653337897b327a62b25840bea1713c262f45a6 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 7 Apr 2020 21:48:56 +0200 Subject: Refactor keybindings to be runtime defined. --- src/seat.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/seat.zig') diff --git a/src/seat.zig b/src/seat.zig index 8767323..eacdf8d 100644 --- a/src/seat.zig +++ b/src/seat.zig @@ -41,6 +41,19 @@ pub const Seat = struct { self.cursor.destroy(); } + /// Handle any user-defined keybinding for the passed keysym and modifiers + /// Returns true if the key was handled + pub fn handleKeybinding(self: Self, keysym: c.xkb_keysym_t, modifiers: u32) bool { + for (self.server.config.keybinds.items) |keybind| { + if (modifiers == keybind.modifiers and keysym == keybind.keysym) { + // Execute the bound command + keybind.command(self.server, keybind.arg); + return true; + } + } + return false; + } + fn addKeyboard(self: *Self, device: *c.wlr_input_device) !void { c.wlr_seat_set_keyboard(self.wlr_seat, device); -- cgit v1.2.3