• LRN's avatar
    GDK W32: Test for IME correctly · 64ab82c4
    LRN authored
    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.
    64ab82c4