aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <mail@isaacfreund.com>2022-07-26 16:25:04 +0200
committerIsaac Freund <mail@isaacfreund.com>2022-07-26 16:25:04 +0200
commitd4b2f2b0fc5766c8ae14a6f42fe76d058bfb3505 (patch)
tree42837953e11c04155a00069f9b738d55dd016d46
parent7443e1377ad6b260f4c9bc14ff02082ced8abb6b (diff)
downloadriver-d4b2f2b0fc5766c8ae14a6f42fe76d058bfb3505.tar.gz
river-d4b2f2b0fc5766c8ae14a6f42fe76d058bfb3505.tar.xz
Seat: send enter event on keyboard device creation
Currently we don't send an enter event when a new keyboard device is created which causes issues when switching ttys. On switching away the keyboard device is destroyed and leave is sent. Currently on switching back the keyboard device is re-created but no enter event is sent before we start sending key events, which is a violation of the protocol.
-rw-r--r--river/Seat.zig46
1 files changed, 28 insertions, 18 deletions
diff --git a/river/Seat.zig b/river/Seat.zig
index c04e2eb..fcd3377 100644
--- a/river/Seat.zig
+++ b/river/Seat.zig
@@ -244,24 +244,7 @@ pub fn setFocusRaw(self: *Self, new_focus: FocusTarget) void {
// Send keyboard enter/leave events and handle pointer constraints
if (target_surface) |wlr_surface| {
- if (self.wlr_seat.getKeyboard()) |wlr_keyboard| {
- var keycodes = KeycodeSet{
- .items = wlr_keyboard.keycodes,
- .len = wlr_keyboard.num_keycodes,
- };
-
- const keyboard = @intToPtr(*Keyboard, wlr_keyboard.data);
- keycodes.subtract(keyboard.eaten_keycodes);
-
- self.wlr_seat.keyboardNotifyEnter(
- wlr_surface,
- &keycodes.items,
- keycodes.len,
- &wlr_keyboard.modifiers,
- );
- } else {
- self.wlr_seat.keyboardNotifyEnter(wlr_surface, null, 0, null);
- }
+ self.keyboardNotifyEnter(wlr_surface);
if (server.input_manager.pointer_constraints.constraintForSurface(wlr_surface, self.wlr_seat)) |constraint| {
@intToPtr(*PointerConstraint, constraint.data).setAsActive();
@@ -286,6 +269,27 @@ pub fn setFocusRaw(self: *Self, new_focus: FocusTarget) void {
while (it) |node| : (it = node.next) node.data.sendFocusedView();
}
+fn keyboardNotifyEnter(self: *Self, wlr_surface: *wlr.Surface) void {
+ if (self.wlr_seat.getKeyboard()) |wlr_keyboard| {
+ var keycodes = KeycodeSet{
+ .items = wlr_keyboard.keycodes,
+ .len = wlr_keyboard.num_keycodes,
+ };
+
+ const keyboard = @intToPtr(*Keyboard, wlr_keyboard.data);
+ keycodes.subtract(keyboard.eaten_keycodes);
+
+ self.wlr_seat.keyboardNotifyEnter(
+ wlr_surface,
+ &keycodes.items,
+ keycodes.len,
+ &wlr_keyboard.modifiers,
+ );
+ } else {
+ self.wlr_seat.keyboardNotifyEnter(wlr_surface, null, 0, null);
+ }
+}
+
/// Focus the given output, notifying any listening clients of the change.
pub fn focusOutput(self: *Self, output: *Output) void {
if (self.focused_output == output) return;
@@ -470,6 +474,12 @@ fn tryAddDevice(self: *Self, wlr_device: *wlr.InputDevice) !void {
errdefer util.gpa.destroy(keyboard);
try keyboard.init(self, wlr_device);
+
+ self.wlr_seat.setKeyboard(keyboard.device.wlr_device);
+ if (self.wlr_seat.keyboard_state.focused_surface) |wlr_surface| {
+ self.wlr_seat.keyboardNotifyClearFocus();
+ self.keyboardNotifyEnter(wlr_surface);
+ }
},
.pointer, .touch => {
const device = try util.gpa.create(InputDevice);