diff --git a/eekboard/eekboard-context-service.c b/eekboard/eekboard-context-service.c index 36fd62bb..6e46f0f8 100644 --- a/eekboard/eekboard-context-service.c +++ b/eekboard/eekboard-context-service.c @@ -139,14 +139,8 @@ eekboard_context_service_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object); - + (void)value; switch (prop_id) { - case PROP_KEYBOARD: - if (context->priv->keyboard) - g_object_unref (context->priv->keyboard); - context->priv->keyboard = g_value_get_object (value); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -231,6 +225,11 @@ eekboard_context_service_update_layout(EekboardContextService *context, enum squ g_object_notify (G_OBJECT(context), "keyboard"); + // The keymap will get set even if the window is hidden. + // It's not perfect, + // but simpler than adding a check in the window showing procedure + eekboard_context_service_set_keymap(context, keyboard); + // replacing the keyboard above will cause the previous keyboard to get destroyed from the UI side (eek_gtk_keyboard_dispose) if (previous_keyboard) { level_keyboard_free(previous_keyboard); @@ -338,7 +337,7 @@ eekboard_context_service_class_init (EekboardContextServiceClass *klass) pspec = g_param_spec_pointer("keyboard", "Keyboard", "Keyboard", - G_PARAM_READWRITE); + G_PARAM_READABLE); g_object_class_install_property (gobject_class, PROP_KEYBOARD, pspec); diff --git a/src/server-context-service.c b/src/server-context-service.c index 16a1e7eb..1cacb37d 100644 --- a/src/server-context-service.c +++ b/src/server-context-service.c @@ -78,17 +78,6 @@ on_notify_keyboard (GObject *object, GParamSpec *spec, ServerContextService *context) { - const LevelKeyboard *keyboard = eekboard_context_service_get_keyboard (EEKBOARD_CONTEXT_SERVICE(context)); - - if (!keyboard) - g_error("Programmer error: keyboard layout was unset!"); - - // The keymap will get set even if the window is hidden. - // It's not perfect, - // but simpler than adding a check in the window showing procedure - eekboard_context_service_set_keymap(EEKBOARD_CONTEXT_SERVICE(context), - keyboard); - /* Recreate the keyboard widget to keep in sync with the keymap. */ if (context->window) make_widget(context);