Revert "Remove checking translated keysyms"

This reverts commit 744e6b3052.

This broke VT switching and likely other keysyms which don't have
a "raw" equivalent.
This commit is contained in:
Isaac Freund 2020-10-21 15:24:11 +02:00
parent 03a2da9690
commit 3e4743e9a2
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11

View file

@ -80,6 +80,14 @@ fn handleKey(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
// Translate libinput keycode -> xkbcommon // Translate libinput keycode -> xkbcommon
const keycode = event.keycode + 8; const keycode = event.keycode + 8;
// Get a list of keysyms as xkb reports them
var translated_keysyms: ?[*]c.xkb_keysym_t = undefined;
const translated_keysyms_len = c.xkb_state_key_get_syms(
wlr_keyboard.xkb_state,
keycode,
&translated_keysyms,
);
// Get a list of keysyms ignoring modifiers (e.g. 1 instead of !) // Get a list of keysyms ignoring modifiers (e.g. 1 instead of !)
// Important for mappings like Mod+Shift+1 // Important for mappings like Mod+Shift+1
var raw_keysyms: ?[*]c.xkb_keysym_t = undefined; var raw_keysyms: ?[*]c.xkb_keysym_t = undefined;
@ -98,16 +106,29 @@ fn handleKey(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
const released = event.state == .WLR_KEY_RELEASED; const released = event.state == .WLR_KEY_RELEASED;
var i: usize = 0; var i: usize = 0;
while (i < raw_keysyms_len) : (i += 1) { while (i < translated_keysyms_len) : (i += 1) {
// Handle builtin mapping only when keys are pressed // Handle builtin mapping only when keys are pressed
if (!released and self.handleBuiltinMapping(raw_keysyms.?[i])) { if (!released and self.handleBuiltinMapping(translated_keysyms.?[i])) {
handled = true; handled = true;
break; break;
} else if (self.seat.handleMapping(raw_keysyms.?[i], modifiers, released)) { } else if (self.seat.handleMapping(translated_keysyms.?[i], modifiers, released)) {
handled = true; handled = true;
break; break;
} }
} }
if (!handled) {
i = 0;
while (i < raw_keysyms_len) : (i += 1) {
// Handle builtin mapping only when keys are pressed
if (!released and self.handleBuiltinMapping(raw_keysyms.?[i])) {
handled = true;
break;
} else if (self.seat.handleMapping(raw_keysyms.?[i], modifiers, released)) {
handled = true;
break;
}
}
}
if (!handled) { if (!handled) {
// Otherwise, we pass it along to the client. // Otherwise, we pass it along to the client.