[gnome-settings-daemon/gnome-3-8] keyboard: Use the gtk+ ibus module if there's at least one ibus source
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/gnome-3-8] keyboard: Use the gtk+ ibus module if there's at least one ibus source
- Date: Tue, 19 Mar 2013 15:19:03 +0000 (UTC)
commit 39b26a6b1f98b5331cc8611534edecdda502b39e
Author: Rui Matos <tiagomatos gmail com>
Date: Tue Mar 19 15:13:53 2013 +0100
keyboard: Use the gtk+ ibus module if there's at least one ibus source
Switching the gtk+ IM module when switching input source adds delays
and races with the input events themselves. Thus it's better to always
use the ibus module as long as the user has at least one ibus input
source.
https://bugzilla.gnome.org/show_bug.cgi?id=696141
plugins/keyboard/gsd-keyboard-manager.c | 61 +++++++++++++++++++++----------
1 files changed, 42 insertions(+), 19 deletions(-)
---
diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c
index e4de28a..2d4a344 100644
--- a/plugins/keyboard/gsd-keyboard-manager.c
+++ b/plugins/keyboard/gsd-keyboard-manager.c
@@ -123,7 +123,7 @@ static gboolean apply_input_sources_settings (GSettings *setti
gint n_keys,
GsdKeyboardManager *manager);
static void set_gtk_im_module (GsdKeyboardManager *manager,
- const gchar *new_module);
+ GVariant *sources);
G_DEFINE_TYPE (GsdKeyboardManager, gsd_keyboard_manager, G_TYPE_OBJECT)
@@ -319,6 +319,43 @@ set_ibus_xkb_engine (GsdKeyboardManager *manager)
set_ibus_engine (manager, ibus_engine_desc_get_name (engine));
}
+static gboolean
+need_ibus (GVariant *sources)
+{
+ GVariantIter iter;
+ const gchar *type;
+
+ g_variant_iter_init (&iter, sources);
+ while (g_variant_iter_next (&iter, "(&s&s)", &type, NULL))
+ if (g_str_equal (type, INPUT_SOURCE_TYPE_IBUS))
+ return TRUE;
+
+ return FALSE;
+}
+
+
+static void
+set_gtk_im_module (GsdKeyboardManager *manager,
+ GVariant *sources)
+{
+ GsdKeyboardManagerPrivate *priv = manager->priv;
+ const gchar *new_module;
+ gchar *current_module;
+
+ if (!sources || need_ibus (sources))
+ new_module = GTK_IM_MODULE_IBUS;
+ else
+ new_module = GTK_IM_MODULE_SIMPLE;
+
+ current_module = g_settings_get_string (priv->interface_settings,
+ KEY_GTK_IM_MODULE);
+ if (!g_str_equal (current_module, new_module))
+ g_settings_set_string (priv->interface_settings,
+ KEY_GTK_IM_MODULE,
+ new_module);
+ g_free (current_module);
+}
+
/* XXX: See upstream bug:
* https://codereview.appspot.com/6586075/ */
static gchar *
@@ -903,22 +940,6 @@ apply_xkb_settings (GsdKeyboardManager *manager,
g_free (rules_file_path);
}
-static void
-set_gtk_im_module (GsdKeyboardManager *manager,
- const gchar *new_module)
-{
- GsdKeyboardManagerPrivate *priv = manager->priv;
- gchar *current_module;
-
- current_module = g_settings_get_string (priv->interface_settings,
- KEY_GTK_IM_MODULE);
- if (!g_str_equal (current_module, new_module))
- g_settings_set_string (priv->interface_settings,
- KEY_GTK_IM_MODULE,
- new_module);
- g_free (current_module);
-}
-
static gboolean
apply_input_sources_settings (GSettings *settings,
gpointer keys,
@@ -966,8 +987,8 @@ apply_input_sources_settings (GSettings *settings,
g_warning ("Couldn't find XKB input source '%s'", id);
goto exit;
}
- set_gtk_im_module (manager, GTK_IM_MODULE_SIMPLE);
#ifdef HAVE_IBUS
+ set_gtk_im_module (manager, sources);
set_ibus_xkb_engine (manager);
#endif
} else if (g_str_equal (type, INPUT_SOURCE_TYPE_IBUS)) {
@@ -993,7 +1014,9 @@ apply_input_sources_settings (GSettings *settings,
goto exit;
}
- set_gtk_im_module (manager, GTK_IM_MODULE_IBUS);
+ /* NULL here is a shortcut for "I already know I
+ need the IBus module". */
+ set_gtk_im_module (manager, NULL);
set_ibus_engine (manager, id);
#else
g_warning ("IBus input source type specified but IBus support was not compiled");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]