feat: add AZERTY support (#164)
Browse files
* feat: add AZERTY support to lua config (fixes #125) * Update lua.zig * fix(x11): dynamically refresh key grabs on MappingNotify Resolves an issue where non-QWERTY keybinds (e.g., AZERTY special characters) would fail to register if the keyboard layout was applied after the WM initially started. The WM now listens for MappingNotify events and will automatically ungrab and regrab keys whenever the keyboard map or modifiers change. --------- Co-authored-by: ozyz <ozyz@proton.me>
+10 −0 src/config/lua.zig
| @@ -1294,9 +1294,19 @@ fn keynameToKeysym(name: []const u8) ?u64 { | ||
| 1294 | 1294 | .{ "bracketleft", 0x005b }, |
| 1295 | 1295 | .{ "bracketright", 0x005d }, |
| 1296 | 1296 | .{ "backslash", 0x005c }, |
| 1297 | + .{ "colon", 0x003a }, | |
| 1297 | 1298 | .{ "semicolon", 0x003b }, |
| 1298 | 1299 | .{ "apostrophe", 0x0027 }, |
| 1300 | + .{ "quotedbl", 0x0022 }, | |
| 1301 | + .{ "ampersand", 0x0026 }, | |
| 1302 | + .{ "parenleft", 0x0028 }, | |
| 1303 | + .{ "parenright", 0x0029 }, | |
| 1304 | + .{ "underscore", 0x005f }, | |
| 1299 | 1305 | .{ "grave", 0x0060 }, |
| 1306 | + .{ "agrave", 0x00e0 }, | |
| 1307 | + .{ "egrave", 0x00e8 }, | |
| 1308 | + .{ "ccedilla", 0x00e7 }, | |
| 1309 | + .{ "eacute", 0x00e9 }, | |
| 1300 | 1310 | .{ "Left", 0xff51 }, |
| 1301 | 1311 | .{ "Up", 0xff52 }, |
| 1302 | 1312 | .{ "Right", 0xff53 }, |
+10 −0 src/wm/handlers.zig
| @@ -32,6 +32,7 @@ pub fn handleEvent(event: *xlib.XEvent, wm: *WindowManager) void { | ||
| 32 | 32 | .button_press => handleButtonPress(&event.xbutton, wm), |
| 33 | 33 | .expose => handleExpose(&event.xexpose, wm), |
| 34 | 34 | .property_notify => handlePropertyNotify(&event.xproperty, wm), |
| 35 | + .mapping_notify => handleMappingNotify(&event.xmapping, wm), | |
| 35 | 36 | else => {}, |
| 36 | 37 | } |
| 37 | 38 | } |
| @@ -360,3 +361,12 @@ fn handlePropertyNotify(event: *xlib.XPropertyEvent, wm: *WindowManager) void { | ||
| 360 | 361 | core.updateWindowType(client, wm); |
| 361 | 362 | } |
| 362 | 363 | } |
| 364 | + | |
| 365 | +fn handleMappingNotify(event: *xlib.XMappingEvent, wm: *WindowManager) void { | |
| 366 | + _ = xlib.XRefreshKeyboardMapping(event); | |
| 367 | + | |
| 368 | + if (event.request == xlib.MappingKeyboard or event.request == xlib.MappingModifier) { | |
| 369 | + wm.ungrabKeybinds(); | |
| 370 | + wm.grabKeybinds(); | |
| 371 | + } | |
| 372 | +} |
+5 −0 src/x11/xlib.zig
| @@ -268,3 +268,8 @@ pub const XC_fleur = c.XC_fleur; | ||
| 268 | 268 | pub const XAllowEvents = c.XAllowEvents; |
| 269 | 269 | pub const ReplayPointer = c.ReplayPointer; |
| 270 | 270 | pub const AnyButton = c.AnyButton; |
| 271 | + | |
| 272 | +pub const XMappingEvent = c.XMappingEvent; | |
| 273 | +pub const XRefreshKeyboardMapping = c.XRefreshKeyboardMapping; | |
| 274 | +pub const MappingKeyboard = c.MappingKeyboard; | |
| 275 | +pub const MappingModifier = c.MappingModifier; |