GDK W32: Test for IME correctly

ImmIsIME() doesn't work (always returns TRUE) since Vista.
Use ITfActiveLanguageProfileNotifySink to detect TSF changes,
which are equal to IME changes for us.

Also make sure that IMMultiContext re-loads the IM when keyboard layout
changes, otherwise there's a subtle bug that could happen:
* Run GTK application with non-IME layout (US, for example)
* Focus on an editable widget (GtkEntry, for example)
* IM Context is initialized to use the simple IM
* Switch to an IME layout (such as Korean)
* Start typing
* Since IME module is not loaded yet, keypresses are handled
  by a default MS IME handler
* Once IME commits a character, GDK will get a WM_KEYDOWN,
  which will trigger a GdkKeyEvent, which will be handled by
  an event filter in IM Context, which will finally re-evaluate
  its status and load IME, and only after that GTK will get
  to handle IME by itself - but by that point input would
  already be broken.
To avoid this we can emit a dummy event (with Void keyval),
which will cause IM Context to load the appropriate module
immediately.
This commit is contained in:
Руслан Ижбулатов
2019-01-12 21:32:48 +00:00
parent 17665f06e3
commit 3b244c9f11
7 changed files with 221 additions and 3 deletions

View File

@ -38,7 +38,7 @@ HINSTANCE _gdk_app_hmodule;
gint _gdk_input_ignore_core;
HKL _gdk_input_locale;
gboolean _gdk_input_locale_is_ime;
gboolean _gdk_input_locale_is_ime = FALSE;
UINT _gdk_input_codepage;
gint _gdk_input_ignore_wintab = FALSE;