1 diff --git a/CMakeLists.txt b/CMakeLists.txt
2 index c82136e..eeed7a6 100644
5 @@ -35,6 +35,7 @@ add_subdirectory(ivi-layermanagement-api/ilmClient)
6 add_subdirectory(ivi-layermanagement-api/ilmControl)
7 add_subdirectory(ivi-layermanagement-api/test)
8 add_subdirectory(ivi-layermanagement-examples)
9 +add_subdirectory(id-agent-modules/simple-id-agent)
12 add_subdirectory(ivi-input-api/ilmInput)
13 diff --git a/id-agent-modules/simple-id-agent/CMakeLists.txt b/id-agent-modules/simple-id-agent/CMakeLists.txt
15 index 0000000..8290722
17 +++ b/id-agent-modules/simple-id-agent/CMakeLists.txt
19 +############################################################################
21 +# Copyright (C) 2013 DENSO CORPORATION
22 +# Copyright 2014 BMW Car IT GmbH
25 +# Licensed under the Apache License, Version 2.0 (the "License");
26 +# you may not use this file except in compliance with the License.
27 +# You may obtain a copy of the License at
29 +# http://www.apache.org/licenses/LICENSE-2.0
31 +# Unless required by applicable law or agreed to in writing, software
32 +# distributed under the License is distributed on an "AS IS" BASIS,
33 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34 +# See the License for the specific language governing permissions and
35 +# limitations under the License.
37 +############################################################################
39 +cmake_minimum_required (VERSION 2.6)
41 +project(simple-id-agent)
43 +find_package(PkgConfig REQUIRED)
44 +pkg_check_modules(WAYLAND_SERVER wayland-server>=1.13.0 REQUIRED)
45 +pkg_check_modules(WESTON weston>=2.0.0 REQUIRED)
46 +pkg_check_modules(PIXMAN pixman-1 REQUIRED)
48 +find_package(Threads REQUIRED)
50 +GET_TARGET_PROPERTY(IVI_EXTENSION_INCLUDE_DIRS ivi-extension-protocol INCLUDE_DIRECTORIES)
54 + ${IVI_EXTENSION_INCLUDE_DIRS}
55 + ${WAYLAND_SERVER_INCLUDE_DIRS}
56 + ${WESTON_INCLUDE_DIRS}
57 + ${PIXMAN_INCLUDE_DIRS}
61 + ${WAYLAND_SERVER_LIBRARY_DIRS}
62 + ${PIXMAN_LIBRARY_DIRS}
65 +add_library(${PROJECT_NAME} MODULE
66 + src/simple-id-agent.c
69 +set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
71 +add_dependencies(${PROJECT_NAME}
72 + ivi-extension-protocol
73 + ${WAYLAND_SERVER_LIBRARIES}
79 + ivi-extension-protocol
80 + ${WAYLAND_SERVER_LIBRARIES}
83 +set(CMAKE_C_LDFLAGS "-module -avoid-version")
85 +target_link_libraries(${PROJECT_NAME} ${LIBS})
88 + TARGETS ${PROJECT_NAME}
89 + LIBRARY DESTINATION lib${LIB_SUFFIX}/weston
91 diff --git a/id-agent-modules/simple-id-agent/src/simple-id-agent.c b/id-agent-modules/simple-id-agent/src/simple-id-agent.c
93 index 0000000..3c9e989
95 +++ b/id-agent-modules/simple-id-agent/src/simple-id-agent.c
98 + * Copyright (C) 2017 Advanced Driver Information Technology Joint Venture GmbH
100 + * Permission to use, copy, modify, distribute, and sell this software and
101 + * its documentation for any purpose is hereby granted without fee, provided
102 + * that the above copyright notice appear in all copies and that both that
103 + * copyright notice and this permission notice appear in supporting
104 + * documentation, and that the name of the copyright holders not be used in
105 + * advertising or publicity pertaining to distribution of the software
106 + * without specific, written prior permission. The copyright holders make
107 + * no representations about the suitability of this software for any
108 + * purpose. It is provided "as is" without express or implied warranty.
110 + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
111 + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
112 + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
113 + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
114 + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
115 + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
116 + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
125 +#include <weston/ivi-layout-export.h>
129 + uint32_t default_id_offset;
130 + uint32_t last_assigned_id;
131 + struct weston_compositor *compositor;
132 + const struct ivi_layout_interface *interface;
133 + struct wl_listener desktop_surface_configured;
137 +desktop_surface_event_configure(struct wl_listener *listener,
140 + struct ivi_id_agent *ida = wl_container_of(listener, ida,
141 + desktop_surface_configured);
142 + struct ivi_layout_surface *layout_surface =
143 + (struct ivi_layout_surface *) data;
146 + tmp_id = ++ida->last_assigned_id;
148 + /* Find an unused id */
149 + while(ida->interface->get_surface_from_id(tmp_id)) {
150 + weston_log("simple-id-agent: surface id: %d is already used\n", tmp_id);
154 + ida->last_assigned_id = tmp_id;
156 + if (ida->interface->surface_set_id(layout_surface, ida->last_assigned_id) != 0)
157 + weston_log("simple-id-agent: failed to set surface id :%d\n", ida->last_assigned_id);
161 +deinit(struct ivi_id_agent *ida)
163 + wl_list_remove(&ida->desktop_surface_configured.link);
168 +read_config(struct ivi_id_agent *ida)
170 + struct weston_config *config = NULL;
171 + struct weston_config_section *section = NULL;
172 + const char *name = NULL;
174 + config = wet_get_config(ida->compositor);
178 + section = weston_config_get_section(config, "id-agent", NULL, NULL);
182 + weston_config_section_get_uint(section, "default-id-offset",
183 + &ida->default_id_offset, 0);
186 + ida->default_id_offset = 0;
193 +id_agent_module_init(struct weston_compositor *ec,
194 + const struct ivi_layout_interface *interface,
195 + size_t interface_version)
197 + struct ivi_id_agent *ida;
199 + ida = calloc(1, sizeof *ida);
201 + weston_log("failed to allocate ivi_id_agent\n");
205 + ida->compositor = ec;
206 + ida->interface = interface;
207 + ida->desktop_surface_configured.notify = desktop_surface_event_configure;
208 + ida->interface->add_listener_configure_desktop_surface(&ida->desktop_surface_configured);
210 + if(read_config(ida) != 0) {
215 + ida->last_assigned_id = ida->default_id_offset;
217 + weston_log("id_agent_module_init: success\n");
221 diff --git a/id-agent-modules/simple-id-agent/weston.ini.in b/id-agent-modules/simple-id-agent/weston.ini.in
223 index 0000000..b5e5fa1
225 +++ b/id-agent-modules/simple-id-agent/weston.ini.in
232 +ivi-module=ivi-controller.so
233 +ivi-input-module=ivi-input-controller.so
234 +id-agent-module=simple-id-agent.so
237 +default-id-offset=10
238 diff --git a/weston-ivi-shell/src/ivi-controller.c b/weston-ivi-shell/src/ivi-controller.c
239 index 6d95c88..5e61e76 100644
240 --- a/weston-ivi-shell/src/ivi-controller.c
241 +++ b/weston-ivi-shell/src/ivi-controller.c
242 @@ -2164,6 +2164,40 @@ load_input_module(struct ivishell *shell)
246 +static int load_id_agent_module(struct weston_compositor *ec,
247 + const struct ivi_layout_interface *interface,
248 + size_t interface_version)
250 + struct weston_config *config = wet_get_config(ec);
251 + struct weston_config_section *section;
252 + char *id_agent_module = NULL;
254 + int (*id_agent_module_init)(struct weston_compositor *ec,
255 + const struct ivi_layout_interface *interface,
256 + size_t interface_version);
258 + section = weston_config_get_section(config, "ivi-shell", NULL, NULL);
260 + if (weston_config_section_get_string(section, "id-agent-module",
261 + &id_agent_module, NULL) < 0) {
262 + weston_log("ivi-controller: No id-agent-module set\n");
266 + id_agent_module_init = wet_load_module_entrypoint(id_agent_module, "id_agent_module_init");
267 + if (!id_agent_module_init)
270 + if (id_agent_module_init(ec, interface,
271 + sizeof(struct ivi_layout_interface)) != 0) {
272 + weston_log("ivi-controller: Initialization of id agent module fails\n");
276 + free(id_agent_module);
281 launch_client_process(void *data)
283 @@ -2229,6 +2263,11 @@ controller_module_init(struct weston_compositor *compositor,
287 + if (load_id_agent_module(compositor, interface, interface_version) < 0) {
292 if (shell->bkgnd_surface_id && shell->ivi_client_name) {
293 loop = wl_display_get_event_loop(compositor->wl_display);
294 wl_event_loop_add_idle(loop, launch_client_process, shell);