keyboard-groups: use globber for identifier matching

This commit is contained in:
Leon Henrik Plickat
2024-01-03 21:30:46 +01:00
committed by Isaac Freund
parent 540ca043df
commit dd9933b6a1
4 changed files with 41 additions and 19 deletions
+10 -7
View File
@@ -21,6 +21,7 @@ const assert = std.debug.assert;
const wlr = @import("wlroots");
const wl = @import("wayland").server.wl;
const xkb = @import("xkbcommon");
const globber = @import("globber");
const server = &@import("main.zig").server;
const util = @import("util.zig");
@@ -52,13 +53,15 @@ pub fn init(self: *Self, seat: *Seat, wlr_device: *wlr.InputDevice) !void {
// wlroots will log a more detailed error if this fails.
if (!wlr_keyboard.setKeymap(server.config.keymap)) return error.OutOfMemory;
// Add to keyboard group, if applicable.
var it = seat.keyboard_groups.first;
while (it) |node| : (it = node.next) {
if (node.data.identifiers.contains(self.device.identifier)) {
// wlroots will log an error if this fails explaining the reason.
_ = node.data.wlr_group.addKeyboard(wlr_keyboard);
break;
// Add to keyboard-group, if applicable.
var group_it = seat.keyboard_groups.first;
outer: while (group_it) |group_node| : (group_it = group_node.next) {
for (group_node.data.globs.items) |glob| {
if (globber.match(glob, self.device.identifier)) {
// wlroots will log an error if this fails explaining the reason.
_ = group_node.data.wlr_group.addKeyboard(wlr_keyboard);
break :outer;
}
}
}