1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c82136e..eeed7a6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,6 +35,7 @@ add_subdirectory(ivi-layermanagement-api/ilmClient)
add_subdirectory(ivi-layermanagement-api/ilmControl)
add_subdirectory(ivi-layermanagement-api/test)
add_subdirectory(ivi-layermanagement-examples)
+add_subdirectory(id-agent-modules/simple-id-agent)
if(WITH_ILM_INPUT)
add_subdirectory(ivi-input-api/ilmInput)
diff --git a/id-agent-modules/simple-id-agent/CMakeLists.txt b/id-agent-modules/simple-id-agent/CMakeLists.txt
new file mode 100644
index 0000000..8290722
--- /dev/null
+++ b/id-agent-modules/simple-id-agent/CMakeLists.txt
@@ -0,0 +1,72 @@
+############################################################################
+#
+# Copyright (C) 2013 DENSO CORPORATION
+# Copyright 2014 BMW Car IT GmbH
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+############################################################################
+
+cmake_minimum_required (VERSION 2.6)
+
+project(simple-id-agent)
+
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(WAYLAND_SERVER wayland-server>=1.13.0 REQUIRED)
+pkg_check_modules(WESTON weston>=2.0.0 REQUIRED)
+pkg_check_modules(PIXMAN pixman-1 REQUIRED)
+
+find_package(Threads REQUIRED)
+
+GET_TARGET_PROPERTY(IVI_EXTENSION_INCLUDE_DIRS ivi-extension-protocol INCLUDE_DIRECTORIES)
+
+include_directories(
+ src
+ ${IVI_EXTENSION_INCLUDE_DIRS}
+ ${WAYLAND_SERVER_INCLUDE_DIRS}
+ ${WESTON_INCLUDE_DIRS}
+ ${PIXMAN_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${WAYLAND_SERVER_LIBRARY_DIRS}
+ ${PIXMAN_LIBRARY_DIRS}
+)
+
+add_library(${PROJECT_NAME} MODULE
+ src/simple-id-agent.c
+)
+
+set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
+
+add_dependencies(${PROJECT_NAME}
+ ivi-extension-protocol
+ ${WAYLAND_SERVER_LIBRARIES}
+ ${PIXMAN_LIBRARIES}
+)
+
+set(LIBS
+ ${LIBS}
+ ivi-extension-protocol
+ ${WAYLAND_SERVER_LIBRARIES}
+)
+
+set(CMAKE_C_LDFLAGS "-module -avoid-version")
+
+target_link_libraries(${PROJECT_NAME} ${LIBS})
+
+install (
+ TARGETS ${PROJECT_NAME}
+ LIBRARY DESTINATION lib${LIB_SUFFIX}/weston
+)
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
new file mode 100644
index 0000000..3c9e989
--- /dev/null
+++ b/id-agent-modules/simple-id-agent/src/simple-id-agent.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2017 Advanced Driver Information Technology Joint Venture GmbH
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+
+#include <weston.h>
+#include <weston/ivi-layout-export.h>
+
+struct ivi_id_agent
+{
+ uint32_t default_id_offset;
+ uint32_t last_assigned_id;
+ struct weston_compositor *compositor;
+ const struct ivi_layout_interface *interface;
+ struct wl_listener desktop_surface_configured;
+};
+
+static void
+desktop_surface_event_configure(struct wl_listener *listener,
+ void *data)
+{
+ struct ivi_id_agent *ida = wl_container_of(listener, ida,
+ desktop_surface_configured);
+ struct ivi_layout_surface *layout_surface =
+ (struct ivi_layout_surface *) data;
+ uint32_t tmp_id;
+
+ tmp_id = ++ida->last_assigned_id;
+
+ /* Find an unused id */
+ while(ida->interface->get_surface_from_id(tmp_id)) {
+ weston_log("simple-id-agent: surface id: %d is already used\n", tmp_id);
+ tmp_id++;
+ }
+
+ ida->last_assigned_id = tmp_id;
+
+ if (ida->interface->surface_set_id(layout_surface, ida->last_assigned_id) != 0)
+ weston_log("simple-id-agent: failed to set surface id :%d\n", ida->last_assigned_id);
+}
+
+static void
+deinit(struct ivi_id_agent *ida)
+{
+ wl_list_remove(&ida->desktop_surface_configured.link);
+ free(ida);
+}
+
+static int32_t
+read_config(struct ivi_id_agent *ida)
+{
+ struct weston_config *config = NULL;
+ struct weston_config_section *section = NULL;
+ const char *name = NULL;
+
+ config = wet_get_config(ida->compositor);
+ if (!config)
+ return -1;
+
+ section = weston_config_get_section(config, "id-agent", NULL, NULL);
+
+ if (section) {
+
+ weston_config_section_get_uint(section, "default-id-offset",
+ &ida->default_id_offset, 0);
+
+ } else {
+ ida->default_id_offset = 0;
+ }
+
+ return 0;
+}
+
+WL_EXPORT int32_t
+id_agent_module_init(struct weston_compositor *ec,
+ const struct ivi_layout_interface *interface,
+ size_t interface_version)
+{
+ struct ivi_id_agent *ida;
+
+ ida = calloc(1, sizeof *ida);
+ if (ida == NULL) {
+ weston_log("failed to allocate ivi_id_agent\n");
+ return -1;
+ }
+
+ ida->compositor = ec;
+ ida->interface = interface;
+ ida->desktop_surface_configured.notify = desktop_surface_event_configure;
+ ida->interface->add_listener_configure_desktop_surface(&ida->desktop_surface_configured);
+
+ if(read_config(ida) != 0) {
+ deinit(ida);
+ return -1;
+ }
+
+ ida->last_assigned_id = ida->default_id_offset;
+
+ weston_log("id_agent_module_init: success\n");
+
+ return 0;
+}
diff --git a/id-agent-modules/simple-id-agent/weston.ini.in b/id-agent-modules/simple-id-agent/weston.ini.in
new file mode 100644
index 0000000..b5e5fa1
--- /dev/null
+++ b/id-agent-modules/simple-id-agent/weston.ini.in
@@ -0,0 +1,11 @@
+[core]
+shell=ivi-shell.so
+require-input=false
+
+[ivi-shell]
+ivi-module=ivi-controller.so
+ivi-input-module=ivi-input-controller.so
+id-agent-module=simple-id-agent.so
+
+[id-agent]
+default-id-offset=10
diff --git a/weston-ivi-shell/src/ivi-controller.c b/weston-ivi-shell/src/ivi-controller.c
index 6d95c88..5e61e76 100644
--- a/weston-ivi-shell/src/ivi-controller.c
+++ b/weston-ivi-shell/src/ivi-controller.c
@@ -2164,6 +2164,40 @@ load_input_module(struct ivishell *shell)
return 0;
}
+static int load_id_agent_module(struct weston_compositor *ec,
+ const struct ivi_layout_interface *interface,
+ size_t interface_version)
+{
+ struct weston_config *config = wet_get_config(ec);
+ struct weston_config_section *section;
+ char *id_agent_module = NULL;
+
+ int (*id_agent_module_init)(struct weston_compositor *ec,
+ const struct ivi_layout_interface *interface,
+ size_t interface_version);
+
+ section = weston_config_get_section(config, "ivi-shell", NULL, NULL);
+
+ if (weston_config_section_get_string(section, "id-agent-module",
+ &id_agent_module, NULL) < 0) {
+ weston_log("ivi-controller: No id-agent-module set\n");
+ return 0;
+ }
+
+ id_agent_module_init = wet_load_module_entrypoint(id_agent_module, "id_agent_module_init");
+ if (!id_agent_module_init)
+ return -1;
+
+ if (id_agent_module_init(ec, interface,
+ sizeof(struct ivi_layout_interface)) != 0) {
+ weston_log("ivi-controller: Initialization of id agent module fails\n");
+ return -1;
+ }
+
+ free(id_agent_module);
+ return 0;
+}
+
static void
launch_client_process(void *data)
{
@@ -2229,6 +2263,11 @@ controller_module_init(struct weston_compositor *compositor,
return -1;
}
+ if (load_id_agent_module(compositor, interface, interface_version) < 0) {
+ free(shell);
+ return -1;
+ }
+
if (shell->bkgnd_surface_id && shell->ivi_client_name) {
loop = wl_display_get_event_loop(compositor->wl_display);
wl_event_loop_add_idle(loop, launch_client_process, shell);
|