Keyboard: don't add virtual keyboards to group
Also don't set their keymap, the client handles that. This is the first step towards fixing a regression with fcitx5.
This commit is contained in:
		| @ -160,7 +160,7 @@ pub fn reconfigureDevices(input_manager: *InputManager) void { | ||||
| fn handleNewInput(listener: *wl.Listener(*wlr.InputDevice), wlr_device: *wlr.InputDevice) void { | ||||
|     const input_manager: *InputManager = @fieldParentPtr("new_input", listener); | ||||
|  | ||||
|     input_manager.defaultSeat().addDevice(wlr_device); | ||||
|     input_manager.defaultSeat().addDevice(wlr_device, false); | ||||
| } | ||||
|  | ||||
| fn handleNewVirtualPointer( | ||||
| @ -178,7 +178,7 @@ fn handleNewVirtualPointer( | ||||
|         log.debug("Ignoring output suggestion from virtual pointer", .{}); | ||||
|     } | ||||
|  | ||||
|     input_manager.defaultSeat().addDevice(&event.new_pointer.pointer.base); | ||||
|     input_manager.defaultSeat().addDevice(&event.new_pointer.pointer.base, true); | ||||
| } | ||||
|  | ||||
| fn handleNewVirtualKeyboard( | ||||
| @ -186,7 +186,7 @@ fn handleNewVirtualKeyboard( | ||||
|     virtual_keyboard: *wlr.VirtualKeyboardV1, | ||||
| ) void { | ||||
|     const seat: *Seat = @alignCast(@ptrCast(virtual_keyboard.seat.data)); | ||||
|     seat.addDevice(&virtual_keyboard.keyboard.base); | ||||
|     seat.addDevice(&virtual_keyboard.keyboard.base, true); | ||||
| } | ||||
|  | ||||
| fn handleNewConstraint( | ||||
|  | ||||
| @ -88,7 +88,7 @@ pressed: Pressed = .{}, | ||||
| key: wl.Listener(*wlr.Keyboard.event.Key) = wl.Listener(*wlr.Keyboard.event.Key).init(handleKey), | ||||
| modifiers: wl.Listener(*wlr.Keyboard) = wl.Listener(*wlr.Keyboard).init(handleModifiers), | ||||
|  | ||||
| pub fn init(keyboard: *Keyboard, seat: *Seat, wlr_device: *wlr.InputDevice) !void { | ||||
| pub fn init(keyboard: *Keyboard, seat: *Seat, wlr_device: *wlr.InputDevice, virtual: bool) !void { | ||||
|     keyboard.* = .{ | ||||
|         .device = undefined, | ||||
|     }; | ||||
| @ -98,12 +98,14 @@ pub fn init(keyboard: *Keyboard, seat: *Seat, wlr_device: *wlr.InputDevice) !voi | ||||
|     const wlr_keyboard = keyboard.device.wlr_device.toKeyboard(); | ||||
|     wlr_keyboard.data = keyboard; | ||||
|  | ||||
|     // wlroots will log a more detailed error if this fails. | ||||
|     if (!wlr_keyboard.setKeymap(server.config.keymap)) return error.OutOfMemory; | ||||
|     if (!virtual) { | ||||
|         // wlroots will log a more detailed error if this fails. | ||||
|         if (!wlr_keyboard.setKeymap(server.config.keymap)) return error.OutOfMemory; | ||||
|  | ||||
|     if (wlr.KeyboardGroup.fromKeyboard(wlr_keyboard) == null) { | ||||
|         // wlroots will log an error on failure | ||||
|         _ = seat.keyboard_group.addKeyboard(wlr_keyboard); | ||||
|         if (wlr.KeyboardGroup.fromKeyboard(wlr_keyboard) == null) { | ||||
|             // wlroots will log an error on failure | ||||
|             _ = seat.keyboard_group.addKeyboard(wlr_keyboard); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     wlr_keyboard.setRepeatInfo(server.config.repeat_rate, server.config.repeat_delay); | ||||
|  | ||||
| @ -127,7 +127,7 @@ pub fn init(seat: *Seat, name: [*:0]const u8) !void { | ||||
|     try seat.cursor.init(seat); | ||||
|     seat.relay.init(); | ||||
|  | ||||
|     try seat.tryAddDevice(&seat.keyboard_group.keyboard.base); | ||||
|     try seat.tryAddDevice(&seat.keyboard_group.keyboard.base, false); | ||||
|  | ||||
|     seat.wlr_seat.events.request_set_selection.add(&seat.request_set_selection); | ||||
|     seat.wlr_seat.events.request_start_drag.add(&seat.request_start_drag); | ||||
| @ -480,19 +480,19 @@ fn handleMappingRepeatTimeout(seat: *Seat) c_int { | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| pub fn addDevice(seat: *Seat, wlr_device: *wlr.InputDevice) void { | ||||
|     seat.tryAddDevice(wlr_device) catch |err| switch (err) { | ||||
| pub fn addDevice(seat: *Seat, wlr_device: *wlr.InputDevice, virtual: bool) void { | ||||
|     seat.tryAddDevice(wlr_device, virtual) catch |err| switch (err) { | ||||
|         error.OutOfMemory => log.err("out of memory", .{}), | ||||
|     }; | ||||
| } | ||||
|  | ||||
| fn tryAddDevice(seat: *Seat, wlr_device: *wlr.InputDevice) !void { | ||||
| fn tryAddDevice(seat: *Seat, wlr_device: *wlr.InputDevice, virtual: bool) !void { | ||||
|     switch (wlr_device.type) { | ||||
|         .keyboard => { | ||||
|             const keyboard = try util.gpa.create(Keyboard); | ||||
|             errdefer util.gpa.destroy(keyboard); | ||||
|  | ||||
|             try keyboard.init(seat, wlr_device); | ||||
|             try keyboard.init(seat, wlr_device, virtual); | ||||
|  | ||||
|             seat.wlr_seat.setKeyboard(keyboard.device.wlr_device.toKeyboard()); | ||||
|             if (seat.wlr_seat.keyboard_state.focused_surface) |wlr_surface| { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user