Keyboard: fix mapping XF86ScreenSaver

This commit is contained in:
Isaac Freund 2024-01-06 20:36:53 -06:00
parent afbc84c994
commit 540ca043df
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
2 changed files with 21 additions and 1 deletions

2
deps/zig-xkbcommon vendored

@ -1 +1 @@
Subproject commit e93ceb0436c66a7e4c727fdb59020e889519e489
Subproject commit 7b188de0ba794b52eb70340abf2469b858630816

View File

@ -257,6 +257,26 @@ fn parseKeysym(name: [:0]const u8, out: *?[]const u8) !xkb.Keysym {
out.* = try fmt.allocPrint(util.gpa, "invalid keysym '{s}'", .{name});
return Error.Other;
}
// The case insensitive matching done by xkbcommon returns the first
// lowercase match found if there are multiple matches that differ only in
// case. This works great for alphabetic keys for example but there is one
// problematic exception we handle specially here. For some reason there
// exist both uppercase and lowercase versions of XF86ScreenSaver with
// different keysym values for example. Switching to a case-sensitive match
// would be too much of a breaking change at this point so fix this by
// special-casing this exception.
if (@intFromEnum(keysym) == xkb.Keysym.XF86Screensaver) {
if (mem.eql(u8, name, "XF86Screensaver")) {
return keysym;
} else if (mem.eql(u8, name, "XF86ScreenSaver")) {
return @enumFromInt(xkb.Keysym.XF86ScreenSaver);
} else {
out.* = try fmt.allocPrint(util.gpa, "ambiguous keysym name '{s}'", .{name});
return Error.Other;
}
}
return keysym;
}