Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions windows/src/engine/keyman32/appint/aiTIP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ extern "C" __declspec(dllexport) BOOL WINAPI TIPIsKeymanRunning() {
extern "C" __declspec(dllexport) BOOL WINAPI TIPActivateKeyboard(GUID *profile) { // I3581
PKEYMAN64THREADDATA _td = ThreadGlobals();
if(!_td) return FALSE;

RefreshToggleState();

if(profile != NULL) {
for(int i = 0; i < _td->nKeyboards; i++) {
for(int j = 0; j < _td->lpKeyboards[i].nProfiles; j++) {
Expand Down
18 changes: 18 additions & 0 deletions windows/src/engine/keyman32/capsstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,21 @@
BOOL IsCapsLockOn(void) {
return GetKeyState(VK_CAPITAL) & 1;
}

/**
* Resync the Caps Lock and Num Lock state cache.
*
* Use when state may be stale after focus changes or when the toggle keys
* changed while this Keyman engine instance was not processing key events.
*/
void RefreshToggleState(void) {
DWORD previousShiftState = Globals::get_ShiftState();

if (GetKeyState(VK_CAPITAL) & 1) *Globals::ShiftState() |= CAPITALFLAG;
else *Globals::ShiftState() &= ~CAPITALFLAG;

if (GetKeyState(VK_NUMLOCK) & 1) *Globals::ShiftState() |= NUMLOCKFLAG;
else *Globals::ShiftState() &= ~NUMLOCKFLAG;

SendDebugMessageFormat("Enter: %x Exit: %x", previousShiftState, Globals::get_ShiftState());
}
1 change: 1 addition & 0 deletions windows/src/engine/keyman32/capsstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
#define __CAPSSTATE_H

BOOL IsCapsLockOn(void);
void RefreshToggleState(void);

#endif
6 changes: 1 addition & 5 deletions windows/src/engine/keyman32/kmhook_getmessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,7 @@ ProcessWMKeymanControl(WPARAM wParam, LPARAM lParam) {
void GetCapsAndNumlockState() { // I4793
DWORD n = Globals::get_ShiftState();

if(GetKeyState(VK_NUMLOCK) & 1) *Globals::ShiftState() |= NUMLOCKFLAG;
else *Globals::ShiftState() &= ~NUMLOCKFLAG;

if(GetKeyState(VK_CAPITAL) & 1) *Globals::ShiftState() |= CAPITALFLAG;
else *Globals::ShiftState() &= ~CAPITALFLAG;
RefreshToggleState();

if(GetKeyState(VK_SHIFT) < 0) *Globals::ShiftState() |= K_SHIFTFLAG;
else *Globals::ShiftState() &= ~K_SHIFTFLAG;
Expand Down
Loading