fix: make compositor keyboard layout policy follow layout switches - #24
Open
maryny4 wants to merge 1 commit into
Open
fix: make compositor keyboard layout policy follow layout switches#24maryny4 wants to merge 1 commit into
maryny4 wants to merge 1 commit into
Conversation
Two mechanisms replace the wl_keyboard.modifiers sync, which is unreachable for hypr-rdp: modifiers events are delivered only after wl_keyboard.enter, i.e. to the client whose surface holds keyboard focus, and hypr-rdp has no surfaces. The group therefore stayed 0 forever and every modifier change reset the virtual keyboard's layout (Hyprland also silently ignores switchxkblayout for virtual keyboards, so only the virtual keyboard owner can switch its group). - Subscribe to Hyprland socket2 activelayout events and mirror external layout switches (hyprctl switchxkblayout, physical keyboards) onto the virtual keyboard. - Replicate per-key XKB state processing so group toggle options (e.g. grp:alt_shift_toggle) forwarded by the RDP client switch the tracked group in lockstep with the compositor's own processing. (cherry picked from commit 4d4a193)
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.
Problem
With
keyboard_layout_policy = "compositor", layout switching never works over RDP:hyprctl switchxkblayout all nexthas no effect on RDP input, and Alt+Shift forwarded by the RDP client snaps back on the next modifier press. This is the behavior #14 describes; the sync added in a6b0e43 cannot receive the data it needs:wl_state.keyboard_groupis only updated fromwl_keyboard::Event::Modifiers, but Wayland deliversmodifiersonly afterwl_keyboard.enter, i.e. to the client whose surface holds keyboard focus. hypr-rdp has no surfaces, so the event never arrives and the group stays 0 forever. Verified with a minimal surfaceless client (bindwl_seat→get_keyboard, switch layouts): it receiveskeymap=1, enter=0, modifiers=0, repeat_info=1. The existing unit tests pass because they setkeyboard_groupon the struct directly.KeyboardEvent::Synchronizemstsc sends on window focus) then emitszwp_virtual_keyboard_v1.modifiers(..., group=0), resetting whatever layout was switched — including group toggles Hyprland itself performs on the virtual keyboard when the client forwards Alt+Shift.switchxkblayoutfor virtual keyboards (returnsok, index unchanged) and emits noactivelayoutevents for them, so the virtual keyboard's group can only be set by its owner through the virtual-keyboard protocol.Fix
Replace the unreachable wl_keyboard sync with two mechanisms (both under the
compositorpolicy):activelayoutevents via the existinghyprland::EventStream, resolve the event's layout name against the compiled keymap's layout names, and mirror external switches (hyprctl switchxkblayout, physical keyboards) onto the virtual keyboard with an immediatemodifiers()send.KeyboardStateTracker(xkb_state_update_key+serialize_layout), so group toggle options likegrp:alt_shift_toggleforwarded by the RDP client switch the tracked group in lockstep with the compositor's own processing of the same key stream.clientpolicy behavior is unchanged. No new dependencies.xkb::Stateis wrapped with an explicitunsafe impl Send— access is serialized by theInputStatemutex, and libxkbcommon objects have no thread affinity.Verification
cargo fmt --check,cargo clippy -- -D warnings,cargo testandcargo test --no-default-featuresall pass; new tests cover the Alt+Shift toggle, composition of external switches with toggles, layout-name resolution, and activelayout parsing.switchxkblayout all next, the patched instance follows the switch and back (hyprctl devices+ log).Fixes the remaining part of #14.