Skip to content

GDK W32: Support switching input modules at runtime

LRN requested to merge lrn/gtk:win32-runtime-immodule-swap into gtk-3-24

This leverages the normal input module switching mechanism in GTK by making it think that the gtk-im-module setting changed. Actually, the backend always returns an empty string when asked to query this setting. However, this still triggers an input module loading code, which, not being able to load the desired module (which is and empty string), falls back to looking at current keyboard layout.

Paired with the code that signals gtk-im-module change on keyboard layout switches, this is sufficient to make GTK capable of loading appropriate input modules at runtime. At least, the kinds of modules that specify languages for which they are loaded automatically by default.

Loading other kinds of input modules might still work via specifying the gtk-im-module setting in gtk ini file, but doing so will likely make GTK incapable of loading the IME input module that is used for Korean, Chinese and Japanese.

Until someone figures out a way to actually change gtk-im-module setting on Windows at runtime with meaningful values, the behaviour introduced by this commit seems like a sufficient workaround.

Fixes #1375 (closed)

Merge request reports