From e43bb78160d403a0d77759fcc2bc50fc0fc0337e Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 31 May 2020 23:56:25 +0200 Subject: Store modes by id --- src/Seat.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Seat.zig') diff --git a/src/Seat.zig b/src/Seat.zig index 7e0b06b..31be96e 100644 --- a/src/Seat.zig +++ b/src/Seat.zig @@ -26,7 +26,6 @@ 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; @@ -46,8 +45,8 @@ cursor: Cursor, /// Mulitple keyboards are handled separately keyboards: std.TailQueue(Keyboard), -/// Current keybind mode -mode: *Mode, +/// Id of the current keybind mode +mode_id: u32, /// Currently focused output, may be the noop output if no focused_output: *Output, @@ -77,7 +76,7 @@ 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.mode_id = 0; self.focused_output = &self.input_manager.server.root.noop_output; @@ -250,7 +249,8 @@ 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.mode.keybinds.items) |keybind| { + const modes = &self.input_manager.server.config.modes; + for (modes.items[self.mode_id].items) |keybind| { if (modifiers == keybind.modifiers and keysym == keybind.keysym) { // Execute the bound command const allocator = self.input_manager.server.allocator; -- cgit v1.2.3