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

commit3054594aece7a0f5d555ce66efb3e7cd1eddb649
parentf63ecda46b
authorDoclic <[email protected]>
date2023-10-19 01:21
river: make RuleList return deleted items

 river/command/rule.zig | 6 +++---
 river/rule_list.zig    | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/river/command/rule.zig b/river/command/rule.zig
index 33b9b3b..a2dc9da 100644
--- a/river/command/rule.zig
+++ b/river/command/rule.zig
@@ -105,13 +105,13 @@ pub fn ruleDel(_: *Seat, args: []const [:0]const u8, _: *?[]const u8) Error!void
 
     switch (action) {
         .float, .@"no-float" => {
-            server.config.float_rules.del(.{
+            _ = server.config.float_rules.del(.{
                 .app_id_glob = app_id_glob,
                 .title_glob = title_glob,
             });
         },
         .ssd, .csd => {
-            server.config.ssd_rules.del(.{
+            _ = server.config.ssd_rules.del(.{
                 .app_id_glob = app_id_glob,
                 .title_glob = title_glob,
             });
@@ -119,7 +119,7 @@ pub fn ruleDel(_: *Seat, args: []const [:0]const u8, _: *?[]const u8) Error!void
             server.root.applyPending();
         },
         .tag => {
-            server.config.tag_rules.del(.{
+            _ = server.config.tag_rules.del(.{
                 .app_id_glob = app_id_glob,
                 .title_glob = title_glob,
             });
diff --git a/river/rule_list.zig b/river/rule_list.zig
index 1083018..ad6fbf8 100644
--- a/river/rule_list.zig
+++ b/river/rule_list.zig
@@ -82,17 +82,17 @@ pub fn RuleList(comptime T: type) type {
             });
         }
 
-        pub fn del(list: *Self, rule: struct { app_id_glob: []const u8, title_glob: []const u8 }) void {
+        pub fn del(list: *Self, rule: struct { app_id_glob: []const u8, title_glob: []const u8 }) ?T {
             for (list.rules.items, 0..) |existing, i| {
                 if (mem.eql(u8, rule.app_id_glob, existing.app_id_glob) and
                     mem.eql(u8, rule.title_glob, existing.title_glob))
                 {
                     util.gpa.free(existing.app_id_glob);
                     util.gpa.free(existing.title_glob);
-                    _ = list.rules.orderedRemove(i);
-                    return;
+                    return list.rules.orderedRemove(i).value;
                 }
             }
+            return null;
         }
 
         /// Returns the value of the most specific rule matching the view.