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

commit016ffd1ba11f442125e31a14be2cb11fba5ddb91
parentf736677d7e
authorIsaac Freund <[email protected]>
date2020-04-08 00:40
Add binding to toggle focused tags

 src/command.zig | 10 ++++++++++
 src/config.zig  |  7 +++++++
 2 files changed, 17 insertions(+)

diff --git a/src/command.zig b/src/command.zig
index a325fe9..075e21f 100644
--- a/src/command.zig
+++ b/src/command.zig
@@ -71,6 +71,16 @@ pub fn focusTags(server: *Server, arg: Arg) void {
     server.root.arrange();
 }
 
+/// Toggle focus of the passsed tags.
+pub fn toggleTags(server: *Server, arg: Arg) void {
+    const tags = arg.uint;
+    const new_focused_tags = server.root.current_focused_tags ^ tags;
+    if (new_focused_tags != 0) {
+        server.root.pending_focused_tags = new_focused_tags;
+        server.root.arrange();
+    }
+}
+
 /// Set the tags of the focused view.
 pub fn setFocusedViewTags(server: *Server, arg: Arg) void {
     const tags = arg.uint;
diff --git a/src/config.zig b/src/config.zig
index ac67071..75c7f99 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -58,5 +58,12 @@ pub const Config = struct {
         try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_4, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.setFocusedViewTags, .arg = .{ .uint = 1 << 3 } });
         try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_5, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.setFocusedViewTags, .arg = .{ .uint = 1 << 4 } });
         try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_6, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.setFocusedViewTags, .arg = .{ .uint = 1 << 5 } });
+
+        try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_1, .modifiers = mod | c.WLR_MODIFIER_CTRL, .command = command.toggleTags, .arg = .{ .uint = 1 << 0 } });
+        try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_2, .modifiers = mod | c.WLR_MODIFIER_CTRL, .command = command.toggleTags, .arg = .{ .uint = 1 << 1 } });
+        try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_3, .modifiers = mod | c.WLR_MODIFIER_CTRL, .command = command.toggleTags, .arg = .{ .uint = 1 << 2 } });
+        try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_4, .modifiers = mod | c.WLR_MODIFIER_CTRL, .command = command.toggleTags, .arg = .{ .uint = 1 << 3 } });
+        try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_5, .modifiers = mod | c.WLR_MODIFIER_CTRL, .command = command.toggleTags, .arg = .{ .uint = 1 << 4 } });
+        try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_6, .modifiers = mod | c.WLR_MODIFIER_CTRL, .command = command.toggleTags, .arg = .{ .uint = 1 << 5 } });
     }
 };