diff options
Diffstat (limited to 'ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c')
-rw-r--r-- | ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c b/ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c index 82900dc..a3c0ea5 100644 --- a/ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c +++ b/ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c @@ -73,6 +73,8 @@ struct input_context { struct wl_listener surface_destroyed; struct wl_listener compositor_destroy_listener; struct wl_listener seat_create_listener; + + char *seat_default_name; }; enum kbd_events { @@ -997,12 +999,12 @@ handle_seat_create(struct wl_listener *listener, void *data) /* If default seat is created, we have to add it to the accepted_seat_list * of all surfaces. Also we have to send an acceptance event to all clients */ - if (!strcmp(ctx->west_seat->seat_name, "default")) { + if (!strcmp(ctx->west_seat->seat_name, input_ctx->seat_default_name)) { wl_list_for_each(surf, &input_ctx->ivishell->list_surface, link) { add_accepted_seat(surf, ctx); send_input_acceptance(input_ctx, interface->get_id_of_surface(surf->layout_surface), - "default", ILM_TRUE); + input_ctx->seat_default_name, ILM_TRUE); } } } @@ -1049,12 +1051,12 @@ handle_surface_create(struct wl_listener *listener, void *data) wl_list_init(&ivisurface->accepted_seat_list); - seat_ctx = input_ctrl_get_seat_ctx(input_ctx, "default"); + seat_ctx = input_ctrl_get_seat_ctx(input_ctx, input_ctx->seat_default_name); if (seat_ctx) { add_accepted_seat(ivisurface, seat_ctx); send_input_acceptance(input_ctx, interface->get_id_of_surface(ivisurface->layout_surface), - "default", ILM_TRUE); + input_ctx->seat_default_name, ILM_TRUE); } } @@ -1263,6 +1265,10 @@ destroy_input_context(struct input_context *ctx) * free up the controller structure*/ wl_resource_destroy(resource); } + + if (ctx->seat_default_name) { + free(ctx->seat_default_name); + } free(ctx); } @@ -1304,6 +1310,36 @@ input_controller_destroy(struct wl_listener *listener, void *data) } } +static int +get_config( struct input_context *ctx) +{ + int ret = 0; + struct weston_config *config = NULL; + struct weston_config_section *section = NULL; + ctx->seat_default_name = NULL; + + config = wet_get_config(ctx->ivishell->compositor); + if (!config) + goto exit; + + section = weston_config_get_section(config, "ivi-shell", NULL, NULL); + if (!section) + goto exit; + + weston_config_section_get_string(section, + "default-seat", + &ctx->seat_default_name, "default"); +exit: + if (!ctx->seat_default_name) { + ctx->seat_default_name = strdup("default"); + if (!ctx->seat_default_name) { + weston_log("%s: Failed to allocate memory for seat default name\n", __FUNCTION__); + ret = -1; + } + } + + return ret; +} static struct input_context * create_input_context(struct ivishell *shell) @@ -1321,6 +1357,12 @@ create_input_context(struct ivishell *shell) wl_list_init(&ctx->resource_list); wl_list_init(&ctx->seat_list); + /* get the default seat*/ + if (get_config(ctx) != 0) { + free(ctx); + return NULL; + } + /* Add signal handlers for ivi surfaces. */ ctx->surface_created.notify = handle_surface_create; ctx->surface_destroyed.notify = handle_surface_destroy; @@ -1341,7 +1383,6 @@ create_input_context(struct ivishell *shell) return ctx; } - static int input_controller_init(struct ivishell *shell) { |