forked from AuroraMiddleware/gtk
Rework the way IM contexts are set
Add a function to obtain the effective context id, and reset the slave only when the effective context id is different from the current context id, when setting a client window and on focus in. This might fix bug 593868 and bug 567124.
This commit is contained in:
parent
ea98cdc164
commit
1c0ecc0380
@ -685,11 +685,7 @@ _gtk_im_module_get_default_context_id (GdkWindow *client_window)
|
||||
if (GDK_IS_DRAWABLE (client_window))
|
||||
{
|
||||
screen = gdk_drawable_get_screen (GDK_DRAWABLE (client_window));
|
||||
if (screen)
|
||||
settings = gtk_settings_get_for_screen (screen);
|
||||
else
|
||||
settings = gtk_settings_get_default ();
|
||||
|
||||
g_object_get (G_OBJECT (settings), "gtk-im-module", &tmp, NULL);
|
||||
if (tmp)
|
||||
{
|
||||
|
@ -220,6 +220,18 @@ gtk_im_multicontext_set_slave (GtkIMMulticontext *multicontext,
|
||||
g_signal_emit_by_name (multicontext, "preedit-changed");
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
get_effective_context_id (GtkIMMulticontext *multicontext)
|
||||
{
|
||||
if (multicontext->priv->context_id)
|
||||
return multicontext->priv->context_id;
|
||||
|
||||
if (!global_context_id)
|
||||
global_context_id = _gtk_im_module_get_default_context_id (multicontext->priv->client_window);
|
||||
|
||||
return global_context_id;
|
||||
}
|
||||
|
||||
static GtkIMContext *
|
||||
gtk_im_multicontext_get_slave (GtkIMMulticontext *multicontext)
|
||||
{
|
||||
@ -229,14 +241,7 @@ gtk_im_multicontext_get_slave (GtkIMMulticontext *multicontext)
|
||||
|
||||
g_free (multicontext->context_id);
|
||||
|
||||
if (multicontext->priv->context_id)
|
||||
multicontext->context_id = g_strdup (multicontext->priv->context_id);
|
||||
else
|
||||
{
|
||||
if (!global_context_id)
|
||||
global_context_id = _gtk_im_module_get_default_context_id (multicontext->priv->client_window);
|
||||
multicontext->context_id = g_strdup (global_context_id);
|
||||
}
|
||||
multicontext->context_id = g_strdup (get_effective_context_id (multicontext));
|
||||
slave = _gtk_im_module_create (multicontext->context_id);
|
||||
gtk_im_multicontext_set_slave (multicontext, slave, FALSE);
|
||||
g_object_unref (slave);
|
||||
@ -264,16 +269,10 @@ gtk_im_multicontext_set_client_window (GtkIMContext *context,
|
||||
|
||||
multicontext->priv->client_window = window;
|
||||
|
||||
gtk_im_multicontext_set_slave (multicontext, NULL, FALSE);
|
||||
|
||||
if (window == NULL)
|
||||
return;
|
||||
|
||||
if (window)
|
||||
{
|
||||
screen = gdk_drawable_get_screen (GDK_DRAWABLE (window));
|
||||
if (screen)
|
||||
settings = gtk_settings_get_for_screen (screen);
|
||||
else
|
||||
settings = gtk_settings_get_default ();
|
||||
|
||||
connected = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (settings),
|
||||
"gtk-im-module-connected"));
|
||||
@ -288,6 +287,10 @@ gtk_im_multicontext_set_client_window (GtkIMContext *context,
|
||||
}
|
||||
}
|
||||
|
||||
if (g_strcmp0 (multicontext->context_id, get_effective_context_id (multicontext)) != 0)
|
||||
gtk_im_multicontext_set_slave (multicontext, NULL, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_im_multicontext_get_preedit_string (GtkIMContext *context,
|
||||
gchar **str,
|
||||
@ -327,16 +330,7 @@ gtk_im_multicontext_focus_in (GtkIMContext *context)
|
||||
GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT (context);
|
||||
GtkIMContext *slave;
|
||||
|
||||
/* If the global context type is different from the context we were
|
||||
* using before, get rid of the old slave and create a new one
|
||||
* for the new global context type.
|
||||
*/
|
||||
if (multicontext->context_id == NULL ||
|
||||
(multicontext->priv->context_id != NULL &&
|
||||
strcmp (multicontext->priv->context_id, multicontext->context_id) != 0) ||
|
||||
(multicontext->priv->context_id == NULL &&
|
||||
(global_context_id == NULL ||
|
||||
strcmp (global_context_id, multicontext->context_id) != 0)))
|
||||
if (g_strcmp0 (multicontext->context_id, get_effective_context_id (multicontext)) != 0)
|
||||
gtk_im_multicontext_set_slave (multicontext, NULL, FALSE);
|
||||
|
||||
slave = gtk_im_multicontext_get_slave (multicontext);
|
||||
|
Loading…
Reference in New Issue
Block a user