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-modules/ivi-input-controller)
21 +add_subdirectory(wl-shell-emulator)
23 #=============================================================================================
24 # generate all documents
25 diff --git a/wl-shell-emulator/CMakeLists.txt b/wl-shell-emulator/CMakeLists.txt
27 index 0000000..2678098
29 +++ b/wl-shell-emulator/CMakeLists.txt
31 +############################################################################
33 +# Copyright (C) 2015 Advanced Driver Information Technology Joint Venture GmbH
36 +# Licensed under the Apache License, Version 2.0 (the "License");
37 +# you may not use this file except in compliance with the License.
38 +# You may obtain a copy of the License at
40 +# http://www.apache.org/licenses/LICENSE-2.0
42 +# Unless required by applicable law or agreed to in writing, software
43 +# distributed under the License is distributed on an "AS IS" BASIS,
44 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45 +# See the License for the specific language governing permissions and
46 +# limitations under the License.
48 +############################################################################
50 +cmake_minimum_required (VERSION 2.6)
52 +project(wl-shell-emulator)
54 +find_package(PkgConfig REQUIRED)
55 +pkg_check_modules(WAYLAND_SERVER wayland-server REQUIRED)
56 +pkg_check_modules(WESTON weston REQUIRED)
58 +GET_TARGET_PROPERTY(IVI_EXTENSION_INCLUDE_DIRS ivi-extension-protocol INCLUDE_DIRECTORIES)
59 +GET_TARGET_PROPERTY(IVI_CONTROLLER_INCLUDE_DIRS ivi-controller INCLUDE_DIRECTORIES)
63 + ${IVI_EXTENSION_INCLUDE_DIRS}
64 + ${IVI_CONTROLLER_INCLUDE_DIRS}
65 + ${WAYLAND_SERVER_INCLUDE_DIRS}
66 + ${WESTON_INCLUDE_DIRS}
67 + ${WESTON_INCLUDE_DIRS}/weston
71 + ${WAYLAND_SERVER_LIBRARY_DIRS}
75 +add_library(${PROJECT_NAME} MODULE
76 + src/wl-shell-emulator.c
79 +set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
81 +add_dependencies(${PROJECT_NAME}
82 + ivi-extension-protocol
83 + ${WAYLAND_SERVER_LIBRARIES}
88 + ivi-extension-protocol
89 + ${WAYLAND_SERVER_LIBRARIES}
92 +set(CMAKE_C_LDFLAGS "-module -avoid-version")
94 +target_link_libraries(${PROJECT_NAME} ${LIBS})
97 + TARGETS ${PROJECT_NAME}
98 + LIBRARY DESTINATION lib/weston
100 diff --git a/wl-shell-emulator/README b/wl-shell-emulator/README
102 index 0000000..6eebc04
104 +++ b/wl-shell-emulator/README
106 +This directory contains the wl-shell-emulator module.
107 +To use this, add it to the "ivi-module" entry in your weston.ini.
108 +Multiple modules may be specified in the same entry by separating
109 +the modules with commas.
110 +Additionally, the basement of surface-id is indentified by weston.ini
111 +at "surface-id-for-wl-shell" entry. wl-shell-emulator will increment
112 +surface-id per wl-shell-surface creation.
114 +- Sample of weston.ini
119 +ivi-module=ivi-controller.so,wl-shell-emulator.so
120 +surface-id-for-wl-shell-app=0x30000000
123 +ivi-layermanagement-examples/layer-add-surfaces is easy
124 +for you to try wl-shell-emulator. When you invoke wl_shell
125 +application. layer-add-surfaces can add the ivi-surface to a layer
126 +and set visibility for it.
127 diff --git a/wl-shell-emulator/src/wl-shell-emulator.c b/wl-shell-emulator/src/wl-shell-emulator.c
129 index 0000000..274b192
131 +++ b/wl-shell-emulator/src/wl-shell-emulator.c
134 + * Copyright (C) 2015 Advanced Driver Information Technology Joint Venture GmbH
136 + * Permission to use, copy, modify, distribute, and sell this software and
137 + * its documentation for any purpose is hereby granted without fee, provided
138 + * that the above copyright notice appear in all copies and that both that
139 + * copyright notice and this permission notice appear in supporting
140 + * documentation, and that the name of the copyright holders not be used in
141 + * advertising or publicity pertaining to distribution of the software
142 + * without specific, written prior permission. The copyright holders make
143 + * no representations about the suitability of this software for any
144 + * purpose. It is provided "as is" without express or implied warranty.
146 + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
147 + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
148 + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
149 + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
150 + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
151 + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
152 + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
159 +#include <weston/compositor.h>
161 +#include "weston/ivi-layout-export.h"
164 +#ifndef container_of
165 +#define container_of(ptr, type, member) ({ \
166 + const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
167 + (type *)( (char *)__mptr - offsetof(type,member) );})
170 +#define DEFAULT_SURFACE_ID_FOR_WL_SHELL_APP 0x80000000
172 +struct emulator_surface {
173 + struct wl_resource* resource;
174 + struct emulator_context *context;
175 + struct ivi_layout_surface *layout_surface;
177 + struct weston_surface *surface;
178 + struct wl_listener surface_destroy_listener;
180 + uint32_t id_surface;
181 + int32_t last_width;
182 + int32_t last_height;
184 + struct wl_list link;
187 +struct emulator_controller {
188 + struct wl_list link;
189 + struct wl_resource *resource;
190 + struct wl_client *client;
192 + struct emulator_context *emulator_context;
195 +struct emulator_context {
196 + struct wl_list controller_list;
197 + struct wl_list surface_list;
198 + struct weston_compositor *compositor;
199 + const struct ivi_layout_interface *ivi_layout_interface;
201 + uint32_t id_surface_base;
205 +emulator_surface_pong(struct wl_client *client,
206 + struct wl_resource *resource, uint32_t serial)
212 +emulator_surface_move(struct wl_client *client, struct wl_resource *resource,
213 + struct wl_resource *seat_resource, uint32_t serial)
215 +/*Use ivi_layout_interface to implement*/
219 +emulator_surface_resize(struct wl_client *client, struct wl_resource *resource,
220 + struct wl_resource *seat_resource, uint32_t serial,
223 +/*Use ivi_layout_interface to implement*/
227 +emulator_surface_set_toplevel(struct wl_client *client,
228 + struct wl_resource *resource)
230 +/*Use ivi_layout_interface to implement*/
234 +emulator_surface_set_transient(struct wl_client *client,
235 + struct wl_resource *resource,
236 + struct wl_resource *parent_resource,
237 + int x, int y, uint32_t flags)
239 +/*Use ivi_layout_interface to implement*/
243 +emulator_surface_set_fullscreen(struct wl_client *client,
244 + struct wl_resource *resource,
246 + uint32_t framerate,
247 + struct wl_resource *output_resource)
249 +/*Use ivi_layout_interface to implement*/
253 +emulator_surface_set_popup(struct wl_client *client,
254 + struct wl_resource *resource,
255 + struct wl_resource *seat_resource,
257 + struct wl_resource *parent_resource,
258 + int32_t x, int32_t y, uint32_t flags)
264 +emulator_surface_set_maximized(struct wl_client *client,
265 + struct wl_resource *resource,
266 + struct wl_resource *output_resource)
272 +emulator_surface_set_title(struct wl_client *client,
273 + struct wl_resource *resource, const char *title)
279 +emulator_surface_set_class(struct wl_client *client,
280 + struct wl_resource *resource, const char *class)
285 +static const struct wl_shell_surface_interface shell_surface_implementation = {
286 + emulator_surface_pong,
287 + emulator_surface_move,
288 + emulator_surface_resize,
289 + emulator_surface_set_toplevel,
290 + emulator_surface_set_transient,
291 + emulator_surface_set_fullscreen,
292 + emulator_surface_set_popup,
293 + emulator_surface_set_maximized,
294 + emulator_surface_set_title,
295 + emulator_surface_set_class
298 +/* Gets called through the weston_surface destroy signal. */
300 +emulator_handle_surface_destroy(struct wl_listener *listener, void *data)
302 + struct emulator_surface *emulator_surface =
303 + container_of(listener, struct emulator_surface,
304 + surface_destroy_listener);
306 + assert(emulator_surface != NULL);
308 + if (emulator_surface->surface!=NULL) {
309 + emulator_surface->surface->configure = NULL;
310 + emulator_surface->surface->configure_private = NULL;
311 + emulator_surface->surface = NULL;
314 + wl_list_remove(&emulator_surface->surface_destroy_listener.link);
315 + wl_list_remove(&emulator_surface->link);
317 + if (emulator_surface->resource != NULL) {
318 + wl_resource_set_user_data(emulator_surface->resource, NULL);
319 + emulator_surface->resource = NULL;
321 + free(emulator_surface);
325 +emulator_surface_configure(struct weston_surface *surface,
326 + int32_t sx, int32_t sy)
328 + struct emulator_surface *surf = surface->configure_private;
329 + struct emulator_context *ctx;
331 + if ((surf == NULL) ||
332 + (surf->layout_surface == NULL)) {
336 + if ((surf->last_width != surface->width) ||
337 + (surf->last_height != surface->height)) {
339 + surf->last_width = surface->width;
340 + surf->last_height = surface->height;
342 + ctx = surf->context;
343 + ctx->ivi_layout_interface->surface_configure(surf->layout_surface,
350 + * The ivi_surface wl_resource destructor.
352 + * Gets called via ivi_surface.destroy request or automatic wl_client clean-up.
355 +shell_destroy_shell_surface(struct wl_resource *resource)
357 + struct emulator_surface *surf = wl_resource_get_user_data(resource);
358 + if (surf != NULL) {
359 + surf->resource = NULL;
364 +emulator_get_shell_surface(struct wl_client *client, struct wl_resource *resource,
365 + uint32_t id, struct wl_resource *surface_resource)
367 + struct emulator_controller *controller = wl_resource_get_user_data(resource);
368 + struct emulator_context * context = controller->emulator_context;
369 + struct emulator_surface *emulator_surface;
370 + struct weston_surface *surface;
371 + struct ivi_layout_surface *layout_surface;
372 + struct wl_resource *res;
373 + const struct ivi_layout_interface *interface =
374 + context->ivi_layout_interface;
376 + surface = wl_resource_get_user_data(surface_resource);
378 + layout_surface = interface->surface_create(surface, context->id_surface_base);
380 + if (!layout_surface) {
381 + wl_resource_post_no_memory(surface_resource);
385 + emulator_surface = zalloc(sizeof *emulator_surface);
386 + if (emulator_surface == NULL) {
387 + wl_resource_post_no_memory(resource);
391 + emulator_surface->layout_surface = layout_surface;
392 + emulator_surface->id_surface = context->id_surface_base;
393 + emulator_surface->last_width = 0;
394 + emulator_surface->last_height = 0;
396 + wl_list_init(&emulator_surface->link);
397 + wl_list_insert(&context->surface_list, &emulator_surface->link);
399 + emulator_surface->context = context;
400 + ++(context->id_surface_base);
402 + /** The following code relies on wl_surface destruction triggering
403 + * immediateweston_surface destruction
405 + emulator_surface->surface_destroy_listener.notify = emulator_handle_surface_destroy;
406 + wl_signal_add(&surface->destroy_signal,
407 + &emulator_surface->surface_destroy_listener);
409 + emulator_surface->surface = surface;
410 + surface->configure = emulator_surface_configure;
411 + surface->configure_private = emulator_surface;
413 + res = wl_resource_create(client, &wl_shell_surface_interface, 1, id);
415 + wl_client_post_no_memory(client);
419 + emulator_surface->resource = res;
421 + wl_resource_set_implementation(res, &shell_surface_implementation,
422 + emulator_surface, shell_destroy_shell_surface);
424 +static const struct wl_shell_interface shell_implementation = {
425 + emulator_get_shell_surface
429 +unbind_resource_controller(struct wl_resource *resource)
431 + struct emulator_controller *controller = wl_resource_get_user_data(resource);
433 + wl_list_remove(&controller->link);
439 +bind_shell_implementation(struct wl_client *client, void *data,
440 + uint32_t version, uint32_t id)
442 + struct emulator_context *ctx = data;
443 + struct emulator_controller *controller;
444 + controller = calloc(1, sizeof *controller);
445 + if (controller == NULL) {
446 + weston_log("%s: Failed to allocate memory for controller\n",
451 + controller->emulator_context = ctx;
452 + controller->resource =
453 + wl_resource_create(client, &wl_shell_interface, 1, id);
454 + wl_resource_set_implementation(controller->resource, &shell_implementation,
455 + controller, unbind_resource_controller);
457 + controller->client = client;
458 + controller->id = id;
460 + wl_list_insert(&ctx->controller_list, &controller->link);
463 +static struct emulator_context *
464 +create_emulator_context(struct weston_compositor *ec,
465 + const struct ivi_layout_interface *interface)
467 + struct emulator_context *ctx = NULL;
468 + ctx = calloc(1, sizeof *ctx);
470 + weston_log("%s: Failed to allocate memory for input context\n",
475 + memset(ctx, 0, sizeof *ctx);
477 + ctx->compositor = ec;
478 + ctx->ivi_layout_interface = interface;
479 + wl_list_init(&ctx->controller_list);
480 + wl_list_init(&ctx->surface_list);
486 +setup_emulator_config(struct emulator_context *ctx, int *argc, char *argv[])
488 + struct weston_config_section *section;
490 + section = weston_config_get_section(ctx->compositor->config, "ivi-shell",
494 + weston_config_section_get_uint(section, "surface-id-for-wl-shell-app",
495 + &ctx->id_surface_base,
496 + DEFAULT_SURFACE_ID_FOR_WL_SHELL_APP);
498 + weston_log("Based surface ID for wl_shell application: %u (0x%x)\n",
499 + ctx->id_surface_base, ctx->id_surface_base);
506 +controller_module_init(struct weston_compositor *ec, int* argc, char *argv[],
507 + const struct ivi_layout_interface *interface,
508 + size_t interface_version)
510 + struct emulator_context *ctx = create_emulator_context(ec, interface);
512 + weston_log("%s: Failed to create input context\n", __FUNCTION__);
516 + if (setup_emulator_config(ctx, argc, argv)) {
520 + if (wl_global_create(ec->wl_display, &wl_shell_interface, 1,
521 + ctx, bind_shell_implementation) == NULL) {
524 + weston_log("wl-shell-emulator module loaded successfully!\n");