Repository navigation
fix(wayland): cache compiled XKB keymap per UI thread for layer-shell overlays (#3296) - #3309
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Caches the seat's last compiled XKB keymap and its resolved virtual-modifier bitmasks per UI thread so Wayland layer-shell overlays reuse the reference-counted
xkb::Keymaphandle across recreated keyboard surfaces instead of recompilingxkb::Keymap::new_from_stringon everywl_keyboard.keymapevent.Fixes #3296.
Changes
crates/rune/src/platform/layer_shell_machine/keymap_cache.rs: Add a cross-platform, one-entryKeymapCache<T>keyed by(payload.len(), blake3::Hash)(40 bytes of key metadata instead of retaining the raw keymap text). Matching payloads return a cloned handle without compiling; different payloads replace the entry; failed compilations (None) leave any existing cached entry intact.crates/rune/src/platform/layer_shell/keymap.rs: WrapKeymapCache<CompiledKeymap>in athread_local!cache (matchingcompose.rs, becauselibxkbcommon's reference counts are non-atomic) that caches bothxkb::KeymapandResolvedModMasks.crates/rune/src/platform/layer_shell/devices.rs: Routewl_keyboard::Event::Keymapthroughkeymap::compile_keymap(map)while keeping each surface's ownxkb::Stateand modifier mask reapplication.crates/rune/src/platform/layer_shell_machine/keymap_cache_tests.rs: cross-platform unit tests covering cache hits, same-length and different-length layout-change invalidation, eviction of the replaced entry, compile-failure preservation, and cache clearing.crates/rune/src/platform/layer_shell/keys_tests.rs: Linuxxkbcommontest (a_keyboard_surface_reuses_the_compiled_keymap_until_the_seat_sends_another) covering handle reuse (get_raw_ptr), independent per-surfacexkb::State, invalid-payload preservation, layout switching with updated keysyms andResolvedModMasks, and thread-local isolation.changelog/unreleased/2026-12-03-wayland-layer-shell-keymap-cache.md.Verification
cargo test -j 1 -p rune --lib keymap_cache(2/2 passed)cargo clippy -j 1 -p rune --lib --tests --no-deps(clean)cargo check -j 1 -p rune --target wasm32-unknown-unknown(clean)scripts/file-size.sh(0 errors)xkbcommoncompilation anda_keyboard_surface_reuses_the_compiled_keymap_until_the_seat_sends_anotherare verified on Linux CI (check/clippy). A live Wayland compositor session was not tested locally on Windows.