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

commit638a6b8c21927a8b33ced37320088a425e36e0f4
parentb3915247b9
authorIsaac Freund <[email protected]>
date2020-04-01 19:39
Implement switching between single tags

 src/root.zig   |  8 ++++----
 src/server.zig | 24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/root.zig b/src/root.zig
index e19f3f4..bddee87 100644
--- a/src/root.zig
+++ b/src/root.zig
@@ -2,6 +2,7 @@ const std = @import("std");
 const c = @import("c.zig");
 const util = @import("util.zig");
 
+const Log = @import("log.zig").Log;
 const Output = @import("output.zig").Output;
 const Server = @import("server.zig").Server;
 const Seat = @import("seat.zig").Seat;
@@ -171,10 +172,6 @@ pub const Root = struct {
 
         const visible_count = self.visibleCount(tags);
 
-        if (visible_count == 0) {
-            return;
-        }
-
         const master_count = util.min(u32, self.master_count, visible_count);
         const slave_count = if (master_count >= visible_count) 0 else visible_count - master_count;
 
@@ -284,6 +281,8 @@ pub const Root = struct {
             if (c.wl_event_source_timer_update(self.transaction_timer, 200) == -1) {
                 // TODO: handle failure
             }
+        } else {
+            self.commitTransaction();
         }
     }
 
@@ -315,6 +314,7 @@ pub const Root = struct {
 
         // If there were pending focused tags, make them the current focus
         if (self.pending_focused_tags) |tags| {
+            Log.Debug.log("changing current focus: {b:0>10} to {b:0>10}\n", .{ self.current_focused_tags, tags });
             self.current_focused_tags = tags;
             self.pending_focused_tags = null;
         }
diff --git a/src/server.zig b/src/server.zig
index 4ce4a15..de202fd 100644
--- a/src/server.zig
+++ b/src/server.zig
@@ -165,6 +165,30 @@ pub const Server = struct {
                         }
                     }
                 },
+                c.XKB_KEY_1 => {
+                    self.root.pending_focused_tags = 1 << 0;
+                    self.root.arrange();
+                },
+                c.XKB_KEY_2 => {
+                    self.root.pending_focused_tags = 1 << 1;
+                    self.root.arrange();
+                },
+                c.XKB_KEY_3 => {
+                    self.root.pending_focused_tags = 1 << 2;
+                    self.root.arrange();
+                },
+                c.XKB_KEY_4 => {
+                    self.root.pending_focused_tags = 1 << 3;
+                    self.root.arrange();
+                },
+                c.XKB_KEY_5 => {
+                    self.root.pending_focused_tags = 1 << 4;
+                    self.root.arrange();
+                },
+                c.XKB_KEY_6 => {
+                    self.root.pending_focused_tags = 1 << 5;
+                    self.root.arrange();
+                },
                 else => return false,
             }
         }