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.
This commit is contained in:
parent
7443e1377a
commit
d4b2f2b0fc
@ -244,24 +244,7 @@ pub fn setFocusRaw(self: *Self, new_focus: FocusTarget) void {
|
|||||||
|
|
||||||
// Send keyboard enter/leave events and handle pointer constraints
|
// Send keyboard enter/leave events and handle pointer constraints
|
||||||
if (target_surface) |wlr_surface| {
|
if (target_surface) |wlr_surface| {
|
||||||
if (self.wlr_seat.getKeyboard()) |wlr_keyboard| {
|
self.keyboardNotifyEnter(wlr_surface);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (server.input_manager.pointer_constraints.constraintForSurface(wlr_surface, self.wlr_seat)) |constraint| {
|
if (server.input_manager.pointer_constraints.constraintForSurface(wlr_surface, self.wlr_seat)) |constraint| {
|
||||||
@intToPtr(*PointerConstraint, constraint.data).setAsActive();
|
@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();
|
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.
|
/// Focus the given output, notifying any listening clients of the change.
|
||||||
pub fn focusOutput(self: *Self, output: *Output) void {
|
pub fn focusOutput(self: *Self, output: *Output) void {
|
||||||
if (self.focused_output == output) return;
|
if (self.focused_output == output) return;
|
||||||
@ -470,6 +474,12 @@ fn tryAddDevice(self: *Self, wlr_device: *wlr.InputDevice) !void {
|
|||||||
errdefer util.gpa.destroy(keyboard);
|
errdefer util.gpa.destroy(keyboard);
|
||||||
|
|
||||||
try keyboard.init(self, wlr_device);
|
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 => {
|
.pointer, .touch => {
|
||||||
const device = try util.gpa.create(InputDevice);
|
const device = try util.gpa.create(InputDevice);
|
||||||
|
Loading…
Reference in New Issue
Block a user