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));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
make_widget (ServerContextService *context);
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
on_notify_keyboard (GObject              *object,
 | 
			
		||||
                    GParamSpec           *spec,
 | 
			
		||||
@ -94,6 +97,9 @@ on_notify_keyboard (GObject              *object,
 | 
			
		||||
                                        keyboard);
 | 
			
		||||
 | 
			
		||||
    /* Recreate the keyboard widget to keep in sync with the keymap. */
 | 
			
		||||
    if (context->window)
 | 
			
		||||
        make_widget(context);
 | 
			
		||||
 | 
			
		||||
    gboolean visible;
 | 
			
		||||
    g_object_get (context, "visible", &visible, NULL);
 | 
			
		||||
 | 
			
		||||
@ -232,7 +238,11 @@ make_widget (ServerContextService *context)
 | 
			
		||||
    EekKeyboard *keyboard;
 | 
			
		||||
    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",
 | 
			
		||||
                           NULL,
 | 
			
		||||
                           NULL);
 | 
			
		||||
@ -257,12 +267,8 @@ server_context_service_real_show_keyboard (EekboardContextService *_context)
 | 
			
		||||
 | 
			
		||||
    if (!context->window)
 | 
			
		||||
        make_window (context);
 | 
			
		||||
    if (context->widget) {
 | 
			
		||||
        gtk_widget_destroy(context->widget);
 | 
			
		||||
        context->widget = NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    make_widget (context);
 | 
			
		||||
    if (!context->widget)
 | 
			
		||||
        make_widget (context);
 | 
			
		||||
 | 
			
		||||
    EEKBOARD_CONTEXT_SERVICE_CLASS (server_context_service_parent_class)->
 | 
			
		||||
        show_keyboard (_context);
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user