Make Config.keybinds into a hash map
This helps us with de-duplication. Previously, if you had host-specific keybinds on the same key combination, the compositor would choose the first... which is the opposite of how everything else in our config handling works.
This commit is contained in:
parent
9b0bac12ff
commit
4c0117724e
3 changed files with 26 additions and 11 deletions
|
|
@ -11,6 +11,13 @@ pub const Keybind = struct {
|
|||
keysym: ?xkbcommon.Keysym,
|
||||
};
|
||||
|
||||
pub const Key = struct {
|
||||
modifiers: river.SeatV1.Modifiers,
|
||||
keysym: xkbcommon.Keysym,
|
||||
};
|
||||
|
||||
pub const Map = std.AutoArrayHashMapUnmanaged(Key, XkbBindings.Command);
|
||||
|
||||
pub fn load(config: *Config, parser: *kdl.Parser, hostname: ?[]const u8) !void {
|
||||
while (try parser.next()) |event| {
|
||||
switch (event) {
|
||||
|
|
@ -172,11 +179,20 @@ pub fn load(config: *Config, parser: *kdl.Parser, hostname: ?[]const u8) !void {
|
|||
},
|
||||
};
|
||||
|
||||
try config.keybinds.append(utils.gpa, .{
|
||||
const gop = try config.keybinds.getOrPut(utils.gpa, .{
|
||||
.modifiers = modifiers,
|
||||
.command = command,
|
||||
.keysym = keysym,
|
||||
});
|
||||
if (gop.found_existing) {
|
||||
switch (gop.value_ptr.*) {
|
||||
.spawn => |argv| {
|
||||
for (argv) |arg| utils.gpa.free(arg);
|
||||
utils.gpa.free(argv);
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
gop.value_ptr.* = command;
|
||||
} else {
|
||||
helpers.logWarnInvalidNode(node.name);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue