summaryrefslogtreecommitdiff
path: root/gtk/gtkimmodule.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2013-08-11 15:42:19 -0400
committerMatthias Clasen <mclasen@redhat.com>2013-08-11 15:42:19 -0400
commitea715a49e481bb204e13ca1f24733cfc40017e30 (patch)
tree08915a87aaefc95badcf2cabefbbdbc245ef9631 /gtk/gtkimmodule.c
parentf4a138c7bd9baf56685b4c8193f1371530a8f028 (diff)
downloadgtk+-ea715a49e481bb204e13ca1f24733cfc40017e30.tar.gz
Deal with platform-specific im modules
With multiple GDK backends in the process, we run into problems where we try to use the Wayland im module on X, which crashes. This commit adds a quick backend filter that removes the wayland, xim and ime input methods from consideration unless the corresponding GDK backend is in use.
Diffstat (limited to 'gtk/gtkimmodule.c')
-rw-r--r--gtk/gtkimmodule.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/gtk/gtkimmodule.c b/gtk/gtkimmodule.c
index 2cbf9da167..f17672bbff 100644
--- a/gtk/gtkimmodule.c
+++ b/gtk/gtkimmodule.c
@@ -37,6 +37,18 @@
#include "gtkprivate.h"
#include "gtkintl.h"
+#ifdef GDK_WINDOWING_X11
+#include "x11/gdkx.h"
+#endif
+
+#ifdef GDK_WINDOWING_WAYLAND
+#include "wayland/gdkwayland.h"
+#endif
+
+#ifdef GDK_WINDOWING_WIN32
+#include "win32/gdkwin32.h"
+#endif
+
#undef GDK_DEPRECATED
#undef GDK_DEPRECATED_FOR
#define GDK_DEPRECATED
@@ -638,6 +650,27 @@ match_locale (const gchar *locale,
return 0;
}
+static gboolean
+match_backend (GtkIMContextInfo *context)
+{
+#ifdef GDK_WINDOWING_WAYLAND
+ if (g_strcmp0 (context->context_id, "wayland") == 0)
+ return GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ());
+#endif
+
+#ifdef GDK_WINDOWING_X11
+ if (g_strcmp0 (context->context_id, "xim") == 0)
+ return GDK_IS_X11_DISPLAY (gdk_display_get_default ());
+#endif
+
+#ifdef GDK_WINDOWING_WIN32
+ if (g_strcmp0 (context->context_id, "ime") == 0)
+ return GDK_IS_WIN32_DISPLAY (gdk_display_get_default ());
+#endif
+
+ return TRUE;
+}
+
static const gchar *
lookup_immodule (gchar **immodules_list)
{
@@ -728,7 +761,12 @@ _gtk_im_module_get_default_context_id (GdkWindow *client_window)
for (i = 0; i < module->n_contexts; i++)
{
- const gchar *p = module->contexts[i]->default_locales;
+ const gchar *p;
+
+ if (!match_backend (module->contexts[i]))
+ continue;
+
+ p = module->contexts[i]->default_locales;
while (p)
{
const gchar *q = strchr (p, ':');