forked from AuroraMiddleware/gtk
immulticontext: Don't have a global_context_id
Context IDs are dependant on the display - both because displays can use different backends, but also because changing the GtkSetting is a per-display operation. So just remove the cache. If it turns out we need a per-display cache, we can add one to GtkSettings.
This commit is contained in:
parent
58e273d056
commit
16d4ce4d03
@ -102,8 +102,6 @@ static gboolean gtk_im_multicontext_delete_surrounding_cb (GtkIMContext *
|
|||||||
|
|
||||||
static void propagate_purpose (GtkIMMulticontext *context);
|
static void propagate_purpose (GtkIMMulticontext *context);
|
||||||
|
|
||||||
static const gchar *global_context_id = NULL;
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkIMMulticontext, gtk_im_multicontext, GTK_TYPE_IM_CONTEXT)
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkIMMulticontext, gtk_im_multicontext, GTK_TYPE_IM_CONTEXT)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -250,10 +248,7 @@ get_effective_context_id (GtkIMMulticontext *multicontext)
|
|||||||
if (priv->context_id_aux)
|
if (priv->context_id_aux)
|
||||||
return priv->context_id_aux;
|
return priv->context_id_aux;
|
||||||
|
|
||||||
if (!global_context_id)
|
return _gtk_im_module_get_default_context_id ();
|
||||||
global_context_id = _gtk_im_module_get_default_context_id ();
|
|
||||||
|
|
||||||
return global_context_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkIMContext *
|
static GtkIMContext *
|
||||||
@ -261,9 +256,6 @@ gtk_im_multicontext_get_slave (GtkIMMulticontext *multicontext)
|
|||||||
{
|
{
|
||||||
GtkIMMulticontextPrivate *priv = multicontext->priv;
|
GtkIMMulticontextPrivate *priv = multicontext->priv;
|
||||||
|
|
||||||
if (g_strcmp0 (priv->context_id, get_effective_context_id (multicontext)) != 0)
|
|
||||||
gtk_im_multicontext_set_slave (multicontext, NULL, FALSE);
|
|
||||||
|
|
||||||
if (!priv->slave)
|
if (!priv->slave)
|
||||||
{
|
{
|
||||||
GtkIMContext *slave;
|
GtkIMContext *slave;
|
||||||
@ -284,22 +276,29 @@ gtk_im_multicontext_get_slave (GtkIMMulticontext *multicontext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
im_module_setting_changed (GtkSettings *settings,
|
im_module_setting_changed (GtkSettings *settings,
|
||||||
gpointer data)
|
GtkIMMulticontext *self)
|
||||||
{
|
{
|
||||||
global_context_id = NULL;
|
gtk_im_multicontext_set_slave (self, NULL, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_im_multicontext_set_client_widget (GtkIMContext *context,
|
gtk_im_multicontext_set_client_widget (GtkIMContext *context,
|
||||||
GtkWidget *widget)
|
GtkWidget *widget)
|
||||||
{
|
{
|
||||||
GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT (context);
|
GtkIMMulticontext *self = GTK_IM_MULTICONTEXT (context);
|
||||||
GtkIMMulticontextPrivate *priv = multicontext->priv;
|
GtkIMMulticontextPrivate *priv = self->priv;
|
||||||
GtkIMContext *slave;
|
GtkIMContext *slave;
|
||||||
GtkSettings *settings;
|
GtkSettings *settings;
|
||||||
gboolean connected;
|
|
||||||
|
if (priv->client_widget != NULL)
|
||||||
|
{
|
||||||
|
settings = gtk_widget_get_settings (priv->client_widget);
|
||||||
|
|
||||||
|
g_signal_handlers_disconnect_by_func (settings,
|
||||||
|
im_module_setting_changed,
|
||||||
|
self);
|
||||||
|
}
|
||||||
|
|
||||||
priv->client_widget = widget;
|
priv->client_widget = widget;
|
||||||
|
|
||||||
@ -307,20 +306,12 @@ gtk_im_multicontext_set_client_widget (GtkIMContext *context,
|
|||||||
{
|
{
|
||||||
settings = gtk_widget_get_settings (widget);
|
settings = gtk_widget_get_settings (widget);
|
||||||
|
|
||||||
connected = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (settings),
|
g_signal_connect (settings, "notify::gtk-im-module",
|
||||||
"gtk-im-module-connected"));
|
G_CALLBACK (im_module_setting_changed),
|
||||||
if (!connected)
|
self);
|
||||||
{
|
|
||||||
g_signal_connect (settings, "notify::gtk-im-module",
|
|
||||||
G_CALLBACK (im_module_setting_changed), NULL);
|
|
||||||
g_object_set_data (G_OBJECT (settings), "gtk-im-module-connected",
|
|
||||||
GINT_TO_POINTER (TRUE));
|
|
||||||
|
|
||||||
global_context_id = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
slave = gtk_im_multicontext_get_slave (multicontext);
|
slave = gtk_im_multicontext_get_slave (self);
|
||||||
if (slave)
|
if (slave)
|
||||||
gtk_im_context_set_client_widget (slave, widget);
|
gtk_im_context_set_client_widget (slave, widget);
|
||||||
}
|
}
|
||||||
@ -559,9 +550,14 @@ gtk_im_multicontext_delete_surrounding_cb (GtkIMContext *slave,
|
|||||||
const char *
|
const char *
|
||||||
gtk_im_multicontext_get_context_id (GtkIMMulticontext *context)
|
gtk_im_multicontext_get_context_id (GtkIMMulticontext *context)
|
||||||
{
|
{
|
||||||
|
GtkIMMulticontextPrivate *priv = context->priv;
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_IM_MULTICONTEXT (context), NULL);
|
g_return_val_if_fail (GTK_IS_IM_MULTICONTEXT (context), NULL);
|
||||||
|
|
||||||
return context->priv->context_id;
|
if (priv->context_id == NULL)
|
||||||
|
gtk_im_multicontext_get_slave (context);
|
||||||
|
|
||||||
|
return priv->context_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user