Skip to content

fix(windows): resync caps lock state when Keyman keyboard is activated - #16423

Open
MattGyverLee wants to merge 5 commits into
keymanapp:masterfrom
MattGyverLee:fix/windows/16422-caps-lock-state-on-keyboard-switch
Open

fix(windows): resync caps lock state when Keyman keyboard is activated#16423
MattGyverLee wants to merge 5 commits into
keymanapp:masterfrom
MattGyverLee:fix/windows/16422-caps-lock-state-on-keyboard-switch

Conversation

@MattGyverLee

Copy link
Copy Markdown
Contributor

Here's a proposed fix for #16422 .

Full disclosure, Claude built this minimal fix. I have reviewed the result and tested it by inserting a rebuilt keyman32 and keyman64 DLLs in place. It's just displacing code, nothing new. Rereading the state of the system's locks on keyboard load makes sense to me.

I tested moving with Win+Space and via mouse between the Windows US English and Keyman Cameroon Keyboard. CAPS was detected when the Cameroon Keyboard activated and the first output letter was a capital. It worked well. I noted that switching to yoruba8 ignored the existing CAPS state without disabling it on the system, but this is expected since that keyboard doesn't have CAPS rules.

From Claude:

The Caps Lock and Num Lock flags in Globals::ShiftState() are updated only as key events pass through the engine, so they go stale when the toggle is changed while a non-Keyman layout is active. The existing resync in GetCapsAndNumlockState() runs on window focus change, which a keyboard switch does not trigger, so the core processor was told Caps Lock was off until the user toggled it twice.

Extract the toggle resync as RefreshToggleState() and call it from TIPActivateKeyboard(), which is the profile activation path for both Win+Space and the Windows language selector.

The Caps Lock and Num Lock flags in Globals::ShiftState() are updated
only as key events pass through the engine, so they go stale when the
toggle is changed while a non-Keyman layout is active. The existing
resync in GetCapsAndNumlockState() runs on window focus change, which a
keyboard switch does not trigger, so the core processor was told Caps
Lock was off until the user toggled it twice.

Extract the toggle resync as RefreshToggleState() and call it from
TIPActivateKeyboard(), which is the profile activation path for both
Win+Space and the Windows language selector.

Fixes keymanapp#16422

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011GdFpFi5eqJP6C1YjuQytY
@github-project-automation github-project-automation Bot moved this to Todo in Keyman Aug 21, 2026
@keymanapp-test-bot keymanapp-test-bot Bot added the user-test-missing User tests have not yet been defined for the PR label Aug 21, 2026
@keymanapp-test-bot

Copy link
Copy Markdown

User Test Results

Test specification and instructions

ERROR: user tests have not yet been defined

@keymanapp-test-bot keymanapp-test-bot Bot added this to the A19S36 milestone Aug 21, 2026
@keyman-server

Copy link
Copy Markdown
Collaborator

This pull request is from an external repo and will not automatically be built. The build must still be passed before it can be merged. Ask one of the team members to make a manual build of this PR.

@mcdurdin mcdurdin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. This looks pretty straightforward and clean. We will need to test this in conjunction with the caps lock stores, in particular &CapsAlwaysOff, to ensure that we get a consistent result, and I would like @rc-swag to sign off on the change.

Comment thread windows/src/engine/keyman32/appint/aiTIP.cpp Outdated
Comment thread windows/src/engine/keyman32/capsstate.cpp Outdated
Comment thread windows/src/engine/keyman32/capsstate.cpp Outdated
Comment thread windows/src/engine/keyman32/capsstate.cpp Outdated
@mcdurdin
mcdurdin requested a review from rc-swag August 22, 2026 06:50
@mcdurdin

Copy link
Copy Markdown
Member

@rc-swag can you write up some user tests for this also?

MattGyverLee and others added 4 commits August 22, 2026 10:25
Co-authored-by: Marc Durdin <marc@durdin.net>
Co-authored-by: Marc Durdin <marc@durdin.net>
Co-authored-by: Marc Durdin <marc@durdin.net>
Co-authored-by: Marc Durdin <marc@durdin.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix user-test-missing User tests have not yet been defined for the PR windows/

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants