3 .../EGLWLMockNavigation/src/OpenGLES2App.cpp | 7 +-
4 weston-ivi-shell/src/ivi-controller-interface.h | 19 +
5 wl-shell-emulator/CMakeLists.txt | 69 ++++
6 wl-shell-emulator/README | 21 ++
7 wl-shell-emulator/src/wl-shell-emulator.c | 394 +++++++++++++++++++++
8 6 files changed, 509 insertions(+), 2 deletions(-)
9 create mode 100644 wl-shell-emulator/CMakeLists.txt
10 create mode 100644 wl-shell-emulator/README
11 create mode 100644 wl-shell-emulator/src/wl-shell-emulator.c
13 diff --git a/CMakeLists.txt b/CMakeLists.txt
14 index a75390f..3610fa9 100644
17 @@ -42,6 +42,7 @@ if(WITH_ILM_INPUT)
18 add_subdirectory(ivi-input-controller)
21 +add_subdirectory(wl-shell-emulator)
23 #=============================================================================================
24 # generate all documents
25 diff --git a/ivi-layermanagement-examples/EGLWLMockNavigation/src/OpenGLES2App.cpp b/ivi-layermanagement-examples/EGLWLMockNavigation/src/OpenGLES2App.cpp
26 index 2e65864..8b7e0d1 100644
27 --- a/ivi-layermanagement-examples/EGLWLMockNavigation/src/OpenGLES2App.cpp
28 +++ b/ivi-layermanagement-examples/EGLWLMockNavigation/src/OpenGLES2App.cpp
29 @@ -126,8 +126,11 @@ OpenGLES2App::OpenGLES2App(float fps, float animationSpeed, SurfaceConfiguration
30 createWLContext(config);
33 - ilmClient_init((t_ilm_nativedisplay)m_wlContextStruct.wlDisplay);
34 - setupLayerMangement(config);
35 + if (m_wlContextStruct.wlShell == NULL)
37 + ilmClient_init((t_ilm_nativedisplay)m_wlContextStruct.wlDisplay);
38 + setupLayerMangement(config);
43 diff --git a/weston-ivi-shell/src/ivi-controller-interface.h b/weston-ivi-shell/src/ivi-controller-interface.h
44 index cdafcc9..fd18009 100644
45 --- a/weston-ivi-shell/src/ivi-controller-interface.h
46 +++ b/weston-ivi-shell/src/ivi-controller-interface.h
47 @@ -66,6 +66,25 @@ struct ivi_controller_interface {
48 int32_t (*commit_changes)(void);
51 + * \brief Creates an ivi_layout_surface.
53 + * \return IVI_SUCCEEDED if the method call was successful
54 + * \return IVI_FAILED if the method call was failed
56 + struct ivi_layout_surface* (*surface_create)(
57 + struct weston_surface *wl_surface,
58 + uint32_t id_surface);
61 + * \brief Configure an ivi_layout_surface
63 + * \return IVI_SUCCEEDED if the method call was successful
64 + * \return IVI_FAILED if the method call was failed
66 + void (*surface_configure)(struct ivi_layout_surface *ivisurf,
67 + int32_t width, int32_t height);
70 * surface controller interface
73 diff --git a/wl-shell-emulator/CMakeLists.txt b/wl-shell-emulator/CMakeLists.txt
75 index 0000000..2678098
77 +++ b/wl-shell-emulator/CMakeLists.txt
79 +############################################################################
81 +# Copyright (C) 2015 Advanced Driver Information Technology Joint Venture GmbH
84 +# Licensed under the Apache License, Version 2.0 (the "License");
85 +# you may not use this file except in compliance with the License.
86 +# You may obtain a copy of the License at
88 +# http://www.apache.org/licenses/LICENSE-2.0
90 +# Unless required by applicable law or agreed to in writing, software
91 +# distributed under the License is distributed on an "AS IS" BASIS,
92 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
93 +# See the License for the specific language governing permissions and
94 +# limitations under the License.
96 +############################################################################
98 +cmake_minimum_required (VERSION 2.6)
100 +project(wl-shell-emulator)
102 +find_package(PkgConfig REQUIRED)
103 +pkg_check_modules(WAYLAND_SERVER wayland-server REQUIRED)
104 +pkg_check_modules(WESTON weston REQUIRED)
106 +GET_TARGET_PROPERTY(IVI_EXTENSION_INCLUDE_DIRS ivi-extension-protocol INCLUDE_DIRECTORIES)
107 +GET_TARGET_PROPERTY(IVI_CONTROLLER_INCLUDE_DIRS ivi-controller INCLUDE_DIRECTORIES)
109 +include_directories(
111 + ${IVI_EXTENSION_INCLUDE_DIRS}
112 + ${IVI_CONTROLLER_INCLUDE_DIRS}
113 + ${WAYLAND_SERVER_INCLUDE_DIRS}
114 + ${WESTON_INCLUDE_DIRS}
115 + ${WESTON_INCLUDE_DIRS}/weston
119 + ${WAYLAND_SERVER_LIBRARY_DIRS}
123 +add_library(${PROJECT_NAME} MODULE
124 + src/wl-shell-emulator.c
127 +set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
129 +add_dependencies(${PROJECT_NAME}
130 + ivi-extension-protocol
131 + ${WAYLAND_SERVER_LIBRARIES}
136 + ivi-extension-protocol
137 + ${WAYLAND_SERVER_LIBRARIES}
140 +set(CMAKE_C_LDFLAGS "-module -avoid-version")
142 +target_link_libraries(${PROJECT_NAME} ${LIBS})
145 + TARGETS ${PROJECT_NAME}
146 + LIBRARY DESTINATION lib/weston
148 diff --git a/wl-shell-emulator/README b/wl-shell-emulator/README
150 index 0000000..6eebc04
152 +++ b/wl-shell-emulator/README
154 +This directory contains the wl-shell-emulator module.
155 +To use this, add it to the "ivi-module" entry in your weston.ini.
156 +Multiple modules may be specified in the same entry by separating
157 +the modules with commas.
158 +Additionally, the basement of surface-id is indentified by weston.ini
159 +at "surface-id-for-wl-shell" entry. wl-shell-emulator will increment
160 +surface-id per wl-shell-surface creation.
162 +- Sample of weston.ini
167 +ivi-module=ivi-controller.so,wl-shell-emulator.so
168 +surface-id-for-wl-shell-app=0x30000000
171 +ivi-layermanagement-examples/layer-add-surfaces is easy
172 +for you to try wl-shell-emulator. When you invoke wl_shell
173 +application. layer-add-surfaces can add the ivi-surface to a layer
174 +and set visibility for it.
175 diff --git a/wl-shell-emulator/src/wl-shell-emulator.c b/wl-shell-emulator/src/wl-shell-emulator.c
177 index 0000000..274b192
179 +++ b/wl-shell-emulator/src/wl-shell-emulator.c
182 + * Copyright (C) 2015 Advanced Driver Information Technology Joint Venture GmbH
184 + * Permission to use, copy, modify, distribute, and sell this software and
185 + * its documentation for any purpose is hereby granted without fee, provided
186 + * that the above copyright notice appear in all copies and that both that
187 + * copyright notice and this permission notice appear in supporting
188 + * documentation, and that the name of the copyright holders not be used in
189 + * advertising or publicity pertaining to distribution of the software
190 + * without specific, written prior permission. The copyright holders make
191 + * no representations about the suitability of this software for any
192 + * purpose. It is provided "as is" without express or implied warranty.
194 + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
195 + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
196 + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
197 + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
198 + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
199 + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
200 + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
207 +#include <weston/compositor.h>
209 +#include "ivi-layout-export.h"
210 +#include "ivi-controller-interface.h"
212 +#ifndef container_of
213 +#define container_of(ptr, type, member) ({ \
214 + const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
215 + (type *)( (char *)__mptr - offsetof(type,member) );})
218 +#define DEFAULT_SURFACE_ID_FOR_WL_SHELL_APP 0x80000000
220 +struct emulator_surface {
221 + struct wl_resource* resource;
222 + struct emulator_context *context;
223 + struct ivi_layout_surface *layout_surface;
225 + struct weston_surface *surface;
226 + struct wl_listener surface_destroy_listener;
228 + uint32_t id_surface;
229 + int32_t last_width;
230 + int32_t last_height;
232 + struct wl_list link;
235 +struct emulator_controller {
236 + struct wl_list link;
237 + struct wl_resource *resource;
238 + struct wl_client *client;
240 + struct emulator_context *emulator_context;
243 +struct emulator_context {
244 + struct wl_list controller_list;
245 + struct wl_list surface_list;
246 + struct weston_compositor *compositor;
247 + const struct ivi_controller_interface *ivi_controller_interface;
249 + uint32_t id_surface_base;
253 +emulator_surface_pong(struct wl_client *client,
254 + struct wl_resource *resource, uint32_t serial)
260 +emulator_surface_move(struct wl_client *client, struct wl_resource *resource,
261 + struct wl_resource *seat_resource, uint32_t serial)
263 +/*Use ivi_controller_interface to implement*/
267 +emulator_surface_resize(struct wl_client *client, struct wl_resource *resource,
268 + struct wl_resource *seat_resource, uint32_t serial,
271 +/*Use ivi_controller_interface to implement*/
275 +emulator_surface_set_toplevel(struct wl_client *client,
276 + struct wl_resource *resource)
278 +/*Use ivi_controller_interface to implement*/
282 +emulator_surface_set_transient(struct wl_client *client,
283 + struct wl_resource *resource,
284 + struct wl_resource *parent_resource,
285 + int x, int y, uint32_t flags)
287 +/*Use ivi_controller_interface to implement*/
291 +emulator_surface_set_fullscreen(struct wl_client *client,
292 + struct wl_resource *resource,
294 + uint32_t framerate,
295 + struct wl_resource *output_resource)
297 +/*Use ivi_controller_interface to implement*/
301 +emulator_surface_set_popup(struct wl_client *client,
302 + struct wl_resource *resource,
303 + struct wl_resource *seat_resource,
305 + struct wl_resource *parent_resource,
306 + int32_t x, int32_t y, uint32_t flags)
312 +emulator_surface_set_maximized(struct wl_client *client,
313 + struct wl_resource *resource,
314 + struct wl_resource *output_resource)
320 +emulator_surface_set_title(struct wl_client *client,
321 + struct wl_resource *resource, const char *title)
327 +emulator_surface_set_class(struct wl_client *client,
328 + struct wl_resource *resource, const char *class)
333 +static const struct wl_shell_surface_interface shell_surface_implementation = {
334 + emulator_surface_pong,
335 + emulator_surface_move,
336 + emulator_surface_resize,
337 + emulator_surface_set_toplevel,
338 + emulator_surface_set_transient,
339 + emulator_surface_set_fullscreen,
340 + emulator_surface_set_popup,
341 + emulator_surface_set_maximized,
342 + emulator_surface_set_title,
343 + emulator_surface_set_class
346 +/* Gets called through the weston_surface destroy signal. */
348 +emulator_handle_surface_destroy(struct wl_listener *listener, void *data)
350 + struct emulator_surface *emulator_surface =
351 + container_of(listener, struct emulator_surface,
352 + surface_destroy_listener);
354 + assert(emulator_surface != NULL);
356 + if (emulator_surface->surface!=NULL) {
357 + emulator_surface->surface->configure = NULL;
358 + emulator_surface->surface->configure_private = NULL;
359 + emulator_surface->surface = NULL;
362 + wl_list_remove(&emulator_surface->surface_destroy_listener.link);
363 + wl_list_remove(&emulator_surface->link);
365 + if (emulator_surface->resource != NULL) {
366 + wl_resource_set_user_data(emulator_surface->resource, NULL);
367 + emulator_surface->resource = NULL;
369 + free(emulator_surface);
373 +emulator_surface_configure(struct weston_surface *surface,
374 + int32_t sx, int32_t sy)
376 + struct emulator_surface *surf = surface->configure_private;
377 + struct emulator_context *ctx;
379 + if ((surf == NULL) ||
380 + (surf->layout_surface == NULL)) {
384 + if ((surf->last_width != surface->width) ||
385 + (surf->last_height != surface->height)) {
387 + surf->last_width = surface->width;
388 + surf->last_height = surface->height;
390 + ctx = surf->context;
391 + ctx->ivi_controller_interface->surface_configure(surf->layout_surface,
398 + * The ivi_surface wl_resource destructor.
400 + * Gets called via ivi_surface.destroy request or automatic wl_client clean-up.
403 +shell_destroy_shell_surface(struct wl_resource *resource)
405 + struct emulator_surface *surf = wl_resource_get_user_data(resource);
406 + if (surf != NULL) {
407 + surf->resource = NULL;
412 +emulator_get_shell_surface(struct wl_client *client, struct wl_resource *resource,
413 + uint32_t id, struct wl_resource *surface_resource)
415 + struct emulator_controller *controller = wl_resource_get_user_data(resource);
416 + struct emulator_context * context = controller->emulator_context;
417 + struct emulator_surface *emulator_surface;
418 + struct weston_surface *surface;
419 + struct ivi_layout_surface *layout_surface;
420 + struct wl_resource *res;
421 + const struct ivi_controller_interface *interface =
422 + context->ivi_controller_interface;
424 + surface = wl_resource_get_user_data(surface_resource);
426 + layout_surface = interface->surface_create(surface, context->id_surface_base);
428 + if (!layout_surface) {
429 + wl_resource_post_no_memory(surface_resource);
433 + emulator_surface = zalloc(sizeof *emulator_surface);
434 + if (emulator_surface == NULL) {
435 + wl_resource_post_no_memory(resource);
439 + emulator_surface->layout_surface = layout_surface;
440 + emulator_surface->id_surface = context->id_surface_base;
441 + emulator_surface->last_width = 0;
442 + emulator_surface->last_height = 0;
444 + wl_list_init(&emulator_surface->link);
445 + wl_list_insert(&context->surface_list, &emulator_surface->link);
447 + emulator_surface->context = context;
448 + ++(context->id_surface_base);
450 + /** The following code relies on wl_surface destruction triggering
451 + * immediateweston_surface destruction
453 + emulator_surface->surface_destroy_listener.notify = emulator_handle_surface_destroy;
454 + wl_signal_add(&surface->destroy_signal,
455 + &emulator_surface->surface_destroy_listener);
457 + emulator_surface->surface = surface;
458 + surface->configure = emulator_surface_configure;
459 + surface->configure_private = emulator_surface;
461 + res = wl_resource_create(client, &wl_shell_surface_interface, 1, id);
463 + wl_client_post_no_memory(client);
467 + emulator_surface->resource = res;
469 + wl_resource_set_implementation(res, &shell_surface_implementation,
470 + emulator_surface, shell_destroy_shell_surface);
472 +static const struct wl_shell_interface shell_implementation = {
473 + emulator_get_shell_surface
477 +unbind_resource_controller(struct wl_resource *resource)
479 + struct emulator_controller *controller = wl_resource_get_user_data(resource);
481 + wl_list_remove(&controller->link);
487 +bind_shell_implementation(struct wl_client *client, void *data,
488 + uint32_t version, uint32_t id)
490 + struct emulator_context *ctx = data;
491 + struct emulator_controller *controller;
492 + controller = calloc(1, sizeof *controller);
493 + if (controller == NULL) {
494 + weston_log("%s: Failed to allocate memory for controller\n",
499 + controller->emulator_context = ctx;
500 + controller->resource =
501 + wl_resource_create(client, &wl_shell_interface, 1, id);
502 + wl_resource_set_implementation(controller->resource, &shell_implementation,
503 + controller, unbind_resource_controller);
505 + controller->client = client;
506 + controller->id = id;
508 + wl_list_insert(&ctx->controller_list, &controller->link);
511 +static struct emulator_context *
512 +create_emulator_context(struct weston_compositor *ec,
513 + const struct ivi_controller_interface *interface)
515 + struct emulator_context *ctx = NULL;
516 + ctx = calloc(1, sizeof *ctx);
518 + weston_log("%s: Failed to allocate memory for input context\n",
523 + memset(ctx, 0, sizeof *ctx);
525 + ctx->compositor = ec;
526 + ctx->ivi_controller_interface = interface;
527 + wl_list_init(&ctx->controller_list);
528 + wl_list_init(&ctx->surface_list);
534 +setup_emulator_config(struct emulator_context *ctx, int *argc, char *argv[])
536 + struct weston_config_section *section;
538 + section = weston_config_get_section(ctx->compositor->config, "ivi-shell",
542 + weston_config_section_get_uint(section, "surface-id-for-wl-shell-app",
543 + &ctx->id_surface_base,
544 + DEFAULT_SURFACE_ID_FOR_WL_SHELL_APP);
546 + weston_log("Based surface ID for wl_shell application: %u (0x%x)\n",
547 + ctx->id_surface_base, ctx->id_surface_base);
554 +controller_module_init(struct weston_compositor *ec, int* argc, char *argv[],
555 + const struct ivi_controller_interface *interface,
556 + size_t interface_version)
558 + struct emulator_context *ctx = create_emulator_context(ec, interface);
560 + weston_log("%s: Failed to create input context\n", __FUNCTION__);
564 + if (setup_emulator_config(ctx, argc, argv)) {
568 + if (wl_global_create(ec->wl_display, &wl_shell_interface, 1,
569 + ctx, bind_shell_implementation) == NULL) {
572 + weston_log("wl-shell-emulator module loaded successfully!\n");