git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit664541dbf0fc4cee37fa171ce3e631453719a52e
parent877e2f0b94
authorIsaac Freund <[email protected]>
date2024-01-06 20:36
Keyboard: fix mapping XF86ScreenSaver

 deps/zig-xkbcommon    |  2 +-
 river/command/map.zig | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/deps/zig-xkbcommon b/deps/zig-xkbcommon
index e93ceb0..7b188de 160000
--- a/deps/zig-xkbcommon
+++ b/deps/zig-xkbcommon
@@ -1 +1 @@
-Subproject commit e93ceb0436c66a7e4c727fdb59020e889519e489
+Subproject commit 7b188de0ba794b52eb70340abf2469b858630816
diff --git a/river/command/map.zig b/river/command/map.zig
index 2892636..3ba5af6 100644
--- a/river/command/map.zig
+++ b/river/command/map.zig
@@ -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;
 }