Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git
KeyboardGroup: sync LEDs
build.zig.zon | 4 ++--
river/KeyboardGroup.zig | 14 +++++++++++++-
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/build.zig.zon b/build.zig.zon
index d6ea98a..d76facc 100644
--- a/build.zig.zon
+++ b/build.zig.zon
@@ -20,8 +20,8 @@
.hash = "wayland-0.5.0-lQa1knz8AQCh08NA8BeQrwJB9U3CfqcVAdHZYGRKIGuu",
},
.wlroots = .{
- .url = "git+https://codeberg.org/ifreund/zig-wlroots?ref=master#eb7631742812665c10ff3a9b4b069c3d0cc2017b",
- .hash = "wlroots-0.20.0-dev-jmOlcuxBBAC74vcynqYuP8sjbyLrH6cnNlKzhXKg8zVO",
+ .url = "git+https://codeberg.org/ifreund/zig-wlroots?ref=master#b2b8850d1828c25bdb8fa5ba72829e98e02c7f12",
+ .hash = "wlroots-0.20.0-dev-jmOlcm9CBACfYGVVh6CHuSfGetJE9gXZ4v7ZyEIszvx4",
},
.xkbcommon = .{
.url = "https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.4.0.tar.gz",
diff --git a/river/KeyboardGroup.zig b/river/KeyboardGroup.zig
index f63850b..00c7d34 100644
--- a/river/KeyboardGroup.zig
+++ b/river/KeyboardGroup.zig
@@ -89,7 +89,7 @@ pub fn create(seat: *Seat, config: Keyboard.Config, virtual: bool) !*KeyboardGro
group.state.init(&.{
.name = "river.KeyboardGroup",
- .led_update = null, // TODO
+ .led_update = ledUpdate,
}, "river.KeyboardGroup");
group.state.data = group;
@@ -427,3 +427,15 @@ pub fn sendState(group: *KeyboardGroup) void {
xkb_keyboard.sendState(layout_index, layout_name, capslock, numlock);
}
}
+
+fn ledUpdate(state: *wlr.Keyboard, leds: u32) callconv(.c) void {
+ const group: *KeyboardGroup = @fieldParentPtr("state", state);
+ var it = server.input_manager.devices.iterator(.forward);
+ while (it.next()) |device| {
+ if (device.wlr_device.type != .keyboard) continue;
+ const keyboard: *Keyboard = @fieldParentPtr("device", device);
+ if (keyboard.group != group) continue;
+ const wlr_keyboard = device.wlr_device.toKeyboard();
+ wlr_keyboard.ledUpdate(leds);
+ }
+}