git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit6b011b7d119062643a2b5929fa80959795d240e5
parent30c1a41d21
authorIsaac Freund <[email protected]>
date2020-03-28 14:44
Add keybindings for changing master count

 src/server.zig | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/server.zig b/src/server.zig
index 30b06d5..0d17957 100644
--- a/src/server.zig
+++ b/src/server.zig
@@ -105,6 +105,8 @@ 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 {
         // This function assumes the proper modifier is held down.
         if (modifiers & @intCast(u32, c.WLR_MODIFIER_SHIFT) != 0) {
@@ -124,6 +126,18 @@ pub const Server = struct {
                 c.XKB_KEY_e => c.wl_display_terminate(self.wl_display),
                 c.XKB_KEY_j => self.root.focusNextView(),
                 c.XKB_KEY_k => self.root.focusPrevView(),
+                c.XKB_KEY_h => {
+                    if (self.root.master_count < self.root.views.len) {
+                        self.root.master_count += 1;
+                        self.root.arrange();
+                    }
+                },
+                c.XKB_KEY_l => {
+                    if (self.root.master_count > 0) {
+                        self.root.master_count -= 1;
+                        self.root.arrange();
+                    }
+                },
                 c.XKB_KEY_Return => {
                     // Spawn an instance of alacritty
                     // const argv = [_][]const u8{ "/bin/sh", "-c", "WAYLAND_DEBUG=1 alacritty" };