Only recreate the widget when the keyboard layout changes
Avoid creating a widget before there is a window to put it in.
This commit is contained in:
@ -75,6 +75,9 @@ on_destroy (GtkWidget *widget, gpointer user_data)
|
|||||||
eekboard_context_service_destroy (EEKBOARD_CONTEXT_SERVICE (context));
|
eekboard_context_service_destroy (EEKBOARD_CONTEXT_SERVICE (context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
make_widget (ServerContextService *context);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_notify_keyboard (GObject *object,
|
on_notify_keyboard (GObject *object,
|
||||||
GParamSpec *spec,
|
GParamSpec *spec,
|
||||||
@ -94,6 +97,9 @@ on_notify_keyboard (GObject *object,
|
|||||||
keyboard);
|
keyboard);
|
||||||
|
|
||||||
/* Recreate the keyboard widget to keep in sync with the keymap. */
|
/* Recreate the keyboard widget to keep in sync with the keymap. */
|
||||||
|
if (context->window)
|
||||||
|
make_widget(context);
|
||||||
|
|
||||||
gboolean visible;
|
gboolean visible;
|
||||||
g_object_get (context, "visible", &visible, NULL);
|
g_object_get (context, "visible", &visible, NULL);
|
||||||
|
|
||||||
@ -232,7 +238,11 @@ make_widget (ServerContextService *context)
|
|||||||
EekKeyboard *keyboard;
|
EekKeyboard *keyboard;
|
||||||
EekTheme *theme;
|
EekTheme *theme;
|
||||||
|
|
||||||
g_return_if_fail (!context->widget);
|
if (context->widget) {
|
||||||
|
gtk_widget_destroy(context->widget);
|
||||||
|
context->widget = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
theme = eek_theme_new ("resource:///sm/puri/squeekboard/style.css",
|
theme = eek_theme_new ("resource:///sm/puri/squeekboard/style.css",
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
@ -257,12 +267,8 @@ server_context_service_real_show_keyboard (EekboardContextService *_context)
|
|||||||
|
|
||||||
if (!context->window)
|
if (!context->window)
|
||||||
make_window (context);
|
make_window (context);
|
||||||
if (context->widget) {
|
if (!context->widget)
|
||||||
gtk_widget_destroy(context->widget);
|
make_widget (context);
|
||||||
context->widget = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
make_widget (context);
|
|
||||||
|
|
||||||
EEKBOARD_CONTEXT_SERVICE_CLASS (server_context_service_parent_class)->
|
EEKBOARD_CONTEXT_SERVICE_CLASS (server_context_service_parent_class)->
|
||||||
show_keyboard (_context);
|
show_keyboard (_context);
|
||||||
|
|||||||
Reference in New Issue
Block a user