From 3fe1edbe3edec7967d0d1c67dc7677da9f6a6f4e Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 17 May 2020 00:03:26 +0200 Subject: Implement keybinding modes --- src/Seat.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/Seat.zig') diff --git a/src/Seat.zig b/src/Seat.zig index 4335c00..c697010 100644 --- a/src/Seat.zig +++ b/src/Seat.zig @@ -25,6 +25,7 @@ const Cursor = @import("Cursor.zig"); const InputManager = @import("InputManager.zig"); const Keyboard = @import("Keyboard.zig"); const LayerSurface = @import("LayerSurface.zig"); +const Mode = @import("Mode.zig"); const Output = @import("Output.zig"); const View = @import("View.zig"); const ViewStack = @import("view_stack.zig").ViewStack; @@ -44,6 +45,9 @@ cursor: Cursor, /// Mulitple keyboards are handled separately keyboards: std.TailQueue(Keyboard), +/// Current keybind mode +mode: *Mode, + /// Currently focused output, may be the noop output if no focused_output: *Output, @@ -72,6 +76,8 @@ pub fn init(self: *Self, input_manager: *InputManager, name: []const u8) !void { self.keyboards = std.TailQueue(Keyboard).init(); + self.mode = input_manager.server.config.getMode("normal"); + self.focused_output = &self.input_manager.server.root.noop_output; self.focused_view = null; @@ -243,7 +249,7 @@ pub fn handleViewUnmap(self: *Self, view: *View) void { /// 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.input_manager.server.config.keybinds.items) |keybind| { + for (self.mode.keybinds.items) |keybind| { if (modifiers == keybind.modifiers and keysym == keybind.keysym) { // Execute the bound command keybind.command(self, keybind.arg); -- cgit v1.2.3