summaryrefslogtreecommitdiff
path: root/gtk/gtkimcontextsimple.c
diff options
context:
space:
mode:
authorРуслан Ижбулатов <lrn1986@gmail.com>2016-07-16 09:23:22 +0000
committerРуслан Ижбулатов <lrn1986@gmail.com>2016-08-04 16:37:19 +0000
commit5e6c1928b4b45e34fd70d56f5cd229cfb2f30518 (patch)
treef719e13320c3588525d6dc9a5ebeb5c84e30e593 /gtk/gtkimcontextsimple.c
parent52c7e07948f0d82ade7c730e99c53dea3e13ca67 (diff)
downloadgtk+-5e6c1928b4b45e34fd70d56f5cd229cfb2f30518.tar.gz
W32: Prefer the deadkey combinations that the OS uses
Pick the W32 API for possible deadkey+<something> combinations and prefer these to other sources of deadkey combos. Specifically, if W32 API supports at least one combo for a particular deadkey, only use that data and do not attempt to do other, unsupported combinations, even if they make sense otherwise. This is needed to, for example, correctly support US-International keyboard layout, which produces a combined character for <' + a> combo, but not for <' + s>, for example. This is achieved by stashing all the deadkeys that we find in an array, then doing extra loop through all virtual key codes and trying to combine them with each of these deadkeys. Any combinations that produce a single character are cached for later use. In GTK Simple IM context, call a new GDK W32 function to do a lookup on that cached combination table early on, among the "special cases" (which are now partially obsolete). A limitation of this code is that combinations with more than one deadkey are not supported, except for combinations that consist entirely of 2 known deadkeys. The upshot is that lookups should be relatively fast, as deadkey array stays small and the combination tree stays shallow. Note that the use of ToUnicodeEx() seems suboptimal, as it should be possible to just load a keyboard library (KBD*.DLL) manually and obtain and use its key table directly. However, that is much more complicated and would result in a significant rewrite of gdkkeys-win32. The code from this commit, though hacky, is a direct addition to existing code and should cover vast majority of the use-cases. https://bugzilla.gnome.org/show_bug.cgi?id=569581
Diffstat (limited to 'gtk/gtkimcontextsimple.c')
-rw-r--r--gtk/gtkimcontextsimple.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c
index 897770d6c0..a04224e14c 100644
--- a/gtk/gtkimcontextsimple.c
+++ b/gtk/gtkimcontextsimple.c
@@ -25,6 +25,9 @@
#ifdef GDK_WINDOWING_WAYLAND
#include <wayland/gdkwayland.h>
#endif
+#ifdef GDK_WINDOWING_WIN32
+#include <win32/gdkwin32.h>
+#endif
#include <stdlib.h>
#include <string.h>
@@ -1213,6 +1216,32 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
{
gboolean success = FALSE;
+#ifdef GDK_WINDOWING_WIN32
+ guint16 output[2];
+ gsize output_size = 2;
+
+ switch (gdk_win32_keymap_check_compose (GDK_WIN32_KEYMAP (gdk_keymap_get_default ()),
+ priv->compose_buffer,
+ n_compose,
+ output, &output_size))
+ {
+ case GDK_WIN32_KEYMAP_MATCH_NONE:
+ break;
+ case GDK_WIN32_KEYMAP_MATCH_EXACT:
+ case GDK_WIN32_KEYMAP_MATCH_PARTIAL:
+ for (i = 0; i < output_size; i++)
+ {
+ output_char = gdk_keyval_to_unicode (output[i]);
+ gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple),
+ output_char);
+ }
+ priv->compose_buffer[0] = 0;
+ return TRUE;
+ case GDK_WIN32_KEYMAP_MATCH_INCOMPLETE:
+ return TRUE;
+ }
+#endif
+
G_LOCK (global_tables);
tmp_list = global_tables;