spiegel-keyman/windows/include/keymancontrol.h
Marc Durdin 0e332b6f6c
Some checks are pending
Keyman Build Summary / Summarize build status checks (push) Waiting to run
fix(windows): simplify keyboard refresh and make it more on-demand
Clean up the keyboard refresh process. Keyman COM API will post a
`wm_keyman_refresh`, `KR_REQUEST_REFRESH` message when changes have been
made to the list of installed keyboards (or some other keyboard-related
settings change).

Keyman Engine (any arch) will handle this message, in any process, and
post a message to the master controller (keyman.exe, TfrmKeyman7Main),
`wm_keyman_refresh`, `KR_PRE_REFRESH`.

Keyman Engine (keyman32) will handle _this_ message in the master
controller thread context, and increment the global refresh tag. It also
asks the other architecture host process(es) to update their global
refresh counter to the same value (by posting `wm_keyman_refresh`,
`KM_PRE_REFRESH` to those process(es).)

This refresh tag is then compared on-demand in each thread to the
thread's current refresh tag value, when a keyboard activation is
received, on set focus, or on a keystroke, and the keyboard list is
refreshed at that point.

This means that keyboard installation no longer triggers a large amount
of activity reloading all the keyboards on all windowed threads, but
rather they will gradually reload as the user interacts with them. It
also fixes #15333, which related to having threads with only child
windows -- that is, that were parented by top-level windows from other
threads -- which thus never received the global broadcast in the earlier
design. For example, VSCode, Notepad in Win11, Chrome.

Fixes: #15333
2026-08-26 10:15:46 +02:00

77 lines
3.2 KiB
C

/*
Name: keymancontrol
Copyright: Copyright (C) SIL International.
Documentation:
Description:
Create Date: 1 Aug 2006
Modified Date: 13 Oct 2014
Authors: mcdurdin
Related Files:
Dependencies:
Bugs:
Todo:
Notes:
History: 01 Aug 2006 - mcdurdin - Add KMC_REFRESH and KMC_INTERFACEHOTKEY wm_keyman_control messages
11 Dec 2009 - mcdurdin - I934 - x64 platfrom comms add KMC_SETFOCUSINFO
06 Apr 2010 - mcdurdin - I2271 - Select Keyboard tidy up
24 Oct 2013 - mcdurdin - I3933 - V9.0 - Keyman tray icon menu is not showing installed keyboards
07 Nov 2013 - mcdurdin - I3949 - V9.0 - Keyboard selection and notification needs consolidation
03 Aug 2014 - mcdurdin - I4326 - V9.0 - Switch-off hotkey not working, then keyboard hotkey stopped working (win 8.1 jeremy) [High]
13 Oct 2014 - mcdurdin - I4451 - V9.0 - Language hotkeys are not working
*/
//#define KMC_KEYBOARDCHANGED 1 // I3949
//#define KMC_CHANGEUISTATE 2
//#define KMC_GETLOADED 3
#define KMC_REFRESH 4
#define KMC_INTERFACEHOTKEY 5
//#define KMC_NOTIFYWELCOME 6 // 7.0.245.0
//#define KMC_NOTIFYWELCOMEEVENT 7 // 7.0.245.0
#define KMC_ONSCREENKEYBOARD 8 // 7.0.248.0
#define KMC_SETFOCUSINFO 9 // 7.1.270.0
#define KMC_GETLASTFOCUS 10 // 7.1.270.0
#define KMC_GETLASTACTIVE 11
#define KMC_GETLASTKEYMANID 12 // 7.1.274.0
#define KMC_GETLASTHKL 13 // 7.1.274.0
//#define KMC_LANGUAGESWITCH 14 // 8.0.290.0
//#define KMC_HKLCHANGED 15 // 8.0.290.0 // I3949
#define KMC_KEYDOWN 16 // 8.0.291.0
#define KMC_KEYUP 17 // 8.0.291.0
#define KMC_PROFILECHANGED 18 // 9.0.426.0 // I3933
#define KMC_HINTRESPONSE 19 // 14.0 HIWORD(wParam) = ModalResult, lParam = hint enum
#define KMC_WATCHDOG_FAKEFREEZE 20 // 19.0 - pause Keyman for 5 seconds for debug purposes to test stability
#define KMC_WATCHDOG_KEYEVENT 21 // 19.0 - let the LowLevelHookWatchDog know that input has happened on another thread
#define KMC_WATCHDOG_HOOK_REINSTALL 22 // 19.0 - tell master controller about hook reinstall events
// KMC_WATCHDOG_HOOK_REINSTALL event types
#define WHR_TIMING 0 // 19.0 - report on timing
#define WHR_INIT_FAILURE 1 // 19.0 - hook failed to (re)install
#define WHR_UNINIT_FAILURE 2 // 19.0 - hook failed to uninstall
#define PC_UPDATE 0 // Tell Keyman to update its display of active keyboard
#define PC_UPDATE_LANGUAGESWITCH 1 // Tell Keyman to update its display of active keyboard and then open language switch form
#define PC_HOTKEYCHANGE 2 // Tell Keyman that a hotkey was pressed to switch keyboard
//#define KMC_KEYBOARDHOTKEY 19 // 9.0.459.0 // I4326 Deprecated in favour of language hotkeys
#define KMC_LANGUAGEHOTKEY 20
//TOUCH #define KMC_CONTEXT 19 // 9.0.450.0
// Cross-architecture comms
#define KMC_REGISTER_HOST_WINDOW_X64 23
#define KMC_REGISTER_HOST_WINDOW_ARM64 24
#define RWM_KEYMAN_CONTROL "WM_KEYMAN_CONTROL"
#define RWM_KEYMAN_CONTROL_W L"WM_KEYMAN_CONTROL"
#define khLanguageSwitch 8