X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fshell.c;h=aaf04688a7e1d00fb17586b8c3fcac660e9a5e35;hb=0b766cf978b8b100caecd4c61464e1a683685072;hp=ad62a27ff23756a1a392df5683174e11049a93e8;hpb=14a1292a393774727fb85662d98d8cbe4bc6e5cd;p=src%2Fagl-compositor.git diff --git a/src/shell.c b/src/shell.c index ad62a27..aaf0468 100644 --- a/src/shell.c +++ b/src/shell.c @@ -996,17 +996,16 @@ process_handle_sigchld(struct weston_process *process, int status) } int -ivi_launch_shell_client(struct ivi_compositor *ivi) +ivi_launch_shell_client(struct ivi_compositor *ivi, const char *cmd_section, + struct wl_client **client) { struct process_info *pinfo; struct weston_config_section *section; char *command = NULL; - section = weston_config_get_section(ivi->config, "shell-client", - NULL, NULL); + section = weston_config_get_section(ivi->config, cmd_section, NULL, NULL); if (section) - weston_config_section_get_string(section, "command", - &command, NULL); + weston_config_section_get_string(section, "command", &command, NULL); if (!command) return -1; @@ -1019,9 +1018,8 @@ ivi_launch_shell_client(struct ivi_compositor *ivi) if (!pinfo->path) goto out_free; - ivi->shell_client.client = client_launch(ivi->compositor, &pinfo->proc, - command, process_handle_sigchld); - if (!ivi->shell_client.client) + *client = client_launch(ivi->compositor, &pinfo->proc, command, process_handle_sigchld); + if (!*client) goto out_str; return 0; @@ -1150,6 +1148,22 @@ insert_black_curtain(struct ivi_output *output) weston_log("Added black curtain to output %s\n", output->output->name); } +void +shell_send_app_state(struct ivi_compositor *ivi, const char *app_id, + enum agl_shell_app_state state) +{ + if (app_id && wl_resource_get_version(ivi->shell_client.resource) >= + AGL_SHELL_APP_STATE_SINCE_VERSION) { + + agl_shell_send_app_state(ivi->shell_client.resource, + app_id, state); + + if (ivi->shell_client.resource_ext) + agl_shell_send_app_state(ivi->shell_client.resource_ext, + app_id, state); + } +} + static void shell_ready(struct wl_client *client, struct wl_resource *shell_res) { @@ -1157,8 +1171,7 @@ shell_ready(struct wl_client *client, struct wl_resource *shell_res) struct ivi_output *output; struct ivi_surface *surface, *tmp; - if (ivi->shell_client.resource && - ivi->shell_client.status == BOUND_FAILED) { + if (ivi->shell_client.status == BOUND_FAILED) { wl_resource_post_error(shell_res, WL_DISPLAY_ERROR_INVALID_OBJECT, "agl_shell has already been bound. " @@ -1194,11 +1207,7 @@ shell_ready(struct wl_client *client, struct wl_resource *shell_res) surface->checked_pending = true; app_id = weston_desktop_surface_get_app_id(surface->dsurface); - if (app_id && - wl_resource_get_version(ivi->shell_client.resource) >= - AGL_SHELL_APP_STATE_SINCE_VERSION) - agl_shell_send_app_state(ivi->shell_client.resource, - app_id, AGL_SHELL_APP_STATE_STARTED); + shell_send_app_state(ivi, app_id, AGL_SHELL_APP_STATE_STARTED); } } @@ -1216,8 +1225,7 @@ shell_set_background(struct wl_client *client, struct weston_desktop_surface *dsurface; struct ivi_surface *surface; - if ((ivi->shell_client.resource && - ivi->shell_client.status == BOUND_FAILED) || + if (ivi->shell_client.status == BOUND_FAILED || ivi->shell_client.resource_ext == shell_res) { wl_resource_post_error(shell_res, WL_DISPLAY_ERROR_INVALID_OBJECT, @@ -1280,8 +1288,7 @@ shell_set_panel(struct wl_client *client, struct ivi_surface **member; int32_t width = 0, height = 0; - if ((ivi->shell_client.resource && - ivi->shell_client.status == BOUND_FAILED) || + if (ivi->shell_client.status == BOUND_FAILED || ivi->shell_client.resource_ext == shell_res) { wl_resource_post_error(shell_res, WL_DISPLAY_ERROR_INVALID_OBJECT, @@ -1398,8 +1405,7 @@ shell_activate_app(struct wl_client *client, struct ivi_compositor *ivi = wl_resource_get_user_data(shell_res); struct ivi_output *output = to_ivi_output(woutput); - if (ivi->shell_client.resource && - ivi->shell_client.status == BOUND_FAILED) { + if (ivi->shell_client.status == BOUND_FAILED) { wl_resource_post_error(shell_res, WL_DISPLAY_ERROR_INVALID_OBJECT, "agl_shell has already been bound. " @@ -1438,10 +1444,14 @@ shell_deactivate_app(struct wl_client *client, NULL, AGL_SHELL_DESKTOP_APP_STATE_DEACTIVATED); } -/* stub, no usage for the time being */ static void shell_destroy(struct wl_client *client, struct wl_resource *res) { + struct ivi_compositor *ivi = wl_resource_get_user_data(res); + + /* reset status in case bind_fail was sent */ + if (ivi->shell_client.status == BOUND_FAILED) + ivi->shell_client.status = BOUND_OK; } static void @@ -1581,8 +1591,7 @@ unbind_agl_shell(struct wl_resource *resource) ivi = wl_resource_get_user_data(resource); /* reset status to allow other clients issue legit requests */ - if (ivi->shell_client.resource && - ivi->shell_client.status == BOUND_FAILED) { + if (ivi->shell_client.status == BOUND_FAILED) { ivi->shell_client.status = BOUND_OK; return; } @@ -1660,31 +1669,40 @@ bind_agl_shell(struct wl_client *client, if (ivi->shell_client_ext.resource && ivi->shell_client_ext.doas_requested) { + /* reset status in case client-ext doesn't send an + * explicit agl_shell_destroy request, see + * shell_destroy() */ + if (ivi->shell_client.status == BOUND_FAILED) + ivi->shell_client.status = BOUND_OK; + wl_resource_set_implementation(resource, &agl_shell_implementation, ivi, NULL); - ivi->shell_client_ext.resource = resource; + ivi->shell_client.resource_ext = resource; - if (ivi->shell_client.status == BOUND_OK && - wl_resource_get_version(resource) >= AGL_SHELL_BOUND_OK_SINCE_VERSION) { - weston_log("Sent agl_shell_send_bound_ok to client ext\n"); - ivi->shell_client_ext.status = BOUND_OK; - agl_shell_send_bound_ok(ivi->shell_client_ext.resource); - } + ivi->shell_client_ext.status = BOUND_OK; + agl_shell_send_bound_ok(ivi->shell_client.resource_ext); return; } else { + wl_resource_set_implementation(resource, &agl_shell_implementation, + ivi, NULL); agl_shell_send_bound_fail(resource); ivi->shell_client.status = BOUND_FAILED; + return; } } - wl_resource_set_implementation(resource, &agl_shell_implementation, - ivi, unbind_agl_shell); - ivi->shell_client.resource = resource; - if (ivi->shell_client.status == BOUND_OK && - wl_resource_get_version(resource) >= AGL_SHELL_BOUND_OK_SINCE_VERSION) + if (wl_resource_get_version(resource) >= + AGL_SHELL_BOUND_OK_SINCE_VERSION) { + wl_resource_set_implementation(resource, &agl_shell_implementation, + ivi, unbind_agl_shell); + ivi->shell_client.resource = resource; + /* if we land here we'll have BOUND_OK by default, + but still do the assignment */ + ivi->shell_client.status = BOUND_OK; agl_shell_send_bound_ok(ivi->shell_client.resource); + } } static void