diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2020-04-07 21:48:56 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2020-04-07 21:48:56 +0200 |
| commit | fa653337897b327a62b25840bea1713c262f45a6 (patch) | |
| tree | e7e54b0d861cf9eaa504ea9c266f88ed24cc1de9 /src/server.zig | |
| parent | 15f97314a9a72685a3468dcb72bac4e534b05b35 (diff) | |
| download | river-fa653337897b327a62b25840bea1713c262f45a6.tar.gz river-fa653337897b327a62b25840bea1713c262f45a6.tar.xz | |
Refactor keybindings to be runtime defined.
Diffstat (limited to 'src/server.zig')
| -rw-r--r-- | src/server.zig | 44 |
1 files changed, 5 insertions, 39 deletions
diff --git a/src/server.zig b/src/server.zig index d7c43f1..c729fd3 100644 --- a/src/server.zig +++ b/src/server.zig @@ -2,6 +2,7 @@ const std = @import("std"); const c = @import("c.zig"); const command = @import("command.zig"); +const Config = @import("config.zig").Config; const DecorationManager = @import("decoration_manager.zig").DecorationManager; const Output = @import("output.zig").Output; const Root = @import("root.zig").Root; @@ -25,6 +26,8 @@ pub const Server = struct { root: Root, seat: Seat, + config: Config, + listen_new_output: c.wl_listener, listen_new_xdg_surface: c.wl_listener, @@ -73,6 +76,8 @@ pub const Server = struct { try self.seat.init(self); + try self.config.init(self.allocator); + // Register our listeners for new outputs and xdg_surfaces. self.listen_new_output.notify = handleNewOutput; c.wl_signal_add(&self.wlr_backend.events.new_output, &self.listen_new_output); @@ -112,45 +117,6 @@ pub const Server = struct { c.wl_display_run(self.wl_display); } - /// Handle all compositor keybindings - /// Note: this is a hacky initial implementation for testing and will be rewritten eventually - pub fn handleKeybinding(self: *Self, sym: c.xkb_keysym_t, modifiers: u32) bool { - if (modifiers & @intCast(u32, c.WLR_MODIFIER_LOGO) == 0) { - return false; - } - if (modifiers & @intCast(u32, c.WLR_MODIFIER_SHIFT) != 0) { - switch (sym) { - c.XKB_KEY_H => command.modifyMasterCount(self, 1), - c.XKB_KEY_L => command.modifyMasterCount(self, -1), - c.XKB_KEY_Return => command.spawn(self), - c.XKB_KEY_1 => command.setFocusedViewTags(self, 1 << 0), - c.XKB_KEY_2 => command.setFocusedViewTags(self, 1 << 1), - c.XKB_KEY_3 => command.setFocusedViewTags(self, 1 << 2), - c.XKB_KEY_4 => command.setFocusedViewTags(self, 1 << 3), - c.XKB_KEY_5 => command.setFocusedViewTags(self, 1 << 4), - c.XKB_KEY_6 => command.setFocusedViewTags(self, 1 << 5), - else => return false, - } - } else { - switch (sym) { - c.XKB_KEY_e => command.exitCompositor(self), - c.XKB_KEY_j => command.focusNextView(self), - c.XKB_KEY_k => command.focusPrevView(self), - c.XKB_KEY_h => command.modifyMasterFactor(self, 0.05), - c.XKB_KEY_l => command.modifyMasterFactor(self, -0.05), - c.XKB_KEY_Return => command.zoom(self), - c.XKB_KEY_1 => command.focusTags(self, 1 << 0), - c.XKB_KEY_2 => command.focusTags(self, 1 << 1), - c.XKB_KEY_3 => command.focusTags(self, 1 << 2), - c.XKB_KEY_4 => command.focusTags(self, 1 << 3), - c.XKB_KEY_5 => command.focusTags(self, 1 << 4), - c.XKB_KEY_6 => command.focusTags(self, 1 << 5), - else => return false, - } - } - return true; - } - fn handleNewOutput(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void { const server = @fieldParentPtr(Server, "listen_new_output", listener.?); const wlr_output = @ptrCast(*c.wlr_output, @alignCast(@alignOf(*c.wlr_output), data)); |
