Refactor keybindings to be runtime defined.

This commit is contained in:
Isaac Freund
2020-04-07 21:48:56 +02:00
parent 15f97314a9
commit fa65333789
8 changed files with 116 additions and 68 deletions

View File

@ -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);