blob: 71e038e720d0c3cf7af1a3144a3b22a28289f472 [file] [log] [blame]
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +09001/*
2 * Copyright (C) 2013 DENSO CORPORATION
3 *
Bryce Harringtonaf637c22015-06-11 12:55:55 -07004 * 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:
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +090011 *
Bryce Harringtonaf637c22015-06-11 12:55:55 -070012 * 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.
15 *
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
23 * SOFTWARE.
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +090024 */
25
26/*
27 * ivi-shell supports a type of shell for In-Vehicle Infotainment system.
28 * In-Vehicle Infotainment system traditionally manages surfaces with global
29 * identification. A protocol, ivi_application, supports such a feature
30 * by implementing a request, ivi_application::surface_creation defined in
31 * ivi_application.xml.
32 *
33 * The ivi-shell explicitly loads a module to add business logic like how to
34 * layout surfaces by using internal ivi-layout APIs.
35 */
36#include "config.h"
37
Jussi Kukkonen649bbce2016-07-19 14:16:27 +030038#include <stdint.h>
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +090039#include <string.h>
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +090040#include <dlfcn.h>
41#include <limits.h>
42#include <assert.h>
Pekka Paalanen6c7a1c72015-02-19 17:12:19 +020043#include <linux/input.h>
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +090044
45#include "ivi-shell.h"
46#include "ivi-application-server-protocol.h"
Michael Teyfel8f9e92e2019-02-01 15:17:35 +010047#include "ivi-layout-private.h"
Pekka Paalanen32ca7912016-03-15 17:21:00 +020048#include "ivi-layout-shell.h"
Jon Cruz35b2eaa2015-06-15 15:37:08 -070049#include "shared/helpers.h"
Pekka Paalanen58f98c92016-06-03 16:45:21 +030050#include "compositor/weston.h"
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +090051
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +090052/* Representation of ivi_surface protocol object. */
53struct ivi_shell_surface
54{
55 struct wl_resource* resource;
56 struct ivi_shell *shell;
57 struct ivi_layout_surface *layout_surface;
58
59 struct weston_surface *surface;
60 struct wl_listener surface_destroy_listener;
61
62 uint32_t id_surface;
63
64 int32_t width;
65 int32_t height;
66
67 struct wl_list link;
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +090068};
69
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +090070/*
71 * Implementation of ivi_surface
72 */
73
74static void
Quentin Glidic2edc3d52016-08-12 10:41:33 +020075ivi_shell_surface_committed(struct weston_surface *, int32_t, int32_t);
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +090076
77static struct ivi_shell_surface *
78get_ivi_shell_surface(struct weston_surface *surface)
79{
Pekka Paalanen94cb06a2016-03-16 14:54:12 +020080 struct ivi_shell_surface *shsurf;
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +090081
Quentin Glidic2edc3d52016-08-12 10:41:33 +020082 if (surface->committed != ivi_shell_surface_committed)
Pekka Paalanen94cb06a2016-03-16 14:54:12 +020083 return NULL;
84
Quentin Glidic2edc3d52016-08-12 10:41:33 +020085 shsurf = surface->committed_private;
Pekka Paalanen94cb06a2016-03-16 14:54:12 +020086 assert(shsurf);
87 assert(shsurf->surface == surface);
88
89 return shsurf;
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +090090}
91
Pekka Paalaneneaa43fc2016-04-12 16:06:58 +030092struct ivi_layout_surface *
93shell_get_ivi_layout_surface(struct weston_surface *surface)
94{
95 struct ivi_shell_surface *shsurf;
96
97 shsurf = get_ivi_shell_surface(surface);
98 if (!shsurf)
99 return NULL;
100
101 return shsurf->layout_surface;
102}
103
Pekka Paalanen1f821932016-03-15 16:57:51 +0200104void
105shell_surface_send_configure(struct weston_surface *surface,
106 int32_t width, int32_t height)
107{
108 struct ivi_shell_surface *shsurf;
109
110 shsurf = get_ivi_shell_surface(surface);
Pekka Paalanen1f821932016-03-15 16:57:51 +0200111 if (!shsurf)
112 return;
113
114 if (shsurf->resource)
115 ivi_surface_send_configure(shsurf->resource, width, height);
116}
117
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900118static void
Quentin Glidic2edc3d52016-08-12 10:41:33 +0200119ivi_shell_surface_committed(struct weston_surface *surface,
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900120 int32_t sx, int32_t sy)
121{
122 struct ivi_shell_surface *ivisurf = get_ivi_shell_surface(surface);
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900123
Pekka Paalanenfd45f602016-03-16 15:05:03 +0200124 assert(ivisurf);
125 if (!ivisurf)
126 return;
127
128 if (surface->width == 0 || surface->height == 0)
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900129 return;
130
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900131 if (ivisurf->width != surface->width ||
132 ivisurf->height != surface->height) {
133 ivisurf->width = surface->width;
134 ivisurf->height = surface->height;
135
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +0900136 ivi_layout_surface_configure(ivisurf->layout_surface,
137 surface->width, surface->height);
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900138 }
139}
140
Pekka Paalanen13281f62016-03-07 16:19:37 +0200141static int
142ivi_shell_surface_get_label(struct weston_surface *surface,
143 char *buf,
144 size_t len)
145{
146 struct ivi_shell_surface *shell_surf = get_ivi_shell_surface(surface);
147
148 if (!shell_surf)
149 return snprintf(buf, len, "unidentified window in ivi-shell");
150
151 return snprintf(buf, len, "ivi-surface %#x", shell_surf->id_surface);
152}
153
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900154static void
155layout_surface_cleanup(struct ivi_shell_surface *ivisurf)
156{
157 assert(ivisurf->layout_surface != NULL);
158
Michael Teyfeled28f022017-10-17 11:10:18 +0200159 /* destroy weston_surface destroy signal. */
160 if (!ivisurf->layout_surface->weston_desktop_surface)
161 wl_list_remove(&ivisurf->surface_destroy_listener.link);
162
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900163 ivi_layout_surface_destroy(ivisurf->layout_surface);
164 ivisurf->layout_surface = NULL;
165
Quentin Glidic2edc3d52016-08-12 10:41:33 +0200166 ivisurf->surface->committed = NULL;
167 ivisurf->surface->committed_private = NULL;
Pekka Paalanen13281f62016-03-07 16:19:37 +0200168 weston_surface_set_label_func(ivisurf->surface, NULL);
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900169 ivisurf->surface = NULL;
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900170}
171
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900172/*
173 * The ivi_surface wl_resource destructor.
174 *
175 * Gets called via ivi_surface.destroy request or automatic wl_client clean-up.
176 */
177static void
178shell_destroy_shell_surface(struct wl_resource *resource)
179{
180 struct ivi_shell_surface *ivisurf = wl_resource_get_user_data(resource);
Nobuhiko Tanibata68098422015-06-22 15:31:08 +0900181
182 if (ivisurf == NULL)
183 return;
184
185 assert(ivisurf->resource == resource);
186
187 if (ivisurf->layout_surface != NULL)
188 layout_surface_cleanup(ivisurf);
189
190 wl_list_remove(&ivisurf->link);
191
192 free(ivisurf);
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900193}
194
195/* Gets called through the weston_surface destroy signal. */
196static void
197shell_handle_surface_destroy(struct wl_listener *listener, void *data)
198{
199 struct ivi_shell_surface *ivisurf =
200 container_of(listener, struct ivi_shell_surface,
201 surface_destroy_listener);
202
203 assert(ivisurf != NULL);
204
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900205 if (ivisurf->layout_surface != NULL)
206 layout_surface_cleanup(ivisurf);
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900207}
208
209/* Gets called, when a client sends ivi_surface.destroy request. */
210static void
211surface_destroy(struct wl_client *client, struct wl_resource *resource)
212{
213 /*
214 * Fires the wl_resource destroy signal, and then calls
215 * ivi_surface wl_resource destructor: shell_destroy_shell_surface()
216 */
217 wl_resource_destroy(resource);
218}
219
220static const struct ivi_surface_interface surface_implementation = {
221 surface_destroy,
222};
223
224/**
225 * Request handler for ivi_application.surface_create.
226 *
227 * Creates an ivi_surface protocol object associated with the given wl_surface.
228 * ivi_surface protocol object is represented by struct ivi_shell_surface.
229 *
230 * \param client The client.
231 * \param resource The ivi_application protocol object.
232 * \param id_surface The IVI surface ID.
233 * \param surface_resource The wl_surface protocol object.
234 * \param id The protocol object id for the new ivi_surface protocol object.
235 *
236 * The wl_surface is given the ivi_surface role and associated with a unique
237 * IVI ID which is used to identify the surface in a controller
238 * (window manager).
239 */
240static void
241application_surface_create(struct wl_client *client,
242 struct wl_resource *resource,
243 uint32_t id_surface,
244 struct wl_resource *surface_resource,
245 uint32_t id)
246{
247 struct ivi_shell *shell = wl_resource_get_user_data(resource);
248 struct ivi_shell_surface *ivisurf;
249 struct ivi_layout_surface *layout_surface;
250 struct weston_surface *weston_surface =
251 wl_resource_get_user_data(surface_resource);
252 struct wl_resource *res;
253
254 if (weston_surface_set_role(weston_surface, "ivi_surface",
255 resource, IVI_APPLICATION_ERROR_ROLE) < 0)
256 return;
257
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +0900258 layout_surface = ivi_layout_surface_create(weston_surface, id_surface);
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900259
260 /* check if id_ivi is already used for wl_surface*/
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300261 if (layout_surface == NULL) {
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900262 wl_resource_post_error(resource,
263 IVI_APPLICATION_ERROR_IVI_ID,
264 "surface_id is already assigned "
265 "by another app");
266 return;
267 }
268
Michael Teyfel8f9e92e2019-02-01 15:17:35 +0100269 layout_surface->weston_desktop_surface = NULL;
270
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900271 ivisurf = zalloc(sizeof *ivisurf);
272 if (ivisurf == NULL) {
273 wl_resource_post_no_memory(resource);
274 return;
275 }
276
277 wl_list_init(&ivisurf->link);
278 wl_list_insert(&shell->ivi_surface_list, &ivisurf->link);
279
280 ivisurf->shell = shell;
281 ivisurf->id_surface = id_surface;
282
283 ivisurf->width = 0;
284 ivisurf->height = 0;
285 ivisurf->layout_surface = layout_surface;
Pekka Paalanen1f821932016-03-15 16:57:51 +0200286
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900287 /*
288 * The following code relies on wl_surface destruction triggering
289 * immediateweston_surface destruction
290 */
291 ivisurf->surface_destroy_listener.notify = shell_handle_surface_destroy;
292 wl_signal_add(&weston_surface->destroy_signal,
293 &ivisurf->surface_destroy_listener);
294
295 ivisurf->surface = weston_surface;
296
Quentin Glidic2edc3d52016-08-12 10:41:33 +0200297 weston_surface->committed = ivi_shell_surface_committed;
298 weston_surface->committed_private = ivisurf;
Pekka Paalanen13281f62016-03-07 16:19:37 +0200299 weston_surface_set_label_func(weston_surface,
300 ivi_shell_surface_get_label);
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900301
302 res = wl_resource_create(client, &ivi_surface_interface, 1, id);
303 if (res == NULL) {
304 wl_client_post_no_memory(client);
305 return;
306 }
307
308 ivisurf->resource = res;
309
310 wl_resource_set_implementation(res, &surface_implementation,
311 ivisurf, shell_destroy_shell_surface);
312}
313
314static const struct ivi_application_interface application_implementation = {
315 application_surface_create
316};
317
318/*
319 * Handle wl_registry.bind of ivi_application global singleton.
320 */
321static void
322bind_ivi_application(struct wl_client *client,
323 void *data, uint32_t version, uint32_t id)
324{
325 struct ivi_shell *shell = data;
326 struct wl_resource *resource;
327
328 resource = wl_resource_create(client, &ivi_application_interface,
329 1, id);
330
331 wl_resource_set_implementation(resource,
332 &application_implementation,
333 shell, NULL);
334}
335
336/*
337 * Called through the compositor's destroy signal.
338 */
339static void
340shell_destroy(struct wl_listener *listener, void *data)
341{
342 struct ivi_shell *shell =
343 container_of(listener, struct ivi_shell, destroy_listener);
344 struct ivi_shell_surface *ivisurf, *next;
345
Harsha M M46cbd0a2018-08-07 19:05:03 +0530346 wl_list_remove(&shell->destroy_listener.link);
Emre Ucancf4113c2018-06-05 10:23:00 +0200347 wl_list_remove(&shell->wake_listener.link);
348
Pekka Paalanen32aedb92021-06-15 16:17:29 +0300349 weston_desktop_destroy(shell->desktop);
350
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900351 wl_list_for_each_safe(ivisurf, next, &shell->ivi_surface_list, link) {
Harsha M M1b470f92018-08-03 19:22:16 +0530352 if (ivisurf->layout_surface != NULL)
353 layout_surface_cleanup(ivisurf);
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900354 wl_list_remove(&ivisurf->link);
355 free(ivisurf);
356 }
357
Pekka Paalanen9706a802021-05-14 14:55:26 +0300358 ivi_layout_fini();
359
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900360 free(shell);
361}
362
Emre Ucancf4113c2018-06-05 10:23:00 +0200363/*
364 * Called through the compositor's wake signal.
365 */
366static void
367wake_handler(struct wl_listener *listener, void *data)
368{
369 struct weston_compositor *compositor = data;
370
371 weston_compositor_damage_all(compositor);
372}
373
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900374static void
Alexandros Frantzis47e79c82017-11-16 18:20:57 +0200375terminate_binding(struct weston_keyboard *keyboard, const struct timespec *time,
Derek Foreman8ae2db52015-07-15 13:00:36 -0500376 uint32_t key, void *data)
Pekka Paalanen6c7a1c72015-02-19 17:12:19 +0200377{
378 struct weston_compositor *compositor = data;
379
Pekka Paalanen818c20e2019-02-06 10:48:51 +0200380 weston_compositor_exit(compositor);
Pekka Paalanen6c7a1c72015-02-19 17:12:19 +0200381}
382
383static void
Emre Ucanf85bf152018-01-25 14:37:38 +0100384init_ivi_shell(struct weston_compositor *compositor, struct ivi_shell *shell)
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900385{
Emre Ucanf85bf152018-01-25 14:37:38 +0100386 struct weston_config *config = wet_get_config(compositor);
387 struct weston_config_section *section;
Daniel Stone51d995a2019-11-26 00:14:24 +0000388 bool developermode;
Emre Ucanf85bf152018-01-25 14:37:38 +0100389
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900390 shell->compositor = compositor;
391
392 wl_list_init(&shell->ivi_surface_list);
393
Emre Ucanf85bf152018-01-25 14:37:38 +0100394 section = weston_config_get_section(config, "ivi-shell", NULL, NULL);
395
396 weston_config_section_get_bool(section, "developermode",
397 &developermode, 0);
398
399 if (developermode) {
Pekka Paalanene35b2232015-02-19 17:08:44 +0200400 weston_install_debug_key_binding(compositor, MODIFIER_SUPER);
Pekka Paalanen6c7a1c72015-02-19 17:12:19 +0200401
402 weston_compositor_add_key_binding(compositor, KEY_BACKSPACE,
403 MODIFIER_CTRL | MODIFIER_ALT,
404 terminate_binding,
405 compositor);
406 }
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900407}
408
Nobuhiko Tanibata0627b4a2015-12-09 15:03:47 +0900409static void
410activate_binding(struct weston_seat *seat,
411 struct weston_view *focus_view)
412{
413 struct weston_surface *focus = focus_view->surface;
414 struct weston_surface *main_surface =
415 weston_surface_get_main_surface(focus);
416
417 if (get_ivi_shell_surface(main_surface) == NULL)
418 return;
419
Bryce Harrington260c2ff2016-06-29 19:04:06 -0700420 weston_seat_set_keyboard_focus(seat, focus);
Nobuhiko Tanibata0627b4a2015-12-09 15:03:47 +0900421}
422
423static void
Alexandros Frantzis215bedc2017-11-16 18:20:55 +0200424click_to_activate_binding(struct weston_pointer *pointer,
425 const struct timespec *time,
Nobuhiko Tanibata0627b4a2015-12-09 15:03:47 +0900426 uint32_t button, void *data)
427{
428 if (pointer->grab != &pointer->default_grab)
429 return;
430 if (pointer->focus == NULL)
431 return;
432
433 activate_binding(pointer->seat, pointer->focus);
434}
435
436static void
Alexandros Frantzis9448deb2017-11-16 18:20:58 +0200437touch_to_activate_binding(struct weston_touch *touch,
438 const struct timespec *time,
Nobuhiko Tanibata0627b4a2015-12-09 15:03:47 +0900439 void *data)
440{
441 if (touch->grab != &touch->default_grab)
442 return;
443 if (touch->focus == NULL)
444 return;
445
446 activate_binding(touch->seat, touch->focus);
447}
448
449static void
450shell_add_bindings(struct weston_compositor *compositor,
451 struct ivi_shell *shell)
452{
453 weston_compositor_add_button_binding(compositor, BTN_LEFT, 0,
454 click_to_activate_binding,
455 shell);
456 weston_compositor_add_button_binding(compositor, BTN_RIGHT, 0,
457 click_to_activate_binding,
458 shell);
459 weston_compositor_add_touch_binding(compositor, 0,
460 touch_to_activate_binding,
461 shell);
462}
463
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900464/*
Michael Teyfel62d6d562019-02-05 15:25:56 +0100465 * libweston-desktop
466 */
467
468static void
469desktop_surface_ping_timeout(struct weston_desktop_client *client,
470 void *user_data)
471{
472 /* Not supported */
473}
474
475static void
476desktop_surface_pong(struct weston_desktop_client *client,
477 void *user_data)
478{
479 /* Not supported */
480}
481
482static void
483desktop_surface_added(struct weston_desktop_surface *surface,
484 void *user_data)
485{
486 struct ivi_shell *shell = (struct ivi_shell *) user_data;
487 struct ivi_layout_surface *layout_surface;
488 struct ivi_shell_surface *ivisurf;
489 struct weston_surface *weston_surf =
490 weston_desktop_surface_get_surface(surface);
491
492 layout_surface = ivi_layout_desktop_surface_create(weston_surf);
493 if (!layout_surface) {
494 return;
495 }
496
497 layout_surface->weston_desktop_surface = surface;
498
499 ivisurf = zalloc(sizeof *ivisurf);
500 if (!ivisurf) {
501 return;
502 }
503
504 ivisurf->shell = shell;
505 ivisurf->id_surface = IVI_INVALID_ID;
506
507 ivisurf->width = 0;
508 ivisurf->height = 0;
509 ivisurf->layout_surface = layout_surface;
510 ivisurf->surface = weston_surf;
511
512 weston_desktop_surface_set_user_data(surface, ivisurf);
513}
514
515static void
516desktop_surface_removed(struct weston_desktop_surface *surface,
517 void *user_data)
518{
519 struct ivi_shell_surface *ivisurf = (struct ivi_shell_surface *)
520 weston_desktop_surface_get_user_data(surface);
521
522 assert(ivisurf != NULL);
523
524 if (ivisurf->layout_surface)
525 layout_surface_cleanup(ivisurf);
526}
527
528static void
529desktop_surface_committed(struct weston_desktop_surface *surface,
530 int32_t sx, int32_t sy, void *user_data)
531{
532 struct ivi_shell_surface *ivisurf = (struct ivi_shell_surface *)
533 weston_desktop_surface_get_user_data(surface);
534 struct weston_surface *weston_surf =
535 weston_desktop_surface_get_surface(surface);
536
Dongjin Kimba89f002024-09-30 17:49:36 +0900537 if (!ivisurf)
Michael Teyfel62d6d562019-02-05 15:25:56 +0100538 return;
539
540 if (weston_surf->width == 0 || weston_surf->height == 0)
541 return;
542
543 if (ivisurf->width != weston_surf->width ||
544 ivisurf->height != weston_surf->height) {
545 ivisurf->width = weston_surf->width;
546 ivisurf->height = weston_surf->height;
547
548 ivi_layout_desktop_surface_configure(ivisurf->layout_surface,
549 weston_surf->width,
550 weston_surf->height);
551 }
552}
553
554static void
555desktop_surface_move(struct weston_desktop_surface *surface,
556 struct weston_seat *seat, uint32_t serial, void *user_data)
557{
558 /* Not supported */
559}
560
561static void
562desktop_surface_resize(struct weston_desktop_surface *surface,
563 struct weston_seat *seat, uint32_t serial,
564 enum weston_desktop_surface_edge edges, void *user_data)
565{
566 /* Not supported */
567}
568
569static void
570desktop_surface_fullscreen_requested(struct weston_desktop_surface *surface,
571 bool fullscreen,
572 struct weston_output *output,
573 void *user_data)
574{
575 /* Not supported */
576}
577
578static void
579desktop_surface_maximized_requested(struct weston_desktop_surface *surface,
580 bool maximized, void *user_data)
581{
582 /* Not supported */
583}
584
585static void
586desktop_surface_minimized_requested(struct weston_desktop_surface *surface,
587 void *user_data)
588{
589 /* Not supported */
590}
591
592static void
593desktop_surface_set_xwayland_position(struct weston_desktop_surface *surface,
594 int32_t x, int32_t y, void *user_data)
595{
596 /* Not supported */
597}
598
599static const struct weston_desktop_api shell_desktop_api = {
600 .struct_size = sizeof(struct weston_desktop_api),
601 .ping_timeout = desktop_surface_ping_timeout,
602 .pong = desktop_surface_pong,
603 .surface_added = desktop_surface_added,
604 .surface_removed = desktop_surface_removed,
605 .committed = desktop_surface_committed,
606
607 .move = desktop_surface_move,
608 .resize = desktop_surface_resize,
609 .fullscreen_requested = desktop_surface_fullscreen_requested,
610 .maximized_requested = desktop_surface_maximized_requested,
611 .minimized_requested = desktop_surface_minimized_requested,
612 .set_xwayland_position = desktop_surface_set_xwayland_position,
613};
614
615/*
616 * end of libweston-desktop
617 */
618
619/*
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900620 * Initialization of ivi-shell.
621 */
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900622WL_EXPORT int
Quentin Glidicda01c1d2016-12-02 14:17:08 +0100623wet_shell_init(struct weston_compositor *compositor,
624 int *argc, char *argv[])
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900625{
626 struct ivi_shell *shell;
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900627
628 shell = zalloc(sizeof *shell);
629 if (shell == NULL)
630 return -1;
631
Pekka Paalanen6ffbba32019-11-06 12:59:32 +0200632 if (!weston_compositor_add_destroy_listener_once(compositor,
633 &shell->destroy_listener,
634 shell_destroy)) {
635 free(shell);
636 return 0;
637 }
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900638
Pekka Paalanen6ffbba32019-11-06 12:59:32 +0200639 init_ivi_shell(compositor, shell);
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900640
Emre Ucancf4113c2018-06-05 10:23:00 +0200641 shell->wake_listener.notify = wake_handler;
642 wl_signal_add(&compositor->wake_signal, &shell->wake_listener);
643
Michael Teyfel2763b662017-10-17 11:10:58 +0200644 shell->desktop = weston_desktop_create(compositor, &shell_desktop_api, shell);
645 if (!shell->desktop)
646 goto err_shell;
647
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900648 if (wl_global_create(compositor->wl_display,
649 &ivi_application_interface, 1,
650 shell, bind_ivi_application) == NULL)
Michael Teyfel2763b662017-10-17 11:10:58 +0200651 goto err_desktop;
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900652
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +0900653 ivi_layout_init_with_compositor(compositor);
Nobuhiko Tanibata0627b4a2015-12-09 15:03:47 +0900654 shell_add_bindings(compositor, shell);
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900655
Michael Teyfelf2042e12017-09-26 17:12:08 +0200656 return IVI_SUCCEEDED;
Pekka Paalanene35b2232015-02-19 17:08:44 +0200657
Michael Teyfel2763b662017-10-17 11:10:58 +0200658err_desktop:
659 weston_desktop_destroy(shell->desktop);
660
Michael Teyfelf2042e12017-09-26 17:12:08 +0200661err_shell:
Pekka Paalanend2b9b5d2019-11-06 12:07:23 +0200662 wl_list_remove(&shell->destroy_listener.link);
Michael Teyfelf2042e12017-09-26 17:12:08 +0200663 free(shell);
664
665 return IVI_FAILED;
Nobuhiko Tanibata487adc42014-11-27 13:22:37 +0900666}