From: Marius Vlad Date: Mon, 17 Feb 2020 14:42:27 +0000 (+0200) Subject: protocol: Add agl-shell-desktop protocol X-Git-Tag: 9.99.1~76 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=a35a7f2e5cc20bd40ece91918e753c709e2ee10b;p=src%2Fagl-compositor.git protocol: Add agl-shell-desktop protocol Protocol intented for use by regular XDG application which want to tell the compositor to activate another application. This mimics the activate_app request from agl-shell, and assumes the application is already started. Bug-AGL: SPEC-3252 Signed-off-by: Marius Vlad Change-Id: I1f7bd1d8d2f7d8f1eedf710aef1bf1046846f9be --- diff --git a/meson.build b/meson.build index 37eb26a..aa69218 100644 --- a/meson.build +++ b/meson.build @@ -50,6 +50,7 @@ xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml') protocols = [ { 'name': 'agl-shell', 'source': 'internal' }, + { 'name': 'agl-shell-desktop', 'source': 'internal' }, { 'name': 'xdg-shell', 'source': 'wp-stable' }, ] @@ -122,7 +123,9 @@ srcs_agl_compositor = [ 'shared/option-parser.c', 'shared/os-compatibility.c', agl_shell_server_protocol_h, + agl_shell_desktop_server_protocol_h, agl_shell_protocol_c, + agl_shell_desktop_protocol_c, xdg_shell_protocol_c, ] diff --git a/protocol/agl-shell-desktop.xml b/protocol/agl-shell-desktop.xml new file mode 100644 index 0000000..076b4f2 --- /dev/null +++ b/protocol/agl-shell-desktop.xml @@ -0,0 +1,47 @@ + + + + Copyright © 2020 Collabora, Ltd. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + This extension can be used by regular application to instruct to compositor + to activate or switch to other running (regular) applications. The client + is responsbile for filtering their own app_id when receiving application id. + + Note that other (regular) applications can bind to this interface and there is + no mechanism to place to restrict or limit that. + + + + + Ask the compositor to make a toplevel to become the current/focused + window for window management purposes. + + See xdg_toplevel.set_app_id from the xdg-shell protocol for a + description of app_id. + + + + + + diff --git a/src/ivi-compositor.h b/src/ivi-compositor.h index a01c617..8631477 100644 --- a/src/ivi-compositor.h +++ b/src/ivi-compositor.h @@ -38,6 +38,11 @@ #define ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) +struct desktop_client { + struct wl_resource *resource; + struct wl_list link; /* ivi_compositor::desktop_clients */ +}; + struct ivi_compositor { struct weston_compositor *compositor; struct weston_config *config; @@ -62,6 +67,7 @@ struct ivi_compositor { const struct weston_drm_output_api *drm_api; struct wl_global *agl_shell; + struct wl_global *agl_shell_desktop; struct { int activate_apps_by_default; /* switches once xdg top level has been 'created' */ } quirks; @@ -72,6 +78,8 @@ struct ivi_compositor { bool ready; } shell_client; + struct wl_list desktop_clients; /* desktop_client::link */ + struct wl_list outputs; /* ivi_output.link */ struct wl_list surfaces; /* ivi_surface.link */ diff --git a/src/main.c b/src/main.c index e1ebab5..8c4b10b 100644 --- a/src/main.c +++ b/src/main.c @@ -1145,6 +1145,7 @@ int main(int argc, char *argv[]) wl_list_init(&ivi.outputs); wl_list_init(&ivi.surfaces); wl_list_init(&ivi.pending_surfaces); + wl_list_init(&ivi.desktop_clients); /* Prevent any clients we spawn getting our stdin */ os_fd_set_cloexec(STDIN_FILENO); diff --git a/src/shell.c b/src/shell.c index 0553f30..9100ad7 100644 --- a/src/shell.c +++ b/src/shell.c @@ -39,6 +39,7 @@ #include "shared/os-compatibility.h" #include "agl-shell-server-protocol.h" +#include "agl-shell-desktop-server-protocol.h" static void create_black_surface_view(struct ivi_output *output); @@ -439,6 +440,10 @@ static const struct agl_shell_interface agl_shell_implementation = { .activate_app = shell_activate_app, }; +static const struct agl_shell_desktop_interface agl_shell_desktop_implementation = { + .activate_app = shell_activate_app, +}; + static void unbind_agl_shell(struct wl_resource *resource) { @@ -526,6 +531,42 @@ bind_agl_shell(struct wl_client *client, ivi->shell_client.resource = resource; } +static void +unbind_agl_shell_desktop(struct wl_resource *resource) +{ + struct desktop_client *dclient = wl_resource_get_user_data(resource); + + wl_list_remove(&dclient->link); + free(dclient); +} + +static void +bind_agl_shell_desktop(struct wl_client *client, + void *data, uint32_t version, uint32_t id) +{ + struct ivi_compositor *ivi = data; + struct wl_resource *resource; + struct desktop_client *dclient = zalloc(sizeof(*dclient)); + + if (!dclient) { + wl_client_post_no_memory(client); + return; + } + + resource = wl_resource_create(client, &agl_shell_desktop_interface, + version, id); + if (!resource) { + wl_client_post_no_memory(client); + return; + } + + wl_resource_set_implementation(resource, &agl_shell_desktop_implementation, + dclient, unbind_agl_shell_desktop); + + dclient->resource = resource; + wl_list_insert(&ivi->desktop_clients, &dclient->link); +} + int ivi_shell_create_global(struct ivi_compositor *ivi) { @@ -537,5 +578,13 @@ ivi_shell_create_global(struct ivi_compositor *ivi) return -1; } + ivi->agl_shell_desktop = wl_global_create(ivi->compositor->wl_display, + &agl_shell_desktop_interface, 1, + ivi, bind_agl_shell_desktop); + if (!ivi->agl_shell_desktop) { + weston_log("Failed to create wayland global (agl_shell_desktop).\n"); + return -1; + } + return 0; }