river: add keyboard groups

This commit is contained in:
Leon Henrik Plickat
2022-08-30 15:26:35 +02:00
parent c0e64829f0
commit 01f49bbbc1
10 changed files with 314 additions and 31 deletions

View File

@ -41,6 +41,7 @@ const Switch = @import("Switch.zig");
const View = @import("View.zig");
const ViewStack = @import("view_stack.zig").ViewStack;
const XwaylandOverrideRedirect = @import("XwaylandOverrideRedirect.zig");
const KeyboardGroup = @import("KeyboardGroup.zig");
const log = std.log.scoped(.seat);
const PointerConstraint = @import("PointerConstraint.zig");
@ -69,6 +70,8 @@ mapping_repeat_timer: *wl.EventSource,
/// Currently repeating mapping, if any
repeating_mapping: ?*const Mapping = null,
keyboard_groups: std.TailQueue(KeyboardGroup) = .{},
/// Currently focused output, may be the noop output if no real output
/// is currently available for focus.
focused_output: *Output,
@ -475,7 +478,18 @@ fn tryAddDevice(self: *Self, wlr_device: *wlr.InputDevice) !void {
try keyboard.init(self, wlr_device);
self.wlr_seat.setKeyboard(keyboard.device.wlr_device);
// Add this keyboard to a keyboard group, if the group contains a
// matching identifier and if the keyboard isn't a group itself.
if (keyboard.provider == .device) {
var it = self.keyboard_groups.first;
while (it) |node| : (it = node.next) {
if (node.data.containsIdentifier(keyboard.provider.device.identifier)) {
try node.data.addKeyboard(keyboard);
break;
}
}
}
if (self.wlr_seat.keyboard_state.focused_surface) |wlr_surface| {
self.wlr_seat.keyboardNotifyClearFocus();
self.keyboardNotifyEnter(wlr_surface);
@ -508,6 +522,7 @@ pub fn updateCapabilities(self: *Self) void {
var it = server.input_manager.devices.iterator(.forward);
while (it.next()) |device| {
log.debug(">>>> '{s}'", .{device.identifier});
if (device.seat == self) {
switch (device.wlr_device.type) {
.keyboard => capabilities.keyboard = true,