[gtk+] GtkIMModule: Use default screen when determining context id
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkIMModule: Use default screen when determining context id
- Date: Sun, 11 Aug 2013 19:38:48 +0000 (UTC)
commit f4a138c7bd9baf56685b4c8193f1371530a8f028
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Aug 11 15:35:07 2013 -0400
GtkIMModule: Use default screen when determining context id
This code is called early on, without a window, and then later on
with a window. Currently, it returns different results for these
cases when the setting contains a value. That leads to pointless
construction and destruction of im contexts. Instead, just look
at the settings of the default screen. In practice, there is only
one screen, ever.
gtk/gtkimmodule.c | 43 ++++++++++++++++++++-----------------------
1 files changed, 20 insertions(+), 23 deletions(-)
---
diff --git a/gtk/gtkimmodule.c b/gtk/gtkimmodule.c
index e6372f2..2cbf9da 100644
--- a/gtk/gtkimmodule.c
+++ b/gtk/gtkimmodule.c
@@ -680,16 +680,16 @@ _gtk_im_module_get_default_context_id (GdkWindow *client_window)
const gchar *envvar;
GdkScreen *screen;
GtkSettings *settings;
-
+
if (!contexts_hash)
gtk_im_module_initialize ();
- envvar = g_getenv("GTK_IM_MODULE");
+ envvar = g_getenv ("GTK_IM_MODULE");
if (envvar)
{
- immodules = g_strsplit(envvar, ":", 0);
- context_id = lookup_immodule(immodules);
- g_strfreev(immodules);
+ immodules = g_strsplit (envvar, ":", 0);
+ context_id = lookup_immodule (immodules);
+ g_strfreev (immodules);
if (context_id)
return context_id;
@@ -697,21 +697,18 @@ _gtk_im_module_get_default_context_id (GdkWindow *client_window)
/* Check if the certain immodule is set in XSETTINGS.
*/
- if (GDK_IS_WINDOW (client_window))
+ screen = gdk_screen_get_default ();
+ settings = gtk_settings_get_for_screen (screen);
+ g_object_get (G_OBJECT (settings), "gtk-im-module", &tmp, NULL);
+ if (tmp)
{
- screen = gdk_window_get_screen (client_window);
- settings = gtk_settings_get_for_screen (screen);
- g_object_get (G_OBJECT (settings), "gtk-im-module", &tmp, NULL);
- if (tmp)
- {
- immodules = g_strsplit(tmp, ":", 0);
- context_id = lookup_immodule(immodules);
- g_strfreev(immodules);
- g_free (tmp);
-
- if (context_id)
- return context_id;
- }
+ immodules = g_strsplit (tmp, ":", 0);
+ context_id = lookup_immodule (immodules);
+ g_strfreev (immodules);
+ g_free (tmp);
+
+ if (context_id)
+ return context_id;
}
/* Strip the locale code down to the essentials
@@ -723,12 +720,12 @@ _gtk_im_module_get_default_context_id (GdkWindow *client_window)
tmp = strchr (tmp_locale, '@');
if (tmp)
*tmp = '\0';
-
+
tmp_list = modules_list;
while (tmp_list)
{
GtkIMModule *module = tmp_list->data;
-
+
for (i = 0; i < module->n_contexts; i++)
{
const gchar *p = module->contexts[i]->default_locales;
@@ -746,11 +743,11 @@ _gtk_im_module_get_default_context_id (GdkWindow *client_window)
p = q ? q + 1 : NULL;
}
}
-
+
tmp_list = tmp_list->next;
}
g_free (tmp_locale);
-
+
return context_id ? context_id : SIMPLE_ID;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]