Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 DENSO CORPORATION |
| 3 | * |
Bryce Harrington | af637c2 | 2015-06-11 12:55:55 -0700 | [diff] [blame] | 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: |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 11 | * |
Bryce Harrington | af637c2 | 2015-06-11 12:55:55 -0700 | [diff] [blame] | 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. |
| 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 Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 24 | */ |
| 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 | |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 38 | #include <string.h> |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 39 | #include <dlfcn.h> |
| 40 | #include <limits.h> |
| 41 | #include <assert.h> |
Pekka Paalanen | 6c7a1c7 | 2015-02-19 17:12:19 +0200 | [diff] [blame] | 42 | #include <linux/input.h> |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 43 | |
| 44 | #include "ivi-shell.h" |
| 45 | #include "ivi-application-server-protocol.h" |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 46 | #include "ivi-layout-export.h" |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 47 | #include "ivi-layout-private.h" |
Jon Cruz | 35b2eaa | 2015-06-15 15:37:08 -0700 | [diff] [blame] | 48 | #include "shared/helpers.h" |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 49 | |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 50 | /* Representation of ivi_surface protocol object. */ |
| 51 | struct ivi_shell_surface |
| 52 | { |
| 53 | struct wl_resource* resource; |
| 54 | struct ivi_shell *shell; |
| 55 | struct ivi_layout_surface *layout_surface; |
| 56 | |
| 57 | struct weston_surface *surface; |
| 58 | struct wl_listener surface_destroy_listener; |
| 59 | |
| 60 | uint32_t id_surface; |
| 61 | |
| 62 | int32_t width; |
| 63 | int32_t height; |
| 64 | |
| 65 | struct wl_list link; |
| 66 | |
| 67 | struct wl_listener configured_listener; |
| 68 | }; |
| 69 | |
| 70 | struct ivi_shell_setting |
| 71 | { |
| 72 | char *ivi_module; |
Pekka Paalanen | e35b223 | 2015-02-19 17:08:44 +0200 | [diff] [blame] | 73 | int developermode; |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | /* |
| 77 | * Implementation of ivi_surface |
| 78 | */ |
| 79 | |
| 80 | static void |
| 81 | surface_configure_notify(struct wl_listener *listener, void *data) |
| 82 | { |
| 83 | struct ivi_layout_surface *layout_surf = |
| 84 | (struct ivi_layout_surface *)data; |
| 85 | |
| 86 | struct ivi_shell_surface *shell_surf = |
| 87 | container_of(listener, |
| 88 | struct ivi_shell_surface, |
| 89 | configured_listener); |
| 90 | |
| 91 | int32_t dest_width = 0; |
| 92 | int32_t dest_height = 0; |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 93 | |
| 94 | ivi_layout_surface_get_dimension(layout_surf, |
| 95 | &dest_width, &dest_height); |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 96 | |
| 97 | if (shell_surf->resource) |
| 98 | ivi_surface_send_configure(shell_surf->resource, |
| 99 | dest_width, dest_height); |
| 100 | } |
| 101 | |
| 102 | static void |
| 103 | ivi_shell_surface_configure(struct weston_surface *, int32_t, int32_t); |
| 104 | |
| 105 | static struct ivi_shell_surface * |
| 106 | get_ivi_shell_surface(struct weston_surface *surface) |
| 107 | { |
| 108 | if (surface->configure == ivi_shell_surface_configure) |
| 109 | return surface->configure_private; |
| 110 | |
| 111 | return NULL; |
| 112 | } |
| 113 | |
| 114 | static void |
| 115 | ivi_shell_surface_configure(struct weston_surface *surface, |
| 116 | int32_t sx, int32_t sy) |
| 117 | { |
| 118 | struct ivi_shell_surface *ivisurf = get_ivi_shell_surface(surface); |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 119 | |
| 120 | if (surface->width == 0 || surface->height == 0 || ivisurf == NULL) |
| 121 | return; |
| 122 | |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 123 | if (ivisurf->width != surface->width || |
| 124 | ivisurf->height != surface->height) { |
| 125 | ivisurf->width = surface->width; |
| 126 | ivisurf->height = surface->height; |
| 127 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 128 | ivi_layout_surface_configure(ivisurf->layout_surface, |
| 129 | surface->width, surface->height); |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 130 | } |
| 131 | } |
| 132 | |
Nobuhiko Tanibata | 6f6c938 | 2015-06-22 15:30:53 +0900 | [diff] [blame^] | 133 | static void |
| 134 | layout_surface_cleanup(struct ivi_shell_surface *ivisurf) |
| 135 | { |
| 136 | assert(ivisurf->layout_surface != NULL); |
| 137 | |
| 138 | ivi_layout_surface_destroy(ivisurf->layout_surface); |
| 139 | ivisurf->layout_surface = NULL; |
| 140 | |
| 141 | ivisurf->surface->configure = NULL; |
| 142 | ivisurf->surface->configure_private = NULL; |
| 143 | ivisurf->surface = NULL; |
| 144 | |
| 145 | // destroy weston_surface destroy signal. |
| 146 | wl_list_remove(&ivisurf->surface_destroy_listener.link); |
| 147 | } |
| 148 | |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 149 | /* |
| 150 | * The ivi_surface wl_resource destructor. |
| 151 | * |
| 152 | * Gets called via ivi_surface.destroy request or automatic wl_client clean-up. |
| 153 | */ |
| 154 | static void |
| 155 | shell_destroy_shell_surface(struct wl_resource *resource) |
| 156 | { |
| 157 | struct ivi_shell_surface *ivisurf = wl_resource_get_user_data(resource); |
| 158 | if (ivisurf != NULL) { |
| 159 | ivisurf->resource = NULL; |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /* Gets called through the weston_surface destroy signal. */ |
| 164 | static void |
| 165 | shell_handle_surface_destroy(struct wl_listener *listener, void *data) |
| 166 | { |
| 167 | struct ivi_shell_surface *ivisurf = |
| 168 | container_of(listener, struct ivi_shell_surface, |
| 169 | surface_destroy_listener); |
| 170 | |
| 171 | assert(ivisurf != NULL); |
| 172 | |
Nobuhiko Tanibata | 6f6c938 | 2015-06-22 15:30:53 +0900 | [diff] [blame^] | 173 | if (ivisurf->layout_surface != NULL) |
| 174 | layout_surface_cleanup(ivisurf); |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 175 | |
| 176 | if (ivisurf->resource != NULL) { |
| 177 | wl_resource_set_user_data(ivisurf->resource, NULL); |
| 178 | ivisurf->resource = NULL; |
| 179 | } |
| 180 | free(ivisurf); |
| 181 | |
| 182 | } |
| 183 | |
| 184 | /* Gets called, when a client sends ivi_surface.destroy request. */ |
| 185 | static void |
| 186 | surface_destroy(struct wl_client *client, struct wl_resource *resource) |
| 187 | { |
| 188 | /* |
| 189 | * Fires the wl_resource destroy signal, and then calls |
| 190 | * ivi_surface wl_resource destructor: shell_destroy_shell_surface() |
| 191 | */ |
| 192 | wl_resource_destroy(resource); |
| 193 | } |
| 194 | |
| 195 | static const struct ivi_surface_interface surface_implementation = { |
| 196 | surface_destroy, |
| 197 | }; |
| 198 | |
| 199 | /** |
| 200 | * Request handler for ivi_application.surface_create. |
| 201 | * |
| 202 | * Creates an ivi_surface protocol object associated with the given wl_surface. |
| 203 | * ivi_surface protocol object is represented by struct ivi_shell_surface. |
| 204 | * |
| 205 | * \param client The client. |
| 206 | * \param resource The ivi_application protocol object. |
| 207 | * \param id_surface The IVI surface ID. |
| 208 | * \param surface_resource The wl_surface protocol object. |
| 209 | * \param id The protocol object id for the new ivi_surface protocol object. |
| 210 | * |
| 211 | * The wl_surface is given the ivi_surface role and associated with a unique |
| 212 | * IVI ID which is used to identify the surface in a controller |
| 213 | * (window manager). |
| 214 | */ |
| 215 | static void |
| 216 | application_surface_create(struct wl_client *client, |
| 217 | struct wl_resource *resource, |
| 218 | uint32_t id_surface, |
| 219 | struct wl_resource *surface_resource, |
| 220 | uint32_t id) |
| 221 | { |
| 222 | struct ivi_shell *shell = wl_resource_get_user_data(resource); |
| 223 | struct ivi_shell_surface *ivisurf; |
| 224 | struct ivi_layout_surface *layout_surface; |
| 225 | struct weston_surface *weston_surface = |
| 226 | wl_resource_get_user_data(surface_resource); |
| 227 | struct wl_resource *res; |
| 228 | |
| 229 | if (weston_surface_set_role(weston_surface, "ivi_surface", |
| 230 | resource, IVI_APPLICATION_ERROR_ROLE) < 0) |
| 231 | return; |
| 232 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 233 | layout_surface = ivi_layout_surface_create(weston_surface, id_surface); |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 234 | |
| 235 | /* check if id_ivi is already used for wl_surface*/ |
| 236 | if (layout_surface == NULL){ |
| 237 | wl_resource_post_error(resource, |
| 238 | IVI_APPLICATION_ERROR_IVI_ID, |
| 239 | "surface_id is already assigned " |
| 240 | "by another app"); |
| 241 | return; |
| 242 | } |
| 243 | |
| 244 | ivisurf = zalloc(sizeof *ivisurf); |
| 245 | if (ivisurf == NULL) { |
| 246 | wl_resource_post_no_memory(resource); |
| 247 | return; |
| 248 | } |
| 249 | |
| 250 | wl_list_init(&ivisurf->link); |
| 251 | wl_list_insert(&shell->ivi_surface_list, &ivisurf->link); |
| 252 | |
| 253 | ivisurf->shell = shell; |
| 254 | ivisurf->id_surface = id_surface; |
| 255 | |
| 256 | ivisurf->width = 0; |
| 257 | ivisurf->height = 0; |
| 258 | ivisurf->layout_surface = layout_surface; |
| 259 | ivisurf->configured_listener.notify = surface_configure_notify; |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 260 | ivi_layout_surface_add_configured_listener(layout_surface, |
| 261 | &ivisurf->configured_listener); |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 262 | /* |
| 263 | * The following code relies on wl_surface destruction triggering |
| 264 | * immediateweston_surface destruction |
| 265 | */ |
| 266 | ivisurf->surface_destroy_listener.notify = shell_handle_surface_destroy; |
| 267 | wl_signal_add(&weston_surface->destroy_signal, |
| 268 | &ivisurf->surface_destroy_listener); |
| 269 | |
| 270 | ivisurf->surface = weston_surface; |
| 271 | |
| 272 | weston_surface->configure = ivi_shell_surface_configure; |
| 273 | weston_surface->configure_private = ivisurf; |
| 274 | |
| 275 | res = wl_resource_create(client, &ivi_surface_interface, 1, id); |
| 276 | if (res == NULL) { |
| 277 | wl_client_post_no_memory(client); |
| 278 | return; |
| 279 | } |
| 280 | |
| 281 | ivisurf->resource = res; |
| 282 | |
| 283 | wl_resource_set_implementation(res, &surface_implementation, |
| 284 | ivisurf, shell_destroy_shell_surface); |
| 285 | } |
| 286 | |
| 287 | static const struct ivi_application_interface application_implementation = { |
| 288 | application_surface_create |
| 289 | }; |
| 290 | |
| 291 | /* |
| 292 | * Handle wl_registry.bind of ivi_application global singleton. |
| 293 | */ |
| 294 | static void |
| 295 | bind_ivi_application(struct wl_client *client, |
| 296 | void *data, uint32_t version, uint32_t id) |
| 297 | { |
| 298 | struct ivi_shell *shell = data; |
| 299 | struct wl_resource *resource; |
| 300 | |
| 301 | resource = wl_resource_create(client, &ivi_application_interface, |
| 302 | 1, id); |
| 303 | |
| 304 | wl_resource_set_implementation(resource, |
| 305 | &application_implementation, |
| 306 | shell, NULL); |
| 307 | } |
| 308 | |
Nobuhiko Tanibata | 0038b73 | 2014-11-27 13:25:34 +0900 | [diff] [blame] | 309 | struct weston_view * |
| 310 | get_default_view(struct weston_surface *surface) |
| 311 | { |
| 312 | struct ivi_shell_surface *shsurf; |
| 313 | struct weston_view *view; |
| 314 | |
| 315 | if (!surface || wl_list_empty(&surface->views)) |
| 316 | return NULL; |
| 317 | |
| 318 | shsurf = get_ivi_shell_surface(surface); |
| 319 | if (shsurf && shsurf->layout_surface) { |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 320 | view = ivi_layout_get_weston_view(shsurf->layout_surface); |
Nobuhiko Tanibata | 0038b73 | 2014-11-27 13:25:34 +0900 | [diff] [blame] | 321 | if (view) |
| 322 | return view; |
| 323 | } |
| 324 | |
| 325 | wl_list_for_each(view, &surface->views, surface_link) { |
| 326 | if (weston_view_is_mapped(view)) |
| 327 | return view; |
| 328 | } |
| 329 | |
| 330 | return container_of(surface->views.next, |
| 331 | struct weston_view, surface_link); |
| 332 | } |
| 333 | |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 334 | /* |
| 335 | * Called through the compositor's destroy signal. |
| 336 | */ |
| 337 | static void |
| 338 | shell_destroy(struct wl_listener *listener, void *data) |
| 339 | { |
| 340 | struct ivi_shell *shell = |
| 341 | container_of(listener, struct ivi_shell, destroy_listener); |
| 342 | struct ivi_shell_surface *ivisurf, *next; |
| 343 | |
Nobuhiko Tanibata | 0038b73 | 2014-11-27 13:25:34 +0900 | [diff] [blame] | 344 | input_panel_destroy(shell); |
| 345 | |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 346 | wl_list_for_each_safe(ivisurf, next, &shell->ivi_surface_list, link) { |
| 347 | wl_list_remove(&ivisurf->link); |
| 348 | free(ivisurf); |
| 349 | } |
| 350 | |
| 351 | free(shell); |
| 352 | } |
| 353 | |
| 354 | static void |
Pekka Paalanen | 6c7a1c7 | 2015-02-19 17:12:19 +0200 | [diff] [blame] | 355 | terminate_binding(struct weston_seat *seat, uint32_t time, uint32_t key, |
| 356 | void *data) |
| 357 | { |
| 358 | struct weston_compositor *compositor = data; |
| 359 | |
| 360 | wl_display_terminate(compositor->wl_display); |
| 361 | } |
| 362 | |
| 363 | static void |
Pekka Paalanen | e35b223 | 2015-02-19 17:08:44 +0200 | [diff] [blame] | 364 | init_ivi_shell(struct weston_compositor *compositor, struct ivi_shell *shell, |
| 365 | const struct ivi_shell_setting *setting) |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 366 | { |
| 367 | shell->compositor = compositor; |
| 368 | |
| 369 | wl_list_init(&shell->ivi_surface_list); |
| 370 | |
Nobuhiko Tanibata | 0038b73 | 2014-11-27 13:25:34 +0900 | [diff] [blame] | 371 | weston_layer_init(&shell->input_panel_layer, NULL); |
Pekka Paalanen | e35b223 | 2015-02-19 17:08:44 +0200 | [diff] [blame] | 372 | |
Pekka Paalanen | 6c7a1c7 | 2015-02-19 17:12:19 +0200 | [diff] [blame] | 373 | if (setting->developermode) { |
Pekka Paalanen | e35b223 | 2015-02-19 17:08:44 +0200 | [diff] [blame] | 374 | weston_install_debug_key_binding(compositor, MODIFIER_SUPER); |
Pekka Paalanen | 6c7a1c7 | 2015-02-19 17:12:19 +0200 | [diff] [blame] | 375 | |
| 376 | weston_compositor_add_key_binding(compositor, KEY_BACKSPACE, |
| 377 | MODIFIER_CTRL | MODIFIER_ALT, |
| 378 | terminate_binding, |
| 379 | compositor); |
| 380 | } |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | static int |
| 384 | ivi_shell_setting_create(struct ivi_shell_setting *dest, |
Pekka Paalanen | 8a00525 | 2015-03-20 15:53:53 +0200 | [diff] [blame] | 385 | struct weston_compositor *compositor, |
| 386 | int *argc, char *argv[]) |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 387 | { |
| 388 | int result = 0; |
| 389 | struct weston_config *config = compositor->config; |
| 390 | struct weston_config_section *section; |
| 391 | |
Pekka Paalanen | 8a00525 | 2015-03-20 15:53:53 +0200 | [diff] [blame] | 392 | const struct weston_option ivi_shell_options[] = { |
| 393 | { WESTON_OPTION_STRING, "ivi-module", 0, &dest->ivi_module }, |
| 394 | }; |
| 395 | |
| 396 | parse_options(ivi_shell_options, ARRAY_LENGTH(ivi_shell_options), |
| 397 | argc, argv); |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 398 | |
| 399 | section = weston_config_get_section(config, "ivi-shell", NULL, NULL); |
| 400 | |
Pekka Paalanen | 8a00525 | 2015-03-20 15:53:53 +0200 | [diff] [blame] | 401 | if (!dest->ivi_module && |
| 402 | weston_config_section_get_string(section, "ivi-module", |
| 403 | &dest->ivi_module, NULL) < 0) { |
| 404 | weston_log("Error: ivi-shell: No ivi-module set\n"); |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 405 | result = -1; |
| 406 | } |
| 407 | |
Pekka Paalanen | e35b223 | 2015-02-19 17:08:44 +0200 | [diff] [blame] | 408 | weston_config_section_get_bool(section, "developermode", |
| 409 | &dest->developermode, 0); |
| 410 | |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 411 | return result; |
| 412 | } |
| 413 | |
| 414 | /* |
| 415 | * Initialization of ivi-shell. |
| 416 | */ |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 417 | WL_EXPORT int |
| 418 | module_init(struct weston_compositor *compositor, |
| 419 | int *argc, char *argv[]) |
| 420 | { |
| 421 | struct ivi_shell *shell; |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 422 | struct ivi_shell_setting setting = { }; |
Pekka Paalanen | e35b223 | 2015-02-19 17:08:44 +0200 | [diff] [blame] | 423 | int retval = -1; |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 424 | |
| 425 | shell = zalloc(sizeof *shell); |
| 426 | if (shell == NULL) |
| 427 | return -1; |
| 428 | |
Pekka Paalanen | 8a00525 | 2015-03-20 15:53:53 +0200 | [diff] [blame] | 429 | if (ivi_shell_setting_create(&setting, compositor, argc, argv) != 0) |
Pekka Paalanen | e35b223 | 2015-02-19 17:08:44 +0200 | [diff] [blame] | 430 | return -1; |
| 431 | |
| 432 | init_ivi_shell(compositor, shell, &setting); |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 433 | |
| 434 | shell->destroy_listener.notify = shell_destroy; |
| 435 | wl_signal_add(&compositor->destroy_signal, &shell->destroy_listener); |
| 436 | |
Nobuhiko Tanibata | 0038b73 | 2014-11-27 13:25:34 +0900 | [diff] [blame] | 437 | if (input_panel_setup(shell) < 0) |
Pekka Paalanen | e35b223 | 2015-02-19 17:08:44 +0200 | [diff] [blame] | 438 | goto out_settings; |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 439 | |
Murray Calavera | 9a51cd7 | 2015-06-10 21:16:02 +0000 | [diff] [blame] | 440 | if (text_backend_init(compositor) < 0) |
| 441 | goto out_settings; |
| 442 | |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 443 | if (wl_global_create(compositor->wl_display, |
| 444 | &ivi_application_interface, 1, |
| 445 | shell, bind_ivi_application) == NULL) |
Pekka Paalanen | e35b223 | 2015-02-19 17:08:44 +0200 | [diff] [blame] | 446 | goto out_settings; |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 447 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 448 | ivi_layout_init_with_compositor(compositor); |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 449 | |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 450 | /* Call module_init of ivi-modules which are defined in weston.ini */ |
Pekka Paalanen | e35b223 | 2015-02-19 17:08:44 +0200 | [diff] [blame] | 451 | if (load_controller_modules(compositor, setting.ivi_module, |
| 452 | argc, argv) < 0) |
| 453 | goto out_settings; |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 454 | |
Pekka Paalanen | e35b223 | 2015-02-19 17:08:44 +0200 | [diff] [blame] | 455 | retval = 0; |
| 456 | |
| 457 | out_settings: |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 458 | free(setting.ivi_module); |
Pekka Paalanen | e35b223 | 2015-02-19 17:08:44 +0200 | [diff] [blame] | 459 | |
| 460 | return retval; |
Nobuhiko Tanibata | 487adc4 | 2014-11-27 13:22:37 +0900 | [diff] [blame] | 461 | } |