1 From 8f67f40f7c6b6f62e094f0bdc5044793ae76b1c7 Mon Sep 17 00:00:00 2001
2 From: Emre Ucan <eucan@de.adit-jv.com>
3 Date: Fri, 24 Nov 2017 16:24:51 +0100
4 Subject: [PATCH 1/2] simple-id-agent: initial commit
6 it is a very simple id-agent plugin.
7 It is possible to configure default surface id
8 offset. Assigned ids would start
9 from the given id offset.
11 Please check the example weston.ini for loading
12 and configuring the simple-id-agent
14 Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
17 id-agent-modules/simple-id-agent/CMakeLists.txt | 72 ++++++++++++
18 .../simple-id-agent/src/simple-id-agent.c | 124 +++++++++++++++++++++
19 id-agent-modules/simple-id-agent/weston.ini.in | 11 ++
20 4 files changed, 208 insertions(+)
21 create mode 100644 id-agent-modules/simple-id-agent/CMakeLists.txt
22 create mode 100644 id-agent-modules/simple-id-agent/src/simple-id-agent.c
23 create mode 100644 id-agent-modules/simple-id-agent/weston.ini.in
25 diff --git a/CMakeLists.txt b/CMakeLists.txt
26 index bad85df..d07abf5 100644
29 @@ -35,6 +35,7 @@ add_subdirectory(ivi-layermanagement-api/ilmClient)
30 add_subdirectory(ivi-layermanagement-api/ilmControl)
31 add_subdirectory(ivi-layermanagement-api/test)
32 add_subdirectory(ivi-layermanagement-examples)
33 +add_subdirectory(id-agent-modules/simple-id-agent)
36 add_subdirectory(ivi-input-api/ilmInput)
37 diff --git a/id-agent-modules/simple-id-agent/CMakeLists.txt b/id-agent-modules/simple-id-agent/CMakeLists.txt
39 index 0000000..8290722
41 +++ b/id-agent-modules/simple-id-agent/CMakeLists.txt
43 +############################################################################
45 +# Copyright (C) 2013 DENSO CORPORATION
46 +# Copyright 2014 BMW Car IT GmbH
49 +# Licensed under the Apache License, Version 2.0 (the "License");
50 +# you may not use this file except in compliance with the License.
51 +# You may obtain a copy of the License at
53 +# http://www.apache.org/licenses/LICENSE-2.0
55 +# Unless required by applicable law or agreed to in writing, software
56 +# distributed under the License is distributed on an "AS IS" BASIS,
57 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
58 +# See the License for the specific language governing permissions and
59 +# limitations under the License.
61 +############################################################################
63 +cmake_minimum_required (VERSION 2.6)
65 +project(simple-id-agent)
67 +find_package(PkgConfig REQUIRED)
68 +pkg_check_modules(WAYLAND_SERVER wayland-server>=1.13.0 REQUIRED)
69 +pkg_check_modules(WESTON weston>=2.0.0 REQUIRED)
70 +pkg_check_modules(PIXMAN pixman-1 REQUIRED)
72 +find_package(Threads REQUIRED)
74 +GET_TARGET_PROPERTY(IVI_EXTENSION_INCLUDE_DIRS ivi-extension-protocol INCLUDE_DIRECTORIES)
78 + ${IVI_EXTENSION_INCLUDE_DIRS}
79 + ${WAYLAND_SERVER_INCLUDE_DIRS}
80 + ${WESTON_INCLUDE_DIRS}
81 + ${PIXMAN_INCLUDE_DIRS}
85 + ${WAYLAND_SERVER_LIBRARY_DIRS}
86 + ${PIXMAN_LIBRARY_DIRS}
89 +add_library(${PROJECT_NAME} MODULE
90 + src/simple-id-agent.c
93 +set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
95 +add_dependencies(${PROJECT_NAME}
96 + ivi-extension-protocol
97 + ${WAYLAND_SERVER_LIBRARIES}
103 + ivi-extension-protocol
104 + ${WAYLAND_SERVER_LIBRARIES}
107 +set(CMAKE_C_LDFLAGS "-module -avoid-version")
109 +target_link_libraries(${PROJECT_NAME} ${LIBS})
112 + TARGETS ${PROJECT_NAME}
113 + LIBRARY DESTINATION lib${LIB_SUFFIX}/weston
115 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
117 index 0000000..3c9e989
119 +++ b/id-agent-modules/simple-id-agent/src/simple-id-agent.c
122 + * Copyright (C) 2017 Advanced Driver Information Technology Joint Venture GmbH
124 + * Permission to use, copy, modify, distribute, and sell this software and
125 + * its documentation for any purpose is hereby granted without fee, provided
126 + * that the above copyright notice appear in all copies and that both that
127 + * copyright notice and this permission notice appear in supporting
128 + * documentation, and that the name of the copyright holders not be used in
129 + * advertising or publicity pertaining to distribution of the software
130 + * without specific, written prior permission. The copyright holders make
131 + * no representations about the suitability of this software for any
132 + * purpose. It is provided "as is" without express or implied warranty.
134 + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
135 + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
136 + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
137 + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
138 + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
139 + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
140 + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
149 +#include <weston/ivi-layout-export.h>
153 + uint32_t default_id_offset;
154 + uint32_t last_assigned_id;
155 + struct weston_compositor *compositor;
156 + const struct ivi_layout_interface *interface;
157 + struct wl_listener desktop_surface_configured;
161 +desktop_surface_event_configure(struct wl_listener *listener,
164 + struct ivi_id_agent *ida = wl_container_of(listener, ida,
165 + desktop_surface_configured);
166 + struct ivi_layout_surface *layout_surface =
167 + (struct ivi_layout_surface *) data;
170 + tmp_id = ++ida->last_assigned_id;
172 + /* Find an unused id */
173 + while(ida->interface->get_surface_from_id(tmp_id)) {
174 + weston_log("simple-id-agent: surface id: %d is already used\n", tmp_id);
178 + ida->last_assigned_id = tmp_id;
180 + if (ida->interface->surface_set_id(layout_surface, ida->last_assigned_id) != 0)
181 + weston_log("simple-id-agent: failed to set surface id :%d\n", ida->last_assigned_id);
185 +deinit(struct ivi_id_agent *ida)
187 + wl_list_remove(&ida->desktop_surface_configured.link);
192 +read_config(struct ivi_id_agent *ida)
194 + struct weston_config *config = NULL;
195 + struct weston_config_section *section = NULL;
196 + const char *name = NULL;
198 + config = wet_get_config(ida->compositor);
202 + section = weston_config_get_section(config, "id-agent", NULL, NULL);
206 + weston_config_section_get_uint(section, "default-id-offset",
207 + &ida->default_id_offset, 0);
210 + ida->default_id_offset = 0;
217 +id_agent_module_init(struct weston_compositor *ec,
218 + const struct ivi_layout_interface *interface,
219 + size_t interface_version)
221 + struct ivi_id_agent *ida;
223 + ida = calloc(1, sizeof *ida);
225 + weston_log("failed to allocate ivi_id_agent\n");
229 + ida->compositor = ec;
230 + ida->interface = interface;
231 + ida->desktop_surface_configured.notify = desktop_surface_event_configure;
232 + ida->interface->add_listener_configure_desktop_surface(&ida->desktop_surface_configured);
234 + if(read_config(ida) != 0) {
239 + ida->last_assigned_id = ida->default_id_offset;
241 + weston_log("id_agent_module_init: success\n");
245 diff --git a/id-agent-modules/simple-id-agent/weston.ini.in b/id-agent-modules/simple-id-agent/weston.ini.in
247 index 0000000..b5e5fa1
249 +++ b/id-agent-modules/simple-id-agent/weston.ini.in
256 +ivi-module=ivi-controller.so
257 +ivi-input-module=ivi-input-controller.so
258 +id-agent-module=simple-id-agent.so
261 +default-id-offset=10