spiegel-keyman/windows
Marc Durdin 711541be60 fix(windows): reinstall low level keyboard hook if it gets removed
This change improves the stability of Keyman for Windows by monitoring
the health of the low level keyboard hook. If keyman.exe is unresponsive
at any time, Windows can silently uninstall its low level keyboard hook,
which results in (at least) two problems:

* Keyman's hotkeys stop working
* A modifier key can become stuck, if it was pressed around the time
  Keyman became unresponsive.

The most common scenario in which Keyman can become unresponsive is high
system load, e.g. rendering graphics, videoconference calls, compiling
software.

Restarting Keyman always resolved both of these two issues in the past,
but with this patch, I hope that this will no longer be necessary.

A related 'fakefreeze' project is included for simulating a keyman.exe
hang by posting a `wm_keyman_control:KMC_WATCHDOG_FAKEFREEZE` message to
it, which keyman.exe responds to by `Sleep()`ing for 5 seconds. While
keyman.exe is freezing, any keystroke will cause the low level hook to
be uninstalled by Windows.

Logging has been updated; look for "LowLevelHookWatchDog" in the log for
related events.

One final small change in keyman32.cpp, as I refactored the
WH_KEYBOARD_LL hook installation/uninstallation, was to always clear out
hook variables when uninstalling a hook, because if the hook fails to
uninstall, there's really nothing we can do about it anyway, and we
probably shouldn't be trying again.

Fixes: #8064
2025-11-17 16:30:43 +01:00
..
docs docs(windows): Update supported Unicode version 2025-09-11 11:35:40 +07:00
include chore(windows): move kmtip_guids.h and testkeymanfunctioning.h 2022-06-12 07:43:24 +10:00
src fix(windows): reinstall low level keyboard hook if it gets removed 2025-11-17 16:30:43 +01:00
build.sh maint(common): consolidate builder scripts 2025-08-02 08:11:24 +10:00