fix(sway/language): keep flag visible across hot-plug and unknown layouts#5039
Open
mil-ad wants to merge 1 commit into
Open
fix(sway/language): keep flag visible across hot-plug and unknown layouts#5039mil-ad wants to merge 1 commit into
mil-ad wants to merge 1 commit into
Conversation
…gged devices) so transient events stop blanking layout_. Refresh layouts_map_ on "added"/"xkb_keymap" input events and union layouts across all keyboards so new devices contribute their layouts. Release mutex_ before the refresh sendCmd to avoid self-deadlock from the synchronous signal_cmd emit.
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.
Fixes the
sway/languagemodule silently clearing its{flag}(and{short}/{shortDescription}/{variant}) output until waybar is restarted.Root cause
Two cooperating bugs in
src/modules/sway/language.cpp:set_current_layoutblankslayout_on an unknown name.std::map::operator[]default-constructs aLayouton a missing key, socountry_flag()returns"". Triggered bywtype's transient virtual keyboard (sway/language flag disappears with wtype #1536, wtype breaks the language module #2079) and hot-plugged devices whose layouts weren't in the map at startup ([Bug] sway/language doesn't show the correct flag when a different keyboard is plugged in #4426).layouts_map_is built once, from one device.onCmdonly runs at startup and stores only the single device with the most layouts. New keyboards with disjoint layouts never make it into the map.Fix
set_current_layoutwithfind()and early-return on miss, preserving the last known goodlayout_.layouts_map_fromonEventonchange == "added" || "xkb_keymap"viaipc_.sendCmd(IPC_GET_INPUTS).onCmdre-runnable — union layouts across every keyboard input andlayouts_map_.clear()before each rebuild to avoid compounding the duplicate-suffix pass ("us"→"us1"→"us11").sendCmdis synchronous and re-emitssignal_cmdon the calling thread, so the refresh call is made after releasingmutex_to avoid a self-deadlock whenonCmdre-locks it.