2 * Copyright © 2019 Collabora, Ltd.
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 #include "ivi-compositor.h"
34 #include <sys/socket.h>
35 #include <sys/types.h>
37 #include <libweston/libweston.h>
38 #include <libweston/config-parser.h>
40 #include "shared/os-compatibility.h"
42 #include "agl-shell-server-protocol.h"
43 #include "agl-shell-desktop-server-protocol.h"
46 create_black_surface_view(struct ivi_output *output);
49 insert_black_surface(struct ivi_output *output);
52 ivi_set_desktop_surface(struct ivi_surface *surface)
54 struct desktop_client *dclient;
55 struct ivi_compositor *ivi = surface->ivi;
56 assert(surface->role == IVI_SURFACE_ROLE_NONE);
58 surface->role = IVI_SURFACE_ROLE_DESKTOP;
59 wl_list_insert(&surface->ivi->surfaces, &surface->link);
61 /* advertise to all desktop clients the new surface */
62 wl_list_for_each(dclient, &ivi->desktop_clients, link) {
64 weston_desktop_surface_get_app_id(surface->dsurface);
65 agl_shell_desktop_send_application(dclient->resource, app_id);
70 ivi_set_desktop_surface_popup(struct ivi_surface *surface)
72 struct ivi_compositor *ivi = surface->ivi;
73 assert(surface->role == IVI_SURFACE_ROLE_NONE);
75 surface->role = IVI_SURFACE_ROLE_POPUP;
76 wl_list_insert(&ivi->surfaces, &surface->link);
80 ivi_set_desktop_surface_fullscreen(struct ivi_surface *surface)
82 struct ivi_compositor *ivi = surface->ivi;
83 assert(surface->role == IVI_SURFACE_ROLE_NONE);
85 surface->role = IVI_SURFACE_ROLE_FULLSCREEN;
86 wl_list_insert(&ivi->surfaces, &surface->link);
90 ivi_set_desktop_surface_split(struct ivi_surface *surface)
92 struct ivi_compositor *ivi = surface->ivi;
93 assert(surface->role == IVI_SURFACE_ROLE_NONE);
95 if (surface->split.orientation == AGL_SHELL_DESKTOP_APP_ROLE_SPLIT_VERTICAL)
96 surface->role = IVI_SURFACE_ROLE_SPLIT_V;
98 surface->role = IVI_SURFACE_ROLE_SPLIT_H;
100 wl_list_insert(&ivi->surfaces, &surface->link);
104 ivi_set_pending_desktop_surface_popup(struct ivi_output *ioutput,
105 int x, int y, const char *app_id)
107 struct ivi_compositor *ivi = ioutput->ivi;
108 size_t len_app_id = strlen(app_id);
110 struct pending_popup *p_popup = zalloc(sizeof(*p_popup));
112 p_popup->app_id = zalloc(sizeof(char) * (len_app_id + 1));
113 memcpy(p_popup->app_id, app_id, len_app_id);
114 p_popup->ioutput = ioutput;
118 wl_list_insert(&ivi->popup_pending_apps, &p_popup->link);
122 ivi_set_pending_desktop_surface_fullscreen(struct ivi_output *ioutput,
125 struct ivi_compositor *ivi = ioutput->ivi;
126 size_t len_app_id = strlen(app_id);
128 struct pending_fullscreen *fs = zalloc(sizeof(*fs));
130 fs->app_id = zalloc(sizeof(char) * (len_app_id + 1));
131 memcpy(fs->app_id, app_id, len_app_id);
133 fs->ioutput = ioutput;
135 wl_list_insert(&ivi->fullscreen_pending_apps, &fs->link);
139 ivi_set_pending_desktop_surface_split(struct ivi_output *ioutput,
140 const char *app_id, uint32_t orientation)
142 struct ivi_compositor *ivi = ioutput->ivi;
143 size_t len_app_id = strlen(app_id);
145 if (orientation != AGL_SHELL_DESKTOP_APP_ROLE_SPLIT_VERTICAL &&
146 orientation != AGL_SHELL_DESKTOP_APP_ROLE_SPLIT_HORIZONTAL)
149 struct pending_split *split = zalloc(sizeof(*split));
151 split->app_id = zalloc(sizeof(char) * (len_app_id + 1));
152 memcpy(split->app_id, app_id, len_app_id);
154 split->ioutput = ioutput;
155 split->orientation = orientation;
157 wl_list_insert(&ivi->split_pending_apps, &split->link);
161 ivi_remove_pending_desktop_surface_split(struct pending_split *split)
164 wl_list_remove(&split->link);
169 ivi_remove_pending_desktop_surface_fullscreen(struct pending_fullscreen *fs)
172 wl_list_remove(&fs->link);
177 ivi_remove_pending_desktop_surface_popup(struct pending_popup *p_popup)
179 free(p_popup->app_id);
180 wl_list_remove(&p_popup->link);
185 ivi_check_pending_desktop_surface_popup(struct ivi_surface *surface)
187 struct ivi_compositor *ivi = surface->ivi;
188 struct pending_popup *p_popup, *next_p_popup;
189 const char *_app_id =
190 weston_desktop_surface_get_app_id(surface->dsurface);
192 if (wl_list_empty(&ivi->popup_pending_apps))
195 wl_list_for_each_safe(p_popup, next_p_popup,
196 &ivi->popup_pending_apps, link) {
197 if (!strcmp(_app_id, p_popup->app_id)) {
198 surface->popup.output = p_popup->ioutput;
199 surface->popup.x = p_popup->x;
200 surface->popup.y = p_popup->y;
201 ivi_remove_pending_desktop_surface_popup(p_popup);
210 ivi_check_pending_desktop_surface_split(struct ivi_surface *surface)
212 struct pending_split *split_surf, *next_split_surf;
213 struct ivi_compositor *ivi = surface->ivi;
214 const char *_app_id =
215 weston_desktop_surface_get_app_id(surface->dsurface);
217 if (wl_list_empty(&ivi->split_pending_apps))
220 wl_list_for_each_safe(split_surf, next_split_surf,
221 &ivi->split_pending_apps, link) {
222 if (!strcmp(_app_id, split_surf->app_id)) {
223 surface->split.output = split_surf->ioutput;
224 surface->split.orientation = split_surf->orientation;
225 ivi_remove_pending_desktop_surface_split(split_surf);
234 ivi_check_pending_desktop_surface_fullscreen(struct ivi_surface *surface)
236 struct pending_fullscreen *fs_surf, *next_fs_surf;
237 struct ivi_compositor *ivi = surface->ivi;
238 const char *_app_id =
239 weston_desktop_surface_get_app_id(surface->dsurface);
241 if (wl_list_empty(&ivi->fullscreen_pending_apps))
244 wl_list_for_each_safe(fs_surf, next_fs_surf,
245 &ivi->fullscreen_pending_apps, link) {
246 if (!strcmp(_app_id, fs_surf->app_id)) {
247 surface->fullscreen.output = fs_surf->ioutput;
248 ivi_remove_pending_desktop_surface_fullscreen(fs_surf);
257 ivi_check_pending_desktop_surface(struct ivi_surface *surface)
261 ret = ivi_check_pending_desktop_surface_popup(surface);
263 ivi_set_desktop_surface_popup(surface);
267 ret = ivi_check_pending_desktop_surface_split(surface);
269 ivi_set_desktop_surface_split(surface);
273 ret = ivi_check_pending_desktop_surface_fullscreen(surface);
275 ivi_set_desktop_surface_fullscreen(surface);
279 /* if we end up here means we have a regular desktop app and
280 * try to activate it */
281 ivi_set_desktop_surface(surface);
282 ivi_layout_desktop_committed(surface);
286 ivi_shell_init_black_fs(struct ivi_compositor *ivi)
288 struct ivi_output *out;
290 wl_list_for_each(out, &ivi->outputs, link) {
291 create_black_surface_view(out);
292 insert_black_surface(out);
297 ivi_shell_init(struct ivi_compositor *ivi)
299 weston_layer_init(&ivi->hidden, ivi->compositor);
300 weston_layer_init(&ivi->background, ivi->compositor);
301 weston_layer_init(&ivi->normal, ivi->compositor);
302 weston_layer_init(&ivi->panel, ivi->compositor);
303 weston_layer_init(&ivi->popup, ivi->compositor);
304 weston_layer_init(&ivi->fullscreen, ivi->compositor);
306 weston_layer_set_position(&ivi->hidden,
307 WESTON_LAYER_POSITION_HIDDEN);
308 weston_layer_set_position(&ivi->background,
309 WESTON_LAYER_POSITION_BACKGROUND);
310 weston_layer_set_position(&ivi->normal,
311 WESTON_LAYER_POSITION_NORMAL);
312 weston_layer_set_position(&ivi->panel,
313 WESTON_LAYER_POSITION_UI);
314 weston_layer_set_position(&ivi->popup,
315 WESTON_LAYER_POSITION_TOP_UI);
316 weston_layer_set_position(&ivi->fullscreen,
317 WESTON_LAYER_POSITION_FULLSCREEN);
323 ivi_shell_advertise_xdg_surfaces(struct ivi_compositor *ivi, struct wl_resource *resource)
325 struct ivi_surface *surface;
327 wl_list_for_each(surface, &ivi->surfaces, link) {
329 weston_desktop_surface_get_app_id(surface->dsurface);
330 agl_shell_desktop_send_application(resource, app_id);
335 client_exec(const char *command, int fd)
340 /* Don't give the child our signal mask */
342 sigprocmask(SIG_UNBLOCK, &sig, NULL);
344 /* Launch clients as the user; don't give them the wrong euid */
345 if (seteuid(getuid()) == -1) {
346 weston_log("seteuid failed: %s\n", strerror(errno));
350 /* Duplicate fd to unset the CLOEXEC flag. We don't need to worry about
351 * clobbering fd, as we'll exit/exec either way.
355 weston_log("dup failed: %s\n", strerror(errno));
359 snprintf(s, sizeof s, "%d", fd);
360 setenv("WAYLAND_SOCKET", s, 1);
362 execl("/bin/sh", "/bin/sh", "-c", command, NULL);
363 weston_log("executing '%s' failed: %s", command, strerror(errno));
366 static struct wl_client *
367 launch_shell_client(struct ivi_compositor *ivi, const char *command)
369 struct wl_client *client;
373 weston_log("launching' %s'\n", command);
375 if (os_socketpair_cloexec(AF_UNIX, SOCK_STREAM, 0, sock) < 0) {
376 weston_log("socketpair failed while launching '%s': %s\n",
377 command, strerror(errno));
385 weston_log("fork failed while launching '%s': %s\n",
386 command, strerror(errno));
391 client_exec(command, sock[1]);
396 client = wl_client_create(ivi->compositor->wl_display, sock[0]);
399 weston_log("Failed to create wayland client for '%s'",
408 ivi_launch_shell_client(struct ivi_compositor *ivi)
410 struct weston_config_section *section;
411 char *command = NULL;
413 section = weston_config_get_section(ivi->config, "shell-client",
416 weston_config_section_get_string(section, "command",
422 ivi->shell_client.client = launch_shell_client(ivi, command);
423 if (!ivi->shell_client.client)
430 destroy_black_view(struct wl_listener *listener, void *data)
432 struct fullscreen_view *fs =
433 wl_container_of(listener, fs, fs_destroy);
437 if (fs->fs->view && fs->fs->view->surface) {
438 weston_surface_destroy(fs->fs->view->surface);
443 wl_list_remove(&fs->fs_destroy.link);
449 create_black_surface_view(struct ivi_output *output)
451 struct weston_surface *surface = NULL;
452 struct weston_view *view;
453 struct ivi_compositor *ivi = output->ivi;
454 struct weston_compositor *wc= ivi->compositor;
455 struct weston_output *woutput = output->output;
457 surface = weston_surface_create(wc);
458 view = weston_view_create(surface);
460 assert(view || surface);
462 weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1);
463 weston_surface_set_size(surface, woutput->width, woutput->height);
464 weston_view_set_position(view, woutput->x, woutput->y);
466 output->fullscreen_view.fs = zalloc(sizeof(struct ivi_surface));
467 output->fullscreen_view.fs->view = view;
469 output->fullscreen_view.fs_destroy.notify = destroy_black_view;
470 wl_signal_add(&woutput->destroy_signal,
471 &output->fullscreen_view.fs_destroy);
475 remove_black_surface(struct ivi_output *output)
477 struct weston_view *view = output->fullscreen_view.fs->view;
479 assert(view->is_mapped == true ||
480 view->surface->is_mapped == true);
482 view->is_mapped = false;
483 view->surface->is_mapped = false;
485 weston_layer_entry_remove(&view->layer_link);
486 weston_view_update_transform(view);
488 weston_output_damage(output->output);
492 insert_black_surface(struct ivi_output *output)
494 struct weston_view *view = output->fullscreen_view.fs->view;
496 if (view->is_mapped || view->surface->is_mapped)
499 weston_layer_entry_remove(&view->layer_link);
500 weston_layer_entry_insert(&output->ivi->fullscreen.view_list,
503 view->is_mapped = true;
504 view->surface->is_mapped = true;
506 weston_view_update_transform(view);
507 weston_output_damage(output->output);
511 shell_ready(struct wl_client *client, struct wl_resource *shell_res)
513 struct ivi_compositor *ivi = wl_resource_get_user_data(shell_res);
514 struct ivi_output *output;
515 struct ivi_surface *surface, *tmp;
517 /* Init already finished. Do nothing */
518 if (ivi->shell_client.ready)
521 ivi->shell_client.ready = true;
523 wl_list_for_each(output, &ivi->outputs, link) {
524 remove_black_surface(output);
525 ivi_layout_init(ivi, output);
528 wl_list_for_each_safe(surface, tmp, &ivi->pending_surfaces, link) {
529 wl_list_remove(&surface->link);
530 ivi_check_pending_desktop_surface(surface);
535 shell_set_background(struct wl_client *client,
536 struct wl_resource *shell_res,
537 struct wl_resource *surface_res,
538 struct wl_resource *output_res)
540 struct weston_head *head = weston_head_from_resource(output_res);
541 struct weston_output *woutput = weston_head_get_output(head);
542 struct ivi_output *output = to_ivi_output(woutput);
543 struct weston_surface *wsurface = wl_resource_get_user_data(surface_res);
544 struct weston_desktop_surface *dsurface;
545 struct ivi_surface *surface;
547 dsurface = weston_surface_get_desktop_surface(wsurface);
549 wl_resource_post_error(shell_res,
550 AGL_SHELL_ERROR_INVALID_ARGUMENT,
551 "surface must be a desktop surface");
555 surface = weston_desktop_surface_get_user_data(dsurface);
556 if (surface->role != IVI_SURFACE_ROLE_NONE) {
557 wl_resource_post_error(shell_res,
558 AGL_SHELL_ERROR_INVALID_ARGUMENT,
559 "surface already has another ivi role");
563 if (output->background) {
564 wl_resource_post_error(shell_res,
565 AGL_SHELL_ERROR_BACKGROUND_EXISTS,
566 "output already has background");
570 surface->role = IVI_SURFACE_ROLE_BACKGROUND;
571 surface->bg.output = output;
572 wl_list_remove(&surface->link);
573 wl_list_init(&surface->link);
575 output->background = surface;
577 weston_desktop_surface_set_maximized(dsurface, true);
578 weston_desktop_surface_set_size(dsurface,
579 output->output->width,
580 output->output->height);
584 shell_set_panel(struct wl_client *client,
585 struct wl_resource *shell_res,
586 struct wl_resource *surface_res,
587 struct wl_resource *output_res,
590 struct weston_head *head = weston_head_from_resource(output_res);
591 struct weston_output *woutput = weston_head_get_output(head);
592 struct ivi_output *output = to_ivi_output(woutput);
593 struct weston_surface *wsurface = wl_resource_get_user_data(surface_res);
594 struct weston_desktop_surface *dsurface;
595 struct ivi_surface *surface;
596 struct ivi_surface **member;
597 int32_t width = 0, height = 0;
599 dsurface = weston_surface_get_desktop_surface(wsurface);
601 wl_resource_post_error(shell_res,
602 AGL_SHELL_ERROR_INVALID_ARGUMENT,
603 "surface must be a desktop surface");
607 surface = weston_desktop_surface_get_user_data(dsurface);
608 if (surface->role != IVI_SURFACE_ROLE_NONE) {
609 wl_resource_post_error(shell_res,
610 AGL_SHELL_ERROR_INVALID_ARGUMENT,
611 "surface already has another ivi role");
616 case AGL_SHELL_EDGE_TOP:
617 member = &output->top;
619 case AGL_SHELL_EDGE_BOTTOM:
620 member = &output->bottom;
622 case AGL_SHELL_EDGE_LEFT:
623 member = &output->left;
625 case AGL_SHELL_EDGE_RIGHT:
626 member = &output->right;
629 wl_resource_post_error(shell_res,
630 AGL_SHELL_ERROR_INVALID_ARGUMENT,
631 "invalid edge for panel");
636 wl_resource_post_error(shell_res,
637 AGL_SHELL_ERROR_BACKGROUND_EXISTS,
638 "output already has panel on this edge");
642 surface->role = IVI_SURFACE_ROLE_PANEL;
643 surface->panel.output = output;
644 surface->panel.edge = edge;
645 wl_list_remove(&surface->link);
646 wl_list_init(&surface->link);
650 switch (surface->panel.edge) {
651 case AGL_SHELL_EDGE_TOP:
652 case AGL_SHELL_EDGE_BOTTOM:
653 width = woutput->width;
655 case AGL_SHELL_EDGE_LEFT:
656 case AGL_SHELL_EDGE_RIGHT:
657 height = woutput->height;
661 weston_desktop_surface_set_size(dsurface, width, height);
666 shell_advertise_app_state(struct ivi_compositor *ivi, const char *app_id,
667 const char *data, uint32_t app_state)
669 struct desktop_client *dclient;
671 struct ivi_surface *surf = ivi_find_app(ivi, app_id);
672 struct ivi_policy *policy = ivi->policy;
674 /* FIXME: should queue it here and see when binding agl-shell-desktop
675 * if there are any to be sent */
679 if (policy && policy->api.surface_advertise_state_change &&
680 !policy->api.surface_advertise_state_change(surf, surf->ivi)) {
684 app_role = surf->role;
685 if (app_role == IVI_SURFACE_ROLE_POPUP)
686 app_role = AGL_SHELL_DESKTOP_APP_ROLE_POPUP;
688 wl_list_for_each(dclient, &ivi->desktop_clients, link)
689 agl_shell_desktop_send_state_app(dclient->resource, app_id,
690 data, app_state, app_role);
694 shell_activate_app(struct wl_client *client,
695 struct wl_resource *shell_res,
697 struct wl_resource *output_res)
699 struct weston_head *head = weston_head_from_resource(output_res);
700 struct weston_output *woutput = weston_head_get_output(head);
701 struct ivi_output *output = to_ivi_output(woutput);
703 ivi_layout_activate(output, app_id);
707 shell_desktop_activate_app(struct wl_client *client,
708 struct wl_resource *shell_res,
709 const char *app_id, const char *data,
710 struct wl_resource *output_res)
712 struct weston_head *head = weston_head_from_resource(output_res);
713 struct weston_output *woutput = weston_head_get_output(head);
714 struct ivi_output *output = to_ivi_output(woutput);
716 ivi_layout_activate(output, app_id);
717 shell_advertise_app_state(output->ivi, app_id,
718 data, AGL_SHELL_DESKTOP_APP_STATE_ACTIVATED);
722 shell_deactivate_app(struct wl_client *client,
723 struct wl_resource *shell_res,
726 struct desktop_client *dclient = wl_resource_get_user_data(shell_res);
727 struct ivi_compositor *ivi = dclient->ivi;
729 ivi_layout_deactivate(ivi, app_id);
730 shell_advertise_app_state(ivi, app_id,
731 NULL, AGL_SHELL_DESKTOP_APP_STATE_DEACTIVATED);
734 static const struct agl_shell_interface agl_shell_implementation = {
735 .ready = shell_ready,
736 .set_background = shell_set_background,
737 .set_panel = shell_set_panel,
738 .activate_app = shell_activate_app,
742 shell_desktop_set_app_property(struct wl_client *client,
743 struct wl_resource *shell_res,
744 const char *app_id, uint32_t role,
745 int x, int y, struct wl_resource *output_res)
747 struct weston_head *head = weston_head_from_resource(output_res);
748 struct weston_output *woutput = weston_head_get_output(head);
749 struct ivi_output *output = to_ivi_output(woutput);
752 case AGL_SHELL_DESKTOP_APP_ROLE_POPUP:
753 ivi_set_pending_desktop_surface_popup(output, x, y, app_id);
755 case AGL_SHELL_DESKTOP_APP_ROLE_FULLSCREEN:
756 ivi_set_pending_desktop_surface_fullscreen(output, app_id);
758 case AGL_SHELL_DESKTOP_APP_ROLE_SPLIT_VERTICAL:
759 case AGL_SHELL_DESKTOP_APP_ROLE_SPLIT_HORIZONTAL:
760 ivi_set_pending_desktop_surface_split(output, app_id, role);
767 static const struct agl_shell_desktop_interface agl_shell_desktop_implementation = {
768 .activate_app = shell_desktop_activate_app,
769 .set_app_property = shell_desktop_set_app_property,
770 .deactivate_app = shell_deactivate_app,
774 unbind_agl_shell(struct wl_resource *resource)
776 struct ivi_compositor *ivi;
777 struct ivi_output *output;
778 struct ivi_surface *surf, *surf_tmp;
780 ivi = wl_resource_get_user_data(resource);
781 wl_list_for_each(output, &ivi->outputs, link) {
782 /* reset the active surf if there's one present */
783 if (output->active) {
784 output->active->view->is_mapped = false;
785 output->active->view->surface->is_mapped = false;
787 weston_layer_entry_remove(&output->active->view->layer_link);
788 output->active = NULL;
791 insert_black_surface(output);
794 wl_list_for_each_safe(surf, surf_tmp, &ivi->surfaces, link) {
795 wl_list_remove(&surf->link);
796 wl_list_init(&surf->link);
799 wl_list_for_each_safe(surf, surf_tmp, &ivi->pending_surfaces, link) {
800 wl_list_remove(&surf->link);
801 wl_list_init(&surf->link);
804 wl_list_init(&ivi->surfaces);
805 wl_list_init(&ivi->pending_surfaces);
807 ivi->shell_client.ready = false;
808 ivi->shell_client.resource = NULL;
809 ivi->shell_client.client = NULL;
813 bind_agl_shell(struct wl_client *client,
814 void *data, uint32_t version, uint32_t id)
816 struct ivi_compositor *ivi = data;
817 struct wl_resource *resource;
819 resource = wl_resource_create(client, &agl_shell_interface,
822 wl_client_post_no_memory(client);
827 if (ivi->shell_client.client != client) {
828 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
829 "client not authorized to use agl_shell");
834 if (ivi->shell_client.resource) {
835 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
836 "agl_shell has already been bound");
840 wl_resource_set_implementation(resource, &agl_shell_implementation,
841 ivi, unbind_agl_shell);
842 ivi->shell_client.resource = resource;
846 unbind_agl_shell_desktop(struct wl_resource *resource)
848 struct desktop_client *dclient = wl_resource_get_user_data(resource);
850 wl_list_remove(&dclient->link);
855 bind_agl_shell_desktop(struct wl_client *client,
856 void *data, uint32_t version, uint32_t id)
858 struct ivi_compositor *ivi = data;
859 struct wl_resource *resource;
860 struct desktop_client *dclient = zalloc(sizeof(*dclient));
863 wl_client_post_no_memory(client);
867 resource = wl_resource_create(client, &agl_shell_desktop_interface,
871 wl_client_post_no_memory(client);
875 wl_resource_set_implementation(resource, &agl_shell_desktop_implementation,
876 dclient, unbind_agl_shell_desktop);
878 dclient->resource = resource;
879 wl_list_insert(&ivi->desktop_clients, &dclient->link);
881 /* advertise xdg surfaces */
882 ivi_shell_advertise_xdg_surfaces(ivi, resource);
886 ivi_shell_create_global(struct ivi_compositor *ivi)
888 ivi->agl_shell = wl_global_create(ivi->compositor->wl_display,
889 &agl_shell_interface, 1,
890 ivi, bind_agl_shell);
891 if (!ivi->agl_shell) {
892 weston_log("Failed to create wayland global.\n");
896 ivi->agl_shell_desktop = wl_global_create(ivi->compositor->wl_display,
897 &agl_shell_desktop_interface, 1,
898 ivi, bind_agl_shell_desktop);
899 if (!ivi->agl_shell_desktop) {
900 weston_log("Failed to create wayland global (agl_shell_desktop).\n");