Merge lp:~robertcarr/platform-api/mir2 into lp:platform-api
- mir2
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Ricardo Mendoza |
Approved revision: | 132 |
Merged at revision: | 69 |
Proposed branch: | lp:~robertcarr/platform-api/mir2 |
Merge into: | lp:platform-api |
Diff against target: |
3708 lines (+3196/-195) 44 files modified
CMakeLists.txt (+47/-0) android/default/default_ubuntu_application_ui.cpp (+8/-0) include/ubuntu/application/archive.h (+1/-0) include/ubuntu/application/id.h (+2/-0) include/ubuntu/application/ui/display.h (+6/-0) include/ubuntu/application/ui/input/event.h (+75/-0) include/ubuntu/application/ui/session.h (+2/-0) src/CMakeLists.txt (+19/-1) src/hybris/CMakeLists.txt (+6/-2) src/hybris/hybris_bridge.cpp (+59/-0) src/hybris/hybris_bridge.h (+148/-0) src/hybris/tests/CMakeLists.txt (+1/-1) src/hybris/ubuntu_application_api_hybris.cpp (+2/-191) src/hybris/ubuntu_application_sensors_hybris.cpp (+70/-0) src/mirclient/CMakeLists.txt (+34/-0) src/mirclient/application_instance_mirclient.cpp (+68/-0) src/mirclient/application_instance_mirclient_priv.h (+68/-0) src/mirclient/ubuntu_application_api_mirclient.cpp (+279/-0) src/mirclient/window_mirclient.cpp (+128/-0) src/mirclient/window_mirclient_priv.h (+76/-0) src/mirclient/window_properties_mirclient.cpp (+68/-0) src/mirclient/window_properties_mirclient_priv.h (+72/-0) src/mircommon/CMakeLists.txt (+44/-0) src/mircommon/application_description_mir.cpp (+94/-0) src/mircommon/application_description_mir_priv.h (+56/-0) src/mircommon/application_id_mir.cpp (+56/-0) src/mircommon/application_id_mir_priv.h (+53/-0) src/mircommon/application_options_mir.cpp (+170/-0) src/mircommon/application_options_mir_priv.h (+58/-0) src/mircommon/event_helpers_mir.cpp (+77/-0) src/mircommon/event_helpers_mir.h (+39/-0) src/mircommon/lifecycle_delegate_mir.cpp (+136/-0) src/mircommon/lifecycle_delegate_mir_priv.h (+59/-0) src/mircommon/session_mir.cpp (+43/-0) src/mircommon/ubuntu_application_sensors_desktop.cpp (+190/-0) src/mirserver/CMakeLists.txt (+38/-0) src/mirserver/application_instance_mirserver.cpp (+83/-0) src/mirserver/application_instance_mirserver_priv.h (+85/-0) src/mirserver/ubuntu_application_api_mirserver.cpp (+320/-0) src/mirserver/ubuntu_application_api_mirserver_priv.h (+41/-0) src/mirserver/window_mirserver.cpp (+81/-0) src/mirserver/window_mirserver_priv.h (+92/-0) src/mirserver/window_properties_mirserver.cpp (+73/-0) src/mirserver/window_properties_mirserver_priv.h (+69/-0) |
To merge this branch: | bzr merge lp:~robertcarr/platform-api/mir2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ricardo Mendoza (community) | Approve | ||
Ricardo Salveti (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+169543@code.launchpad.net |
Commit message
Add mir suport.
Description of the change
Add mir support, both for applications and for inprocess mir clients (i.e. the shell).
Stub sensors build to enable qtubuntu on the desktop against mir. Some refactoring of the hybris bridge to enable loading of real sensor module on mir on phone.
Packaging branch lives in lp:~robertcarr/platform-api/mir-with-packaging
PS Jenkins bot (ps-jenkins) wrote : | # |
- 129. By Robert Carr
-
mirserver: Use the surface factory to construct shell (mirserver) surfaces as opposed to going through the mir frontend
Ricardo Salveti (rsalveti) wrote : | # |
46 +find_library(
47 + NAMES hybris_ics
48 +)
Mind changing to hybris-common? _ics was provided by the old pacakge, which is now just a link to hybris-common.
235 +if(ENABLE_
236 + add_subdirector
237 +endif()
238 +
239 +if(ENABLE_
240 +add_subdirecto
241 +endif()
Cosmetics, please also append '/' for mircommon.
- 130. By Robert Carr
-
hybris_
ics->hybris- common - 131. By Robert Carr
-
CMake cosmetics
Robert Carr (robertcarr) wrote : | # |
Thanks! r130 and 131.
Ricardo Salveti (rsalveti) wrote : | # |
$ mmm ubuntu/
...
Install: /media/
Import includes file: /media/
target thumb C++: ubuntuappmanage
target thumb C++: ubuntuappmanage
ubuntu/
ubuntu/
ubuntu/
In file included from ubuntu/
ubuntu/
ubuntu/
make: *** [/media/
make: Leaving directory `/media/
Might not be related with this mr though.
- 132. By Robert Carr
-
Merge trunk
Ricardo Salveti (rsalveti) wrote : | # |
Code looks fine, but better someone with more familiarity with mir to review the specifics.
Other than that, tested with maguro and mako, with flipped and unflipped, no regression.
Ricardo Mendoza (ricmm) wrote : | # |
Tested on maguro, flipped / non-flipped as well as under Mir and it all works fine. No regressions.
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2013-05-21 21:54:07 +0000 |
3 | +++ CMakeLists.txt 2013-06-18 00:07:29 +0000 |
4 | @@ -9,6 +9,53 @@ |
5 | LIBRARY DESTINATION "${LIB_INSTALL_DIR}" |
6 | ARCHIVE DESTINATION "${LIB_INSTALL_DIR}") |
7 | |
8 | +option( |
9 | + ENABLE_HYBRIS_IMPLEMENTATION |
10 | + "Enable hybris based platform API implementation" |
11 | + ON |
12 | +) |
13 | + |
14 | +option( |
15 | + ENABLE_MIRSERVER_IMPLEMENTATION |
16 | + "Enable mirserver based platorm API implementation" |
17 | + OFF |
18 | +) |
19 | + |
20 | +if(ENABLE_MIRSERVER_IMPLEMENTATION) |
21 | + find_package(PkgConfig) |
22 | + pkg_check_modules(MIRSERVER REQUIRED mirserver) |
23 | +endif(ENABLE_MIRSERVER_IMPLEMENTATION) |
24 | + |
25 | +option( |
26 | + ENABLE_MIRCLIENT_IMPLEMENTATION |
27 | + "Enable mirclient based platform API implementation" |
28 | + OFF |
29 | +) |
30 | + |
31 | +if(ENABLE_MIRCLIENT_IMPLEMENTATION) |
32 | + find_package(PkgConfig) |
33 | + pkg_check_modules(MIRCLIENT REQUIRED mirclient) |
34 | +endif(ENABLE_MIRCLIENT_IMPLEMENTATION) |
35 | + |
36 | +if(ENABLE_MIRCLIENT_IMPLEMENTATION OR ENABLE_MIRSERVER_IMPLEMENTATION) |
37 | + pkg_check_modules(MIRCOMMON REQUIRED mircommon) |
38 | +endif() |
39 | + |
40 | +# Sanity-check options |
41 | +if(NOT DEFINED USE_GLES) |
42 | + set(USE_GLES 1) |
43 | +endif() |
44 | + |
45 | +# Try to find hybris, and disable hybris from build if not found |
46 | +find_library(Hybris |
47 | + NAMES hybris-common |
48 | +) |
49 | + |
50 | +if(NOT Hybris) |
51 | + message("Notice: libhybris-common.so not found, disabling hybris support") |
52 | + set(ENABLE_HYBRIS_IMPLEMENTATION OFF) |
53 | +endif() |
54 | + |
55 | include_directories(include) |
56 | include_directories(android/include) |
57 | |
58 | |
59 | === modified file 'android/default/default_ubuntu_application_ui.cpp' |
60 | --- android/default/default_ubuntu_application_ui.cpp 2013-06-07 01:08:41 +0000 |
61 | +++ android/default/default_ubuntu_application_ui.cpp 2013-06-18 00:07:29 +0000 |
62 | @@ -145,6 +145,14 @@ |
63 | return s->value->vertical_resolution(); |
64 | } |
65 | |
66 | +EGLNativeDisplayType |
67 | +ua_ui_display_get_native_type( |
68 | + UAUiDisplay* display) |
69 | +{ |
70 | + // Always EGL_DEFAULT_DISPLAY with android EGL. |
71 | + return EGL_DEFAULT_DISPLAY; |
72 | +} |
73 | + |
74 | /* |
75 | * Window Properties |
76 | */ |
77 | |
78 | === modified file 'include/ubuntu/application/archive.h' |
79 | --- include/ubuntu/application/archive.h 2013-05-27 21:49:05 +0000 |
80 | +++ include/ubuntu/application/archive.h 2013-06-18 00:07:29 +0000 |
81 | @@ -21,6 +21,7 @@ |
82 | #define UBUNTU_APPLICATION_ARCHIVE_H_ |
83 | |
84 | #include <stdint.h> |
85 | +#include <stddef.h> |
86 | #include "ubuntu/status.h" |
87 | |
88 | struct UApplicationArchive; |
89 | |
90 | === modified file 'include/ubuntu/application/id.h' |
91 | --- include/ubuntu/application/id.h 2013-05-27 22:14:00 +0000 |
92 | +++ include/ubuntu/application/id.h 2013-06-18 00:07:29 +0000 |
93 | @@ -20,6 +20,8 @@ |
94 | #ifndef UBUNTU_APPLICATION_ID_H_ |
95 | #define UBUNTU_APPLICATION_ID_H_ |
96 | |
97 | +#include <stdlib.h> |
98 | + |
99 | #ifdef __cplusplus |
100 | extern "C" { |
101 | #endif |
102 | |
103 | === modified file 'include/ubuntu/application/ui/display.h' |
104 | --- include/ubuntu/application/ui/display.h 2013-05-27 22:14:00 +0000 |
105 | +++ include/ubuntu/application/ui/display.h 2013-06-18 00:07:29 +0000 |
106 | @@ -20,6 +20,8 @@ |
107 | #ifndef UBUNTU_APPLICATION_UI_DISPLAY_H_ |
108 | #define UBUNTU_APPLICATION_UI_DISPLAY_H_ |
109 | |
110 | +#include <EGL/egl.h> |
111 | + |
112 | #ifdef __cplusplus |
113 | extern "C" { |
114 | #endif |
115 | @@ -42,6 +44,10 @@ |
116 | ua_ui_display_query_vertical_res( |
117 | UAUiDisplay* display); |
118 | |
119 | + EGLNativeDisplayType |
120 | + ua_ui_display_get_native_type( |
121 | + UAUiDisplay* display); |
122 | + |
123 | #ifdef __cplusplus |
124 | } |
125 | #endif |
126 | |
127 | === modified file 'include/ubuntu/application/ui/input/event.h' |
128 | --- include/ubuntu/application/ui/input/event.h 2013-05-27 17:11:21 +0000 |
129 | +++ include/ubuntu/application/ui/input/event.h 2013-06-18 00:07:29 +0000 |
130 | @@ -25,6 +25,81 @@ |
131 | extern "C" { |
132 | #endif |
133 | |
134 | +// TODO<papi>: Perhaps we should update the struct to use these enum types. But then we need to move action/flags |
135 | +// in to the internal typed event structs. |
136 | + |
137 | +typedef enum { |
138 | + U_KEY_ACTION_DOWN = 0, |
139 | + U_KEY_ACTION_UP = 1, |
140 | + U_KEY_ACTION_MULTIPLE = 2 |
141 | +} UKeyAction; |
142 | + |
143 | +typedef enum { |
144 | + U_KEY_FLAG_WOKE_HERE = 0x1, |
145 | + U_KEY_FLAG_SOFT_KEYBOARD = 0x2, |
146 | + U_KEY_FLAG_KEEP_TOUCH_MODE = 0x4, |
147 | + U_KEY_FLAG_FROM_SYSTEM = 0x8, |
148 | + U_KEY_FLAG_EDITOR_ACTION = 0x10, |
149 | + U_KEY_FLAG_CANCELED = 0x20, |
150 | + U_KEY_FLAG_VIRTUAL_HARD_KEY = 0x40, |
151 | + U_KEY_FLAG_LONG_PRESS = 0x80, |
152 | + U_KEY_FLAG_CANCELED_LONG_PRESS = 0x100, |
153 | + U_KEY_FLAG_TRACKING = 0x200, |
154 | + U_KEY_FLAG_FALLBACK = 0x400 |
155 | +} UKeyFlag; |
156 | + |
157 | +typedef enum { |
158 | + U_KEY_MODIFIER_NONE = 0, |
159 | + U_KEY_MODIFIER_ALT = 0x02, |
160 | + U_KEY_MODIFIER_ALT_LEFT = 0x10, |
161 | + U_KEY_MODIFIER_ALT_RIGHT = 0x20, |
162 | + U_KEY_MODIFIER_SHIFT = 0x01, |
163 | + U_KEY_MODIFIER_SHIFT_LEFT = 0x40, |
164 | + U_KEY_MODIFIER_SHIFT_RIGHT = 0x80, |
165 | + U_KEY_MODIFIER_SYM = 0x04, |
166 | + U_KEY_MODIFIER_FUNCTION = 0x08, |
167 | + U_KEY_MODIFIER_CTRL = 0x1000, |
168 | + U_KEY_MODIFIER_CTRL_LEFT = 0x2000, |
169 | + U_KEY_MODIFIER_CTRL_RIGHT = 0x4000, |
170 | + U_KEY_MODIFIER_META = 0x10000, |
171 | + U_KEY_MODIFIER_META_LEFT = 0x20000, |
172 | + U_KEY_MODIFIER_META_RIGHT = 0x40000, |
173 | + U_KEY_MODIFIER_CAPS_LOCK = 0x100000, |
174 | + U_KEY_MODIFIER_NUM_LOCK = 0x200000, |
175 | + U_KEY_MODIFIER_SCROLL_LOCK = 0x400000 |
176 | +} UKeyModifierMask; |
177 | + |
178 | +#define U_MOTION_ACTION_POINTER_INDEX_SHIFT 8 |
179 | +#define U_MOTION_ACTION_MASK 0xff |
180 | +#define U_MOTION_ACTION_POINTER_INDEX_MASK 0xff00 |
181 | + |
182 | +typedef enum { |
183 | + U_MOTION_ACTION_DOWN = 0, |
184 | + U_MOTION_ACTION_UP = 1, |
185 | + U_MOTION_ACTION_MOVE = 2, |
186 | + U_MOTION_ACTION_CANCEL = 3, |
187 | + U_MOTION_ACTION_OUTSIDE = 4, |
188 | + U_MOTION_ACTION_POINTER_DOWN = 5, |
189 | + U_MOTION_ACTION_POINTER_UP = 6, |
190 | + U_MOTION_ACTION_HOVER_MOVE = 7, |
191 | + U_MOTION_ACTION_SCROLL = 8, |
192 | + U_MOTION_ACTION_HOVER_ENTER = 9, |
193 | + U_MOTION_ACTION_HOVER_EXIT = 10 |
194 | +} UMotionAction; |
195 | + |
196 | +typedef enum { |
197 | + U_MOTION_FLAG_WINDOW_IS_OBSCURED = 0x1 |
198 | +} UMotionFlag; |
199 | + |
200 | +typedef enum { |
201 | + U_MOTION_BUTTON_PRIMARY = 1 << 0, |
202 | + U_MOTION_BUTTON_SECONDARY = 1 << 1, |
203 | + U_MOTION_BUTTON_TERTIARY = 1 << 2, |
204 | + U_MOTION_BUTTON_BACK = 1 << 3, |
205 | + U_MOTION_BUTTON_FORWARD = 1 << 4 |
206 | +} UMotionButtonMask; |
207 | + |
208 | + |
209 | /** Maximum number of pointers reported within one input event. */ |
210 | #define UBUNTU_APPLICATION_UI_INPUT_EVENT_MAX_POINTER_COUNT (16) |
211 | |
212 | |
213 | === modified file 'include/ubuntu/application/ui/session.h' |
214 | --- include/ubuntu/application/ui/session.h 2013-06-05 01:22:24 +0000 |
215 | +++ include/ubuntu/application/ui/session.h 2013-06-18 00:07:29 +0000 |
216 | @@ -20,6 +20,8 @@ |
217 | #ifndef UBUNTU_APPLICATION_UI_SESSION_H_ |
218 | #define UBUNTU_APPLICATION_UI_SESSION_H_ |
219 | |
220 | +#include <stdint.h> |
221 | + |
222 | #ifdef __cplusplus |
223 | extern "C" { |
224 | #endif |
225 | |
226 | === modified file 'src/CMakeLists.txt' |
227 | --- src/CMakeLists.txt 2013-02-05 06:58:40 +0000 |
228 | +++ src/CMakeLists.txt 2013-06-18 00:07:29 +0000 |
229 | @@ -1,1 +1,19 @@ |
230 | -add_subdirectory(android/) |
231 | +include_directories( |
232 | + ${CMAKE_CURRENT_SOURCE_DIR} |
233 | +) |
234 | + |
235 | +if(ENABLE_HYBRIS_IMPLEMENTATION) |
236 | + add_subdirectory(hybris/) |
237 | +endif() |
238 | + |
239 | +if(ENABLE_MIRSERVER_IMPLEMENTATION OR ENABLE_MIRCLIENT_IMPLEMENTATION) |
240 | + add_subdirectory(mircommon/) |
241 | +endif() |
242 | + |
243 | +if(ENABLE_MIRSERVER_IMPLEMENTATION) |
244 | + add_subdirectory(mirserver/) |
245 | +endif() |
246 | + |
247 | +if(ENABLE_MIRCLIENT_IMPLEMENTATION) |
248 | + add_subdirectory(mirclient/) |
249 | +endif() |
250 | |
251 | === renamed directory 'src/android' => 'src/hybris' |
252 | === modified file 'src/hybris/CMakeLists.txt' |
253 | --- src/android/CMakeLists.txt 2013-04-10 14:42:09 +0000 |
254 | +++ src/hybris/CMakeLists.txt 2013-06-18 00:07:29 +0000 |
255 | @@ -1,4 +1,8 @@ |
256 | -set(SOURCES ubuntu_application_api.cpp) |
257 | +set(SOURCES |
258 | + hybris_bridge.cpp |
259 | + ubuntu_application_api_hybris.cpp |
260 | + ubuntu_application_sensors_hybris.cpp |
261 | +) |
262 | |
263 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++0x") |
264 | |
265 | @@ -13,7 +17,7 @@ |
266 | |
267 | target_link_libraries( |
268 | ubuntu_application_api |
269 | - hybris_ics |
270 | + hybris-common |
271 | ) |
272 | |
273 | set_target_properties( |
274 | |
275 | === added file 'src/hybris/hybris_bridge.cpp' |
276 | --- src/hybris/hybris_bridge.cpp 1970-01-01 00:00:00 +0000 |
277 | +++ src/hybris/hybris_bridge.cpp 2013-06-18 00:07:29 +0000 |
278 | @@ -0,0 +1,59 @@ |
279 | +/* |
280 | + * Copyright (C) 2013 Canonical Ltd |
281 | + * |
282 | + * This program is free software: you can redistribute it and/or modify |
283 | + * it under the terms of the GNU Lesser General Public License version 3 as |
284 | + * published by the Free Software Foundation. |
285 | + * |
286 | + * This program is distributed in the hope that it will be useful, |
287 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
288 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
289 | + * GNU Lesser General Public License for more details. |
290 | + * |
291 | + * You should have received a copy of the GNU Lesser General Public License |
292 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
293 | + * |
294 | + * Authored by: Thomas Voss <thomas.voss@canonical.com> |
295 | + * Ricardo Mendoza <ricardo.mendoza@canonical.com> |
296 | + */ |
297 | + |
298 | +#include "hybris_bridge.h" |
299 | + |
300 | +#include <dlfcn.h> |
301 | +#include <assert.h> |
302 | + |
303 | +namespace uh = ubuntu::hybris; |
304 | + |
305 | +extern "C" { |
306 | + |
307 | +extern void *android_dlopen(const char *filename, int flag); |
308 | +extern void *android_dlsym(void *handle, const char *symbol); |
309 | + |
310 | +} |
311 | + |
312 | +const char* uh::Bridge::path_to_library() |
313 | +{ |
314 | + return "/system/lib/libubuntu_application_api.so"; |
315 | +} |
316 | + |
317 | +uh::Bridge& uh::Bridge::instance() |
318 | +{ |
319 | + static uh::Bridge bridge; |
320 | + return bridge; |
321 | +} |
322 | + |
323 | +uh::Bridge::Bridge() |
324 | + : lib_handle(android_dlopen(path_to_library(), RTLD_LAZY)) |
325 | +{ |
326 | + assert(lib_handle && "Error loading ubuntu_application_api"); |
327 | +} |
328 | + |
329 | +uh::Bridge::~Bridge() |
330 | +{ |
331 | + // TODO android_dlclose(libcamera_handle); |
332 | +} |
333 | + |
334 | +void* uh::Bridge::resolve_symbol(const char* symbol) const |
335 | +{ |
336 | + return android_dlsym(lib_handle, symbol); |
337 | +} |
338 | |
339 | === added file 'src/hybris/hybris_bridge.h' |
340 | --- src/hybris/hybris_bridge.h 1970-01-01 00:00:00 +0000 |
341 | +++ src/hybris/hybris_bridge.h 2013-06-18 00:07:29 +0000 |
342 | @@ -0,0 +1,148 @@ |
343 | +/* |
344 | + * Copyright (C) 2013 Canonical Ltd |
345 | + * |
346 | + * This program is free software: you can redistribute it and/or modify |
347 | + * it under the terms of the GNU Lesser General Public License version 3 as |
348 | + * published by the Free Software Foundation. |
349 | + * |
350 | + * This program is distributed in the hope that it will be useful, |
351 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
352 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
353 | + * GNU Lesser General Public License for more details. |
354 | + * |
355 | + * You should have received a copy of the GNU Lesser General Public License |
356 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
357 | + * |
358 | + * Authored by: Thomas Voss <thomas.voss@canonical.com> |
359 | + * Ricardo Mendoza <ricardo.mendoza@canonical.com> |
360 | + */ |
361 | + |
362 | +#ifndef UBUNTU_APPLICATION_API_HYBRIS_BRIDGE_H_ |
363 | +#define UBUNTU_APPLICATION_API_HYBRIS_BRIDGE_H_ |
364 | + |
365 | +#include <stddef.h> |
366 | + |
367 | +namespace ubuntu |
368 | +{ |
369 | +namespace hybris |
370 | +{ |
371 | + |
372 | +struct Bridge |
373 | +{ |
374 | + Bridge(); |
375 | + ~Bridge(); |
376 | + |
377 | + static const char* path_to_library(); |
378 | + static Bridge& instance(); |
379 | + |
380 | + void* resolve_symbol(const char* symbol) const; |
381 | + |
382 | + void* lib_handle; |
383 | +}; |
384 | + |
385 | +} |
386 | +} |
387 | + |
388 | +// Sweet and beautiful music. |
389 | +#define DLSYM(fptr, sym) if (*(fptr) == NULL) { *((void**)fptr) = (void *) ubuntu::hybris::Bridge::instance().resolve_symbol(sym); } |
390 | + |
391 | +#define IMPLEMENT_FUNCTION0(return_type, symbol) \ |
392 | + return_type symbol() \ |
393 | + { \ |
394 | + static return_type (*f)() = NULL; \ |
395 | + DLSYM(&f, #symbol); \ |
396 | + return f();} |
397 | + |
398 | +#define IMPLEMENT_VOID_FUNCTION0(symbol) \ |
399 | + void symbol() \ |
400 | + { \ |
401 | + static void (*f)() = NULL; \ |
402 | + DLSYM(&f, #symbol); \ |
403 | + f();} |
404 | + |
405 | +#define IMPLEMENT_FUNCTION1(return_type, symbol, arg1) \ |
406 | + return_type symbol(arg1 _1) \ |
407 | + { \ |
408 | + static return_type (*f)(arg1) = NULL; \ |
409 | + DLSYM(&f, #symbol); \ |
410 | + return f(_1); } |
411 | + |
412 | +#define IMPLEMENT_SF_FUNCTION1(return_type, symbol, arg1) \ |
413 | + return_type symbol(arg1 _1) \ |
414 | + { \ |
415 | + static return_type (*f)(arg1) __attribute__((pcs("aapcs"))) = NULL; \ |
416 | + DLSYM(&f, #symbol); \ |
417 | + return f(_1); } |
418 | + |
419 | + |
420 | +#define IMPLEMENT_VOID_FUNCTION1(symbol, arg1) \ |
421 | + void symbol(arg1 _1) \ |
422 | + { \ |
423 | + static void (*f)(arg1) = NULL; \ |
424 | + DLSYM(&f, #symbol); \ |
425 | + f(_1); } |
426 | + |
427 | +#define IMPLEMENT_FUNCTION2(return_type, symbol, arg1, arg2) \ |
428 | + return_type symbol(arg1 _1, arg2 _2) \ |
429 | + { \ |
430 | + static return_type (*f)(arg1, arg2) = NULL; \ |
431 | + DLSYM(&f, #symbol); \ |
432 | + return f(_1, _2); } |
433 | + |
434 | +#define IMPLEMENT_VOID_FUNCTION2(symbol, arg1, arg2) \ |
435 | + void symbol(arg1 _1, arg2 _2) \ |
436 | + { \ |
437 | + static void (*f)(arg1, arg2) = NULL; \ |
438 | + DLSYM(&f, #symbol); \ |
439 | + f(_1, _2); } |
440 | + |
441 | +#define IMPLEMENT_FUNCTION3(return_type, symbol, arg1, arg2, arg3) \ |
442 | + return_type symbol(arg1 _1, arg2 _2, arg3 _3) \ |
443 | + { \ |
444 | + static return_type (*f)(arg1, arg2, arg3) = NULL; \ |
445 | + DLSYM(&f, #symbol); \ |
446 | + return f(_1, _2, _3); } |
447 | + |
448 | +#define IMPLEMENT_VOID_FUNCTION3(symbol, arg1, arg2, arg3) \ |
449 | + void symbol(arg1 _1, arg2 _2, arg3 _3) \ |
450 | + { \ |
451 | + static void (*f)(arg1, arg2, arg3) = NULL; \ |
452 | + DLSYM(&f, #symbol); \ |
453 | + f(_1, _2, _3); } |
454 | + |
455 | +#define IMPLEMENT_VOID_FUNCTION4(symbol, arg1, arg2, arg3, arg4) \ |
456 | + void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4) \ |
457 | + { \ |
458 | + static void (*f)(arg1, arg2, arg3, arg4) = NULL; \ |
459 | + DLSYM(&f, #symbol); \ |
460 | + f(_1, _2, _3, _4); } |
461 | + |
462 | +#define IMPLEMENT_FUNCTION4(return_type, symbol, arg1, arg2, arg3, arg4) \ |
463 | + return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4) \ |
464 | + { \ |
465 | + static return_type (*f)(arg1, arg2, arg3, arg4) = NULL; \ |
466 | + DLSYM(&f, #symbol); \ |
467 | + return f(_1, _2, _3, _4); } |
468 | + |
469 | +#define IMPLEMENT_FUNCTION6(return_type, symbol, arg1, arg2, arg3, arg4, arg5, arg6) \ |
470 | + return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6) \ |
471 | + { \ |
472 | + static return_type (*f)(arg1, arg2, arg3, arg4, arg5, arg6) = NULL; \ |
473 | + DLSYM(&f, #symbol); \ |
474 | + return f(_1, _2, _3, _4, _5, _6); } |
475 | + |
476 | +#define IMPLEMENT_VOID_FUNCTION7(symbol, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ |
477 | + void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6, arg7 _7) \ |
478 | + { \ |
479 | + static void (*f)(arg1, arg2, arg3, arg4, arg5, arg6, arg7) = NULL; \ |
480 | + DLSYM(&f, #symbol); \ |
481 | + f(_1, _2, _3, _4, _5, _6, _7); } |
482 | + |
483 | +#define IMPLEMENT_VOID_FUNCTION8(symbol, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \ |
484 | + void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6, arg7 _7, arg8 _8) \ |
485 | + { \ |
486 | + static void (*f)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) = NULL; \ |
487 | + DLSYM(&f, #symbol); \ |
488 | + f(_1, _2, _3, _4, _5, _6, _7, _8); } |
489 | + |
490 | +#endif // UBUNTU_APPLICATION_API_HYBRIS_BRIDGE_H_ |
491 | |
492 | === modified file 'src/hybris/tests/CMakeLists.txt' |
493 | --- src/android/tests/CMakeLists.txt 2013-02-05 06:58:40 +0000 |
494 | +++ src/hybris/tests/CMakeLists.txt 2013-06-18 00:07:29 +0000 |
495 | @@ -1,4 +1,4 @@ |
496 | -set(SOURCES ubuntu_application_api.cpp) |
497 | +set(SOURCES ubuntu_application_api_hybris.cpp) |
498 | |
499 | add_executable(test_android_ubuntu_app_api test_c_api.cpp) |
500 | target_link_libraries(test_android_ubuntu_app_api ubuntu_application_api EGL GLESv2) |
501 | |
502 | === renamed file 'src/android/ubuntu_application_api.cpp' => 'src/hybris/ubuntu_application_api_hybris.cpp' |
503 | --- src/android/ubuntu_application_api.cpp 2013-06-07 01:08:41 +0000 |
504 | +++ src/hybris/ubuntu_application_api_hybris.cpp 2013-06-18 00:07:29 +0000 |
505 | @@ -29,56 +29,12 @@ |
506 | #include <ubuntu/application/ui/session.h> |
507 | #include <ubuntu/application/ui/clipboard.h> |
508 | #include <ubuntu/application/ui/display.h> |
509 | -#include <ubuntu/application/sensors/accelerometer.h> |
510 | -#include <ubuntu/application/sensors/proximity.h> |
511 | -#include <ubuntu/application/sensors/light.h> |
512 | |
513 | #include <assert.h> |
514 | #include <dlfcn.h> |
515 | #include <stddef.h> |
516 | |
517 | -#ifdef __cplusplus |
518 | -extern "C" { |
519 | -#endif |
520 | - |
521 | -extern void *android_dlopen(const char *filename, int flag); |
522 | -extern void *android_dlsym(void *handle, const char *symbol); |
523 | - |
524 | -#ifdef __cplusplus |
525 | -} |
526 | -#endif |
527 | - |
528 | -namespace |
529 | -{ |
530 | - |
531 | -struct Bridge |
532 | -{ |
533 | - static const char* path_to_library() |
534 | - { |
535 | - return "/system/lib/libubuntu_application_api.so"; |
536 | - } |
537 | - |
538 | - static Bridge& instance() { static Bridge bridge; return bridge; } |
539 | - |
540 | - Bridge() : lib_handle(android_dlopen(path_to_library(), RTLD_LAZY)) |
541 | - { |
542 | - assert(lib_handle && "Error loading ubuntu_application_api"); |
543 | - } |
544 | - |
545 | - ~Bridge() |
546 | - { |
547 | - // TODO android_dlclose(libcamera_handle); |
548 | - } |
549 | - |
550 | - void* resolve_symbol(const char* symbol) const |
551 | - { |
552 | - return android_dlsym(lib_handle, symbol); |
553 | - } |
554 | - |
555 | - void* lib_handle; |
556 | -}; |
557 | - |
558 | -} |
559 | +#include "hybris_bridge.h" |
560 | |
561 | #ifdef __cplusplus |
562 | extern "C" { |
563 | @@ -88,106 +44,6 @@ |
564 | /*********** Implementation starts here *******************/ |
565 | /**********************************************************/ |
566 | |
567 | -#define DLSYM(fptr, sym) if (*(fptr) == NULL) { *((void**)fptr) = (void *) Bridge::instance().resolve_symbol(sym); } |
568 | - |
569 | -#define IMPLEMENT_FUNCTION0(return_type, symbol) \ |
570 | - return_type symbol() \ |
571 | - { \ |
572 | - static return_type (*f)() = NULL; \ |
573 | - DLSYM(&f, #symbol); \ |
574 | - return f();} |
575 | - |
576 | -#define IMPLEMENT_VOID_FUNCTION0(symbol) \ |
577 | - void symbol() \ |
578 | - { \ |
579 | - static void (*f)() = NULL; \ |
580 | - DLSYM(&f, #symbol); \ |
581 | - f();} |
582 | - |
583 | -#define IMPLEMENT_FUNCTION1(return_type, symbol, arg1) \ |
584 | - return_type symbol(arg1 _1) \ |
585 | - { \ |
586 | - static return_type (*f)(arg1) = NULL; \ |
587 | - DLSYM(&f, #symbol); \ |
588 | - return f(_1); } |
589 | - |
590 | -#define IMPLEMENT_SF_FUNCTION1(return_type, symbol, arg1) \ |
591 | - return_type symbol(arg1 _1) \ |
592 | - { \ |
593 | - static return_type (*f)(arg1) __attribute__((pcs("aapcs"))) = NULL; \ |
594 | - DLSYM(&f, #symbol); \ |
595 | - return f(_1); } |
596 | - |
597 | - |
598 | -#define IMPLEMENT_VOID_FUNCTION1(symbol, arg1) \ |
599 | - void symbol(arg1 _1) \ |
600 | - { \ |
601 | - static void (*f)(arg1) = NULL; \ |
602 | - DLSYM(&f, #symbol); \ |
603 | - f(_1); } |
604 | - |
605 | -#define IMPLEMENT_FUNCTION2(return_type, symbol, arg1, arg2) \ |
606 | - return_type symbol(arg1 _1, arg2 _2) \ |
607 | - { \ |
608 | - static return_type (*f)(arg1, arg2) = NULL; \ |
609 | - DLSYM(&f, #symbol); \ |
610 | - return f(_1, _2); } |
611 | - |
612 | -#define IMPLEMENT_VOID_FUNCTION2(symbol, arg1, arg2) \ |
613 | - void symbol(arg1 _1, arg2 _2) \ |
614 | - { \ |
615 | - static void (*f)(arg1, arg2) = NULL; \ |
616 | - DLSYM(&f, #symbol); \ |
617 | - f(_1, _2); } |
618 | - |
619 | -#define IMPLEMENT_FUNCTION3(return_type, symbol, arg1, arg2, arg3) \ |
620 | - return_type symbol(arg1 _1, arg2 _2, arg3 _3) \ |
621 | - { \ |
622 | - static return_type (*f)(arg1, arg2, arg3) = NULL; \ |
623 | - DLSYM(&f, #symbol); \ |
624 | - return f(_1, _2, _3); } |
625 | - |
626 | -#define IMPLEMENT_VOID_FUNCTION3(symbol, arg1, arg2, arg3) \ |
627 | - void symbol(arg1 _1, arg2 _2, arg3 _3) \ |
628 | - { \ |
629 | - static void (*f)(arg1, arg2, arg3) = NULL; \ |
630 | - DLSYM(&f, #symbol); \ |
631 | - f(_1, _2, _3); } |
632 | - |
633 | -#define IMPLEMENT_VOID_FUNCTION4(symbol, arg1, arg2, arg3, arg4) \ |
634 | - void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4) \ |
635 | - { \ |
636 | - static void (*f)(arg1, arg2, arg3, arg4) = NULL; \ |
637 | - DLSYM(&f, #symbol); \ |
638 | - f(_1, _2, _3, _4); } |
639 | - |
640 | -#define IMPLEMENT_FUNCTION4(return_type, symbol, arg1, arg2, arg3, arg4) \ |
641 | - return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4) \ |
642 | - { \ |
643 | - static return_type (*f)(arg1, arg2, arg3, arg4) = NULL; \ |
644 | - DLSYM(&f, #symbol); \ |
645 | - return f(_1, _2, _3, _4); } |
646 | - |
647 | -#define IMPLEMENT_FUNCTION6(return_type, symbol, arg1, arg2, arg3, arg4, arg5, arg6) \ |
648 | - return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6) \ |
649 | - { \ |
650 | - static return_type (*f)(arg1, arg2, arg3, arg4, arg5, arg6) = NULL; \ |
651 | - DLSYM(&f, #symbol); \ |
652 | - return f(_1, _2, _3, _4, _5, _6); } |
653 | - |
654 | -#define IMPLEMENT_VOID_FUNCTION7(symbol, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ |
655 | - void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6, arg7 _7) \ |
656 | - { \ |
657 | - static void (*f)(arg1, arg2, arg3, arg4, arg5, arg6, arg7) = NULL; \ |
658 | - DLSYM(&f, #symbol); \ |
659 | - f(_1, _2, _3, _4, _5, _6, _7); } |
660 | - |
661 | -#define IMPLEMENT_VOID_FUNCTION8(symbol, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \ |
662 | - void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6, arg7 _7, arg8 _8) \ |
663 | - { \ |
664 | - static void (*f)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) = NULL; \ |
665 | - DLSYM(&f, #symbol); \ |
666 | - f(_1, _2, _3, _4, _5, _6, _7, _8); } |
667 | |
668 | // Session helpers |
669 | IMPLEMENT_FUNCTION0(UAUiSessionProperties*, ua_ui_session_properties_new); |
670 | @@ -236,6 +92,7 @@ |
671 | IMPLEMENT_VOID_FUNCTION1(ua_ui_display_destroy, UAUiDisplay*); |
672 | IMPLEMENT_FUNCTION1(uint32_t, ua_ui_display_query_horizontal_res, UAUiDisplay*); |
673 | IMPLEMENT_FUNCTION1(uint32_t, ua_ui_display_query_vertical_res, UAUiDisplay*); |
674 | +IMPLEMENT_FUNCTION1(EGLNativeDisplayType, ua_ui_display_get_native_type, UAUiDisplay*); |
675 | |
676 | |
677 | // UAUiWindowProperties |
678 | @@ -256,52 +113,6 @@ |
679 | IMPLEMENT_VOID_FUNCTION1(ua_ui_window_request_fullscreen, UAUiWindow*); |
680 | IMPLEMENT_FUNCTION1(EGLNativeWindowType, ua_ui_window_get_native_type, UAUiWindow*); |
681 | |
682 | -// Ubuntu Application Sensors |
683 | - |
684 | -// Acceleration Sensor |
685 | -IMPLEMENT_FUNCTION0(UASensorsAccelerometer*, ua_sensors_accelerometer_new); |
686 | -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_accelerometer_enable, UASensorsAccelerometer*); |
687 | -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_accelerometer_disable, UASensorsAccelerometer*); |
688 | -IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_accelerometer_get_min_delay, UASensorsAccelerometer*); |
689 | -IMPLEMENT_SF_FUNCTION1(float, ua_sensors_accelerometer_get_min_value, UASensorsAccelerometer*); |
690 | -IMPLEMENT_SF_FUNCTION1(float, ua_sensors_accelerometer_get_max_value, UASensorsAccelerometer*); |
691 | -IMPLEMENT_SF_FUNCTION1(float, ua_sensors_accelerometer_get_resolution, UASensorsAccelerometer*); |
692 | -IMPLEMENT_VOID_FUNCTION3(ua_sensors_accelerometer_set_reading_cb, UASensorsAccelerometer*, on_accelerometer_event_cb, void*); |
693 | - |
694 | -// Acceleration Sensor Event |
695 | -IMPLEMENT_FUNCTION1(uint64_t, uas_accelerometer_event_get_timestamp, UASAccelerometerEvent*); |
696 | -IMPLEMENT_SF_FUNCTION1(float, uas_accelerometer_event_get_acceleration_x, UASAccelerometerEvent*); |
697 | -IMPLEMENT_SF_FUNCTION1(float, uas_accelerometer_event_get_acceleration_y, UASAccelerometerEvent*); |
698 | -IMPLEMENT_SF_FUNCTION1(float, uas_accelerometer_event_get_acceleration_z, UASAccelerometerEvent*); |
699 | - |
700 | -// Proximity Sensor |
701 | -IMPLEMENT_FUNCTION0(UASensorsProximity*, ua_sensors_proximity_new); |
702 | -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_proximity_enable, UASensorsProximity*); |
703 | -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_proximity_disable, UASensorsProximity*); |
704 | -IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_proximity_get_min_delay, UASensorsProximity*); |
705 | -IMPLEMENT_SF_FUNCTION1(float, ua_sensors_proximity_get_min_value, UASensorsProximity*); |
706 | -IMPLEMENT_SF_FUNCTION1(float, ua_sensors_proximity_get_max_value, UASensorsProximity*); |
707 | -IMPLEMENT_SF_FUNCTION1(float, ua_sensors_proximity_get_resolution, UASensorsProximity*); |
708 | -IMPLEMENT_VOID_FUNCTION3(ua_sensors_proximity_set_reading_cb, UASensorsProximity*, on_proximity_event_cb, void*); |
709 | - |
710 | -// Proximity Sensor Event |
711 | -IMPLEMENT_FUNCTION1(uint64_t, uas_proximity_event_get_timestamp, UASProximityEvent*); |
712 | -IMPLEMENT_FUNCTION1(UASProximityDistance, uas_proximity_event_get_distance, UASProximityEvent*); |
713 | - |
714 | -// Ambient Light Sensor |
715 | -IMPLEMENT_FUNCTION0(UASensorsLight*, ua_sensors_light_new); |
716 | -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_light_enable, UASensorsLight*); |
717 | -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_light_disable, UASensorsLight*); |
718 | -IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_light_get_min_delay, UASensorsLight*); |
719 | -IMPLEMENT_SF_FUNCTION1(float, ua_sensors_light_get_min_value, UASensorsLight*); |
720 | -IMPLEMENT_SF_FUNCTION1(float, ua_sensors_light_get_max_value, UASensorsLight*); |
721 | -IMPLEMENT_SF_FUNCTION1(float, ua_sensors_light_get_resolution, UASensorsLight*); |
722 | -IMPLEMENT_VOID_FUNCTION3(ua_sensors_light_set_reading_cb, UASensorsLight*, on_light_event_cb, void*); |
723 | - |
724 | -// Ambient Light Sensor Event |
725 | -IMPLEMENT_FUNCTION1(uint64_t, uas_light_event_get_timestamp, UASLightEvent*); |
726 | -IMPLEMENT_SF_FUNCTION1(float, uas_light_event_get_light, UASLightEvent*); |
727 | - |
728 | /* -------------------------------------------------------------------------- * |
729 | * * * * * * * * * * * * * * * Deprecated API * * * * * * * * * * * * * * * * * |
730 | * -------------------------------------------------------------------------- * |
731 | |
732 | === added file 'src/hybris/ubuntu_application_sensors_hybris.cpp' |
733 | --- src/hybris/ubuntu_application_sensors_hybris.cpp 1970-01-01 00:00:00 +0000 |
734 | +++ src/hybris/ubuntu_application_sensors_hybris.cpp 2013-06-18 00:07:29 +0000 |
735 | @@ -0,0 +1,70 @@ |
736 | +/* |
737 | + * Copyright (C) 2012 Canonical Ltd |
738 | + * |
739 | + * This program is free software: you can redistribute it and/or modify |
740 | + * it under the terms of the GNU Lesser General Public License version 3 as |
741 | + * published by the Free Software Foundation. |
742 | + * |
743 | + * This program is distributed in the hope that it will be useful, |
744 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
745 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
746 | + * GNU Lesser General Public License for more details. |
747 | + * |
748 | + * You should have received a copy of the GNU Lesser General Public License |
749 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
750 | + * |
751 | + * Authored by: Thomas Voss <thomas.voss@canonical.com> |
752 | + * Ricardo Mendoza <ricardo.mendoza@canonical.com> |
753 | + */ |
754 | + |
755 | +#include <ubuntu/application/sensors/accelerometer.h> |
756 | +#include <ubuntu/application/sensors/proximity.h> |
757 | +#include <ubuntu/application/sensors/light.h> |
758 | + |
759 | +#include "hybris_bridge.h" |
760 | + |
761 | +// Ubuntu Application Sensors |
762 | + |
763 | +// Acceleration Sensor |
764 | +IMPLEMENT_FUNCTION0(UASensorsAccelerometer*, ua_sensors_accelerometer_new); |
765 | +IMPLEMENT_FUNCTION1(UStatus, ua_sensors_accelerometer_enable, UASensorsAccelerometer*); |
766 | +IMPLEMENT_FUNCTION1(UStatus, ua_sensors_accelerometer_disable, UASensorsAccelerometer*); |
767 | +IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_accelerometer_get_min_delay, UASensorsAccelerometer*); |
768 | +IMPLEMENT_SF_FUNCTION1(float, ua_sensors_accelerometer_get_min_value, UASensorsAccelerometer*); |
769 | +IMPLEMENT_SF_FUNCTION1(float, ua_sensors_accelerometer_get_max_value, UASensorsAccelerometer*); |
770 | +IMPLEMENT_SF_FUNCTION1(float, ua_sensors_accelerometer_get_resolution, UASensorsAccelerometer*); |
771 | +IMPLEMENT_VOID_FUNCTION3(ua_sensors_accelerometer_set_reading_cb, UASensorsAccelerometer*, on_accelerometer_event_cb, void*); |
772 | + |
773 | +// Acceleration Sensor Event |
774 | +IMPLEMENT_FUNCTION1(uint64_t, uas_accelerometer_event_get_timestamp, UASAccelerometerEvent*); |
775 | +IMPLEMENT_SF_FUNCTION1(float, uas_accelerometer_event_get_acceleration_x, UASAccelerometerEvent*); |
776 | +IMPLEMENT_SF_FUNCTION1(float, uas_accelerometer_event_get_acceleration_y, UASAccelerometerEvent*); |
777 | +IMPLEMENT_SF_FUNCTION1(float, uas_accelerometer_event_get_acceleration_z, UASAccelerometerEvent*); |
778 | + |
779 | +// Proximity Sensor |
780 | +IMPLEMENT_FUNCTION0(UASensorsProximity*, ua_sensors_proximity_new); |
781 | +IMPLEMENT_FUNCTION1(UStatus, ua_sensors_proximity_enable, UASensorsProximity*); |
782 | +IMPLEMENT_FUNCTION1(UStatus, ua_sensors_proximity_disable, UASensorsProximity*); |
783 | +IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_proximity_get_min_delay, UASensorsProximity*); |
784 | +IMPLEMENT_SF_FUNCTION1(float, ua_sensors_proximity_get_min_value, UASensorsProximity*); |
785 | +IMPLEMENT_SF_FUNCTION1(float, ua_sensors_proximity_get_max_value, UASensorsProximity*); |
786 | +IMPLEMENT_SF_FUNCTION1(float, ua_sensors_proximity_get_resolution, UASensorsProximity*); |
787 | +IMPLEMENT_VOID_FUNCTION3(ua_sensors_proximity_set_reading_cb, UASensorsProximity*, on_proximity_event_cb, void*); |
788 | + |
789 | +// Proximity Sensor Event |
790 | +IMPLEMENT_FUNCTION1(uint64_t, uas_proximity_event_get_timestamp, UASProximityEvent*); |
791 | +IMPLEMENT_FUNCTION1(UASProximityDistance, uas_proximity_event_get_distance, UASProximityEvent*); |
792 | + |
793 | +// Ambient Light Sensor |
794 | +IMPLEMENT_FUNCTION0(UASensorsLight*, ua_sensors_light_new); |
795 | +IMPLEMENT_FUNCTION1(UStatus, ua_sensors_light_enable, UASensorsLight*); |
796 | +IMPLEMENT_FUNCTION1(UStatus, ua_sensors_light_disable, UASensorsLight*); |
797 | +IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_light_get_min_delay, UASensorsLight*); |
798 | +IMPLEMENT_SF_FUNCTION1(float, ua_sensors_light_get_min_value, UASensorsLight*); |
799 | +IMPLEMENT_SF_FUNCTION1(float, ua_sensors_light_get_max_value, UASensorsLight*); |
800 | +IMPLEMENT_SF_FUNCTION1(float, ua_sensors_light_get_resolution, UASensorsLight*); |
801 | +IMPLEMENT_VOID_FUNCTION3(ua_sensors_light_set_reading_cb, UASensorsLight*, on_light_event_cb, void*); |
802 | + |
803 | +// Ambient Light Sensor Event |
804 | +IMPLEMENT_FUNCTION1(uint64_t, uas_light_event_get_timestamp, UASLightEvent*); |
805 | +IMPLEMENT_SF_FUNCTION1(float, uas_light_event_get_light, UASLightEvent*); |
806 | |
807 | === added directory 'src/mirclient' |
808 | === added file 'src/mirclient/CMakeLists.txt' |
809 | --- src/mirclient/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
810 | +++ src/mirclient/CMakeLists.txt 2013-06-18 00:07:29 +0000 |
811 | @@ -0,0 +1,34 @@ |
812 | +set(SOURCES |
813 | + ubuntu_application_api_mirclient.cpp |
814 | + application_instance_mirclient.cpp |
815 | + window_properties_mirclient.cpp |
816 | + window_mirclient.cpp |
817 | +) |
818 | + |
819 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -fPIC") |
820 | + |
821 | +add_library( |
822 | + ubuntu_application_api_mirclient SHARED |
823 | + ${SOURCES} |
824 | +) |
825 | + |
826 | +include_directories( |
827 | + ${CMAKE_BINARY_DIR}/include |
828 | + ${MIRCLIENT_INCLUDE_DIRS} |
829 | +) |
830 | + |
831 | +target_link_libraries( |
832 | + ubuntu_application_api_mirclient |
833 | + ${MIRCLIENT_LDFLAGS} ${MIRCLIENT_LIBRARIES} |
834 | + -Wl,--whole-archive ubuntu_application_api_mircommon |
835 | + -Wl,--no-whole-archive |
836 | +) |
837 | + |
838 | +set_target_properties( |
839 | + ubuntu_application_api_mirclient |
840 | + PROPERTIES |
841 | + VERSION 1.0 |
842 | + SOVERSION 1 |
843 | +) |
844 | + |
845 | +install(TARGETS ubuntu_application_api_mirclient ${INSTALL_TARGETS_DEFAULT_ARGS}) |
846 | |
847 | === added file 'src/mirclient/application_instance_mirclient.cpp' |
848 | --- src/mirclient/application_instance_mirclient.cpp 1970-01-01 00:00:00 +0000 |
849 | +++ src/mirclient/application_instance_mirclient.cpp 2013-06-18 00:07:29 +0000 |
850 | @@ -0,0 +1,68 @@ |
851 | +/* |
852 | + * Copyright (C) 2013 Canonical Ltd |
853 | + * |
854 | + * This program is free software: you can redistribute it and/or modify |
855 | + * it under the terms of the GNU Lesser General Public License version 3 as |
856 | + * published by the Free Software Foundation. |
857 | + * |
858 | + * This program is distributed in the hope that it will be useful, |
859 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
860 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
861 | + * GNU Lesser General Public License for more details. |
862 | + * |
863 | + * You should have received a copy of the GNU Lesser General Public License |
864 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
865 | + * |
866 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
867 | + */ |
868 | + |
869 | +#include "application_instance_mirclient_priv.h" |
870 | + |
871 | +namespace uamc = ubuntu::application::mir::client; |
872 | + |
873 | +uamc::Instance::Instance() |
874 | + : con(nullptr), |
875 | + ref_count(1) |
876 | +{ |
877 | + |
878 | +} |
879 | + |
880 | +UApplicationInstance* uamc::Instance::as_u_application_instance() |
881 | +{ |
882 | + return static_cast<UApplicationInstance*>(this); |
883 | +} |
884 | + |
885 | +uamc::Instance* uamc::Instance::from_u_application_instance(UApplicationInstance* u_instance) |
886 | +{ |
887 | + return static_cast<uamc::Instance*>(u_instance); |
888 | +} |
889 | + |
890 | +void uamc::Instance::ref() |
891 | +{ |
892 | + ref_count++; |
893 | +} |
894 | + |
895 | +void uamc::Instance::unref() |
896 | +{ |
897 | + ref_count--; |
898 | + if (ref_count == 0) |
899 | + delete this; |
900 | +} |
901 | + |
902 | +MirConnection* uamc::Instance::connection() const |
903 | +{ |
904 | + return con.get(); |
905 | +} |
906 | + |
907 | +bool uamc::Instance::connect(std::string const& application_name) |
908 | +{ |
909 | + auto mir_connection = mir_connect_sync(NULL, application_name.c_str()); |
910 | + if (mir_connection == nullptr) |
911 | + return false; |
912 | + con = ConnectionPtr(mir_connection, |
913 | + [](MirConnection *c) |
914 | + { |
915 | + mir_connection_release(c); |
916 | + }); |
917 | + return true; |
918 | +} |
919 | |
920 | === added file 'src/mirclient/application_instance_mirclient_priv.h' |
921 | --- src/mirclient/application_instance_mirclient_priv.h 1970-01-01 00:00:00 +0000 |
922 | +++ src/mirclient/application_instance_mirclient_priv.h 2013-06-18 00:07:29 +0000 |
923 | @@ -0,0 +1,68 @@ |
924 | +/* |
925 | + * Copyright (C) 2013 Canonical Ltd |
926 | + * |
927 | + * This program is free software: you can redistribute it and/or modify |
928 | + * it under the terms of the GNU Lesser General Public License version 3 as |
929 | + * published by the Free Software Foundation. |
930 | + * |
931 | + * This program is distributed in the hope that it will be useful, |
932 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
933 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
934 | + * GNU Lesser General Public License for more details. |
935 | + * |
936 | + * You should have received a copy of the GNU Lesser General Public License |
937 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
938 | + * |
939 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
940 | + */ |
941 | + |
942 | +#ifndef UBUNTU_APPLICATION_INSTANCE_MIRCLIENT_PRIV_H_ |
943 | +#define UBUNTU_APPLICATION_INSTANCE_MIRCLIENT_PRIV_H_ |
944 | + |
945 | +#include <ubuntu/application/instance.h> |
946 | + |
947 | +#include <memory> |
948 | +#include <string> |
949 | + |
950 | +#include <mir_toolkit/mir_client_library.h> |
951 | + |
952 | +namespace ubuntu |
953 | +{ |
954 | +namespace application |
955 | +{ |
956 | +namespace mir |
957 | +{ |
958 | +namespace client |
959 | +{ |
960 | + |
961 | +class Instance |
962 | +{ |
963 | +public: |
964 | + Instance(); |
965 | + ~Instance() = default; |
966 | + |
967 | + UApplicationInstance* as_u_application_instance(); |
968 | + static Instance* from_u_application_instance(UApplicationInstance* u_instance); |
969 | + |
970 | + void ref(); |
971 | + void unref(); |
972 | + |
973 | + MirConnection* connection() const; |
974 | + bool connect(std::string const& application_name); |
975 | + |
976 | +protected: |
977 | + Instance(Instance const&) = delete; |
978 | + Instance& operator=(Instance const&) = delete; |
979 | + |
980 | +private: |
981 | + typedef std::unique_ptr<MirConnection, std::function<void(MirConnection*)>> ConnectionPtr; |
982 | + ConnectionPtr con; |
983 | + int ref_count; |
984 | +}; |
985 | + |
986 | +} |
987 | +} |
988 | +} |
989 | +} // namespace ubuntu |
990 | + |
991 | +#endif // UBUNTU_APPLICATION_INSTANCE_MIRCLIENT_PRIV_H_ |
992 | |
993 | === added file 'src/mirclient/ubuntu_application_api_mirclient.cpp' |
994 | --- src/mirclient/ubuntu_application_api_mirclient.cpp 1970-01-01 00:00:00 +0000 |
995 | +++ src/mirclient/ubuntu_application_api_mirclient.cpp 2013-06-18 00:07:29 +0000 |
996 | @@ -0,0 +1,279 @@ |
997 | +/* |
998 | + * Copyright (C) 2013 Canonical Ltd |
999 | + * |
1000 | + * This program is free software: you can redistribute it and/or modify |
1001 | + * it under the terms of the GNU Lesser General Public License version 3 as |
1002 | + * published by the Free Software Foundation. |
1003 | + * |
1004 | + * This program is distributed in the hope that it will be useful, |
1005 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1006 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1007 | + * GNU Lesser General Public License for more details. |
1008 | + * |
1009 | + * You should have received a copy of the GNU Lesser General Public License |
1010 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1011 | + * |
1012 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
1013 | + */ |
1014 | + |
1015 | +#include "application_instance_mirclient_priv.h" |
1016 | +#include "window_properties_mirclient_priv.h" |
1017 | +#include "window_mirclient_priv.h" |
1018 | + |
1019 | +#include "mircommon/application_id_mir_priv.h" |
1020 | + |
1021 | +#include <ubuntu/application/lifecycle_delegate.h> |
1022 | +#include <ubuntu/application/ui/window.h> |
1023 | +#include <ubuntu/application/ui/options.h> |
1024 | +#include <ubuntu/application/ui/session.h> |
1025 | +#include <ubuntu/application/ui/clipboard.h> |
1026 | +#include <ubuntu/application/ui/display.h> |
1027 | +#include <ubuntu/application/sensors/accelerometer.h> |
1028 | +#include <ubuntu/application/sensors/proximity.h> |
1029 | +#include <ubuntu/application/sensors/light.h> |
1030 | + |
1031 | +#include <mir_toolkit/mir_client_library.h> |
1032 | + |
1033 | +#include <stdlib.h> |
1034 | +#include <assert.h> |
1035 | +#include <string.h> |
1036 | + |
1037 | +namespace uam = ubuntu::application::mir; |
1038 | +namespace uamc = uam::client; |
1039 | + |
1040 | +namespace |
1041 | +{ |
1042 | + |
1043 | +// We use a global instance as some platform-api functions, i.e. display_new_with_index |
1044 | +// do not supply dependencies, but a MirConnection is required for all queries. |
1045 | +static uamc::Instance* |
1046 | +global_mir_instance() |
1047 | +{ |
1048 | + // Obviously ref counting is whacky here... |
1049 | + static uamc::Instance instance; |
1050 | + instance.ref(); // We leak a reference, this object can't be destroyed |
1051 | + return &instance; |
1052 | +} |
1053 | + |
1054 | +// Display info |
1055 | +static MirDisplayInfo* |
1056 | +u_display_mir_display(UAUiDisplay *display) |
1057 | +{ |
1058 | + return static_cast<MirDisplayInfo*>(display); |
1059 | +} |
1060 | + |
1061 | +static UAUiDisplay* |
1062 | +mir_display_u_display(MirDisplayInfo *display) |
1063 | +{ |
1064 | + return static_cast<UAUiDisplay*>(display); |
1065 | +} |
1066 | + |
1067 | +}; |
1068 | + |
1069 | +extern "C" |
1070 | +{ |
1071 | + |
1072 | +// TODO<papi>: Eliminate global instance by adding Instance to some functions (i.e. display queries) |
1073 | +// TODO: We can't take ownership of description and options until we get rid of the global instance |
1074 | +// so we leak them. |
1075 | +UApplicationInstance* u_application_instance_new_from_description_with_options(UApplicationDescription* description, UApplicationOptions* options) |
1076 | +{ |
1077 | + auto instance = global_mir_instance(); |
1078 | + |
1079 | + auto id = uam::Id::from_u_application_id(u_application_description_get_application_id(description)); |
1080 | + auto connect_suceeded = instance->connect(id->name); |
1081 | + assert(connect_suceeded); |
1082 | + |
1083 | + return instance->as_u_application_instance(); |
1084 | +} |
1085 | + |
1086 | +void |
1087 | +u_application_instance_ref(UApplicationInstance *u_instance) |
1088 | +{ |
1089 | + auto instance = uamc::Instance::from_u_application_instance(u_instance); |
1090 | + instance->ref(); |
1091 | +} |
1092 | + |
1093 | +void |
1094 | +u_application_instance_unref(UApplicationInstance *u_instance) |
1095 | +{ |
1096 | + auto instance = uamc::Instance::from_u_application_instance(u_instance); |
1097 | + instance->unref(); |
1098 | +} |
1099 | + |
1100 | +void |
1101 | +u_application_instance_destroy(UApplicationInstance *u_instance) |
1102 | +{ |
1103 | + // TODO<papi>: What are the proper semantics here. |
1104 | + u_application_instance_unref(u_instance); |
1105 | +} |
1106 | + |
1107 | +void |
1108 | +u_application_instance_run(UApplicationInstance *instance) |
1109 | +{ |
1110 | + // TODO<papi>: What is this supposed to do? Seems to be no-op on hybris. |
1111 | + (void) instance; |
1112 | +} |
1113 | + |
1114 | +void ua_ui_set_clipboard_content(void* content, size_t content_size) |
1115 | +{ |
1116 | + // TODO<papi,mir>: Implement. We will need a MirConnection |
1117 | + (void) content; |
1118 | + (void) content_size; |
1119 | +} |
1120 | + |
1121 | +void ua_ui_get_clipboard_content(void** out_content, size_t* out_content_size) |
1122 | +{ |
1123 | + // TODO<papi,mir>: Implement, see get_clipboard_comment. |
1124 | + *out_content = NULL; |
1125 | + *out_content_size = 0; |
1126 | +} |
1127 | + |
1128 | +// |
1129 | +// TODO <papi>: We need to expose the EGLNativeDisplay somehow |
1130 | +// |
1131 | + |
1132 | +// TODO <papi>: This function should take an application instance so we can eliminate the global mir instance. |
1133 | +// TODO <mir>: Perhaps this should be noop for Mir as there is no need to construct |
1134 | +// a display object, the connection already has everything we need, as it receives |
1135 | +// the display info at connect time. |
1136 | +UAUiDisplay* ua_ui_display_new_with_index(size_t index) |
1137 | +{ |
1138 | + // TODO<papi,mir>: What are the semantics of index. How should we use it? |
1139 | + (void) index; |
1140 | + auto instance = global_mir_instance(); |
1141 | + |
1142 | + auto display = new MirDisplayInfo; |
1143 | + mir_connection_get_display_info(instance->connection(), display); |
1144 | + |
1145 | + return mir_display_u_display(display); |
1146 | +} |
1147 | + |
1148 | +void ua_ui_display_destroy(UAUiDisplay* display) |
1149 | +{ |
1150 | + auto mir_display = u_display_mir_display(display); |
1151 | + delete mir_display; |
1152 | +} |
1153 | + |
1154 | +uint32_t ua_ui_display_query_horizontal_res(UAUiDisplay* display) |
1155 | +{ |
1156 | + auto mir_display = u_display_mir_display(display); |
1157 | + |
1158 | + // TODO<mir>: Line up return types from mirclient |
1159 | + return static_cast<uint32_t>(mir_display->width); |
1160 | +} |
1161 | + |
1162 | +uint32_t ua_ui_display_query_vertical_res(UAUiDisplay* display) |
1163 | +{ |
1164 | + auto mir_display = u_display_mir_display(display); |
1165 | + |
1166 | + // TODO<mir>: Line up return types from mirclient |
1167 | + return static_cast<uint32_t>(mir_display->height); |
1168 | +} |
1169 | + |
1170 | +EGLNativeDisplayType ua_ui_display_get_native_type(UAUiDisplay* display) |
1171 | +{ |
1172 | + auto instance = global_mir_instance(); |
1173 | + |
1174 | + // TODO<mir>: Careful with this cast |
1175 | + return reinterpret_cast<EGLNativeDisplayType>(mir_connection_get_egl_native_display(instance->connection())); |
1176 | +} |
1177 | + |
1178 | +UAUiWindowProperties* ua_ui_window_properties_new_for_normal_window() |
1179 | +{ |
1180 | + return (new uamc::WindowProperties)->as_u_window_properties(); |
1181 | +} |
1182 | + |
1183 | +void ua_ui_window_properties_destroy(UAUiWindowProperties* u_properties) |
1184 | +{ |
1185 | + auto properties = uamc::WindowProperties::from_u_window_properties(u_properties); |
1186 | + delete properties; |
1187 | +} |
1188 | + |
1189 | +void ua_ui_window_properties_set_titlen(UAUiWindowProperties* u_properties, const char* title, size_t title_length) |
1190 | +{ |
1191 | + auto properties = uamc::WindowProperties::from_u_window_properties(u_properties); |
1192 | + |
1193 | + properties->set_title(title, title_length); |
1194 | +} |
1195 | + |
1196 | +const char* ua_ui_window_properties_get_title(UAUiWindowProperties* u_properties) |
1197 | +{ |
1198 | + auto properties = uamc::WindowProperties::from_u_window_properties(u_properties); |
1199 | + return properties->surface_parameters().name; |
1200 | +} |
1201 | + |
1202 | +void ua_ui_window_properties_set_role(UAUiWindowProperties* properties, UAUiWindowRole role) |
1203 | +{ |
1204 | + // TODO<papi>: Doesn't seem like this is meaningful for mirclient. Perhaps it should leave platform-api. |
1205 | + (void) properties; |
1206 | + (void) role; |
1207 | +} |
1208 | + |
1209 | +void ua_ui_window_properties_set_input_cb_and_ctx(UAUiWindowProperties* u_properties, UAUiWindowInputEventCb cb, void* ctx) |
1210 | +{ |
1211 | + auto properties = uamc::WindowProperties::from_u_window_properties(u_properties); |
1212 | + properties->set_input_cb_and_ctx(cb, ctx); |
1213 | +} |
1214 | + |
1215 | +UAUiWindow* ua_ui_window_new_for_application_with_properties(UApplicationInstance* u_instance, UAUiWindowProperties* u_properties) |
1216 | +{ |
1217 | + auto instance = uamc::Instance::from_u_application_instance(u_instance); |
1218 | + auto properties = uamc::WindowProperties::from_u_window_properties(u_properties); |
1219 | + |
1220 | + auto window = new uamc::Window(*instance, properties); |
1221 | + return window->as_u_window(); |
1222 | +} |
1223 | + |
1224 | +void ua_ui_window_destroy(UAUiWindow* u_window) |
1225 | +{ |
1226 | + auto window = uamc::Window::from_u_window(u_window); |
1227 | + delete window; |
1228 | +} |
1229 | + |
1230 | +UStatus ua_ui_window_move(UAUiWindow* u_window, uint32_t x, uint32_t y) |
1231 | +{ |
1232 | + // TODO<papi,mir>: Implement. Assuming this should exist on mirclient? |
1233 | + (void) u_window; |
1234 | + (void) x; |
1235 | + (void) y; |
1236 | + return (UStatus) 0; |
1237 | +} |
1238 | + |
1239 | +UStatus ua_ui_window_resize(UAUiWindow* u_window, uint32_t width, uint32_t height) |
1240 | +{ |
1241 | + // TODO<mir>: Implement |
1242 | + (void) u_window; |
1243 | + (void) width; |
1244 | + (void) height; |
1245 | + return (UStatus) 0; |
1246 | +} |
1247 | + |
1248 | +UStatus ua_ui_window_hide(UAUiWindow* u_window) |
1249 | +{ |
1250 | + // TODO<mir>: Implement |
1251 | + (void) u_window; |
1252 | + return (UStatus) 0; |
1253 | +} |
1254 | + |
1255 | +UStatus ua_ui_window_show(UAUiWindow* u_window) |
1256 | +{ |
1257 | + // TODO<mir>: Implement |
1258 | + (void) u_window; |
1259 | + return (UStatus) 0; |
1260 | +} |
1261 | + |
1262 | +void ua_ui_window_request_fullscreen(UAUiWindow* u_window) |
1263 | +{ |
1264 | + // TODO<mir>: Implement |
1265 | + (void) u_window; |
1266 | +} |
1267 | + |
1268 | +EGLNativeWindowType ua_ui_window_get_native_type(UAUiWindow* u_window) |
1269 | +{ |
1270 | + auto window = uamc::Window::from_u_window(u_window); |
1271 | + return window->get_native_type(); |
1272 | +} |
1273 | + |
1274 | +// TODO: Sensors |
1275 | +} |
1276 | |
1277 | === added file 'src/mirclient/window_mirclient.cpp' |
1278 | --- src/mirclient/window_mirclient.cpp 1970-01-01 00:00:00 +0000 |
1279 | +++ src/mirclient/window_mirclient.cpp 2013-06-18 00:07:29 +0000 |
1280 | @@ -0,0 +1,128 @@ |
1281 | +/* |
1282 | + * Copyright (C) 2013 Canonical Ltd |
1283 | + * |
1284 | + * This program is free software: you can redistribute it and/or modify |
1285 | + * it under the terms of the GNU Lesser General Public License version 3 as |
1286 | + * published by the Free Software Foundation. |
1287 | + * |
1288 | + * This program is distributed in the hope that it will be useful, |
1289 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1290 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1291 | + * GNU Lesser General Public License for more details. |
1292 | + * |
1293 | + * You should have received a copy of the GNU Lesser General Public License |
1294 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1295 | + * |
1296 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
1297 | + */ |
1298 | + |
1299 | +#include "window_mirclient_priv.h" |
1300 | +#include "application_instance_mirclient_priv.h" |
1301 | +#include "window_properties_mirclient_priv.h" |
1302 | +#include "window_mirclient_priv.h" |
1303 | + |
1304 | +#include "mircommon/event_helpers_mir.h" |
1305 | + |
1306 | +namespace uamc = ubuntu::application::mir::client; |
1307 | +namespace uaum = ubuntu::application::ui::mir; |
1308 | + |
1309 | +namespace ubuntu |
1310 | +{ |
1311 | +namespace application |
1312 | +{ |
1313 | +namespace mir |
1314 | +{ |
1315 | +namespace client |
1316 | +{ |
1317 | + |
1318 | +struct InputContext |
1319 | +{ |
1320 | + UAUiWindowInputEventCb cb; |
1321 | + void *ctx; |
1322 | +}; |
1323 | + |
1324 | +static void |
1325 | +ua_ui_window_mir_handle_event(MirSurface* surface, MirEvent const* mir_ev, void* ctx) |
1326 | +{ |
1327 | + // TODO<mir>: Perhaps this indicates that mirclient library should not pass a surface argument here. |
1328 | + (void) surface; |
1329 | + |
1330 | + Event ubuntu_ev; |
1331 | + uaum::event_to_ubuntu_event(mir_ev, ubuntu_ev); |
1332 | + auto mir_ctx = static_cast<uamc::InputContext*>(ctx); |
1333 | + mir_ctx->cb(mir_ctx->ctx, &ubuntu_ev); |
1334 | +} |
1335 | + |
1336 | +} |
1337 | +} |
1338 | +} |
1339 | +} |
1340 | + |
1341 | +namespace |
1342 | +{ |
1343 | + |
1344 | +static MirPixelFormat |
1345 | +mir_choose_default_pixel_format(MirConnection *connection) |
1346 | +{ |
1347 | + MirDisplayInfo info; |
1348 | + mir_connection_get_display_info(connection, &info); |
1349 | + return info.supported_pixel_format[0]; |
1350 | +} |
1351 | + |
1352 | +static MirSurface* |
1353 | +create_surface_with_parameters(MirConnection *connection, |
1354 | + MirSurfaceParameters parameters) |
1355 | +{ |
1356 | +} |
1357 | + |
1358 | +} |
1359 | + |
1360 | +uamc::Window::Window(uamc::Instance& instance, |
1361 | + uamc::WindowProperties* properties) |
1362 | + : instance(instance) |
1363 | +{ |
1364 | + window_properties = WindowPropertiesPtr(properties, |
1365 | + [](uamc::WindowProperties *p) |
1366 | + { |
1367 | + ua_ui_window_properties_destroy(p->as_u_window_properties()); |
1368 | + }); |
1369 | + |
1370 | + MirSurfaceParameters parameters = properties->surface_parameters(); |
1371 | + auto connection = instance.connection(); |
1372 | + parameters.pixel_format = mir_choose_default_pixel_format(connection); |
1373 | + |
1374 | + auto mir_surface = mir_connection_create_surface_sync(connection, ¶meters); |
1375 | + // TODO: create_surface_sync is unsafe as there is a race between setting the event handler and receiving surfaces |
1376 | + input_ctx = InputContextPtr(new uamc::InputContext{properties->input_cb(), properties->input_context()}, |
1377 | + [](InputContext *c) |
1378 | + { |
1379 | + delete c; |
1380 | + }); |
1381 | + |
1382 | + MirEventDelegate delegate = |
1383 | + { |
1384 | + uamc::ua_ui_window_mir_handle_event, |
1385 | + input_ctx.get() |
1386 | + }; |
1387 | + mir_surface_set_event_handler(mir_surface, &delegate); |
1388 | + surface = SurfacePtr(mir_surface, |
1389 | + [](MirSurface *s) |
1390 | + { |
1391 | + mir_surface_release_sync(s); |
1392 | + }); |
1393 | +} |
1394 | + |
1395 | +UAUiWindow* uamc::Window::as_u_window() |
1396 | +{ |
1397 | + return static_cast<UAUiWindow*>(this); |
1398 | +} |
1399 | + |
1400 | +uamc::Window* uamc::Window::from_u_window(UAUiWindow *u_window) |
1401 | +{ |
1402 | + return static_cast<uamc::Window*>(u_window); |
1403 | +} |
1404 | + |
1405 | +EGLNativeWindowType uamc::Window::get_native_type() |
1406 | +{ |
1407 | + return reinterpret_cast<EGLNativeWindowType>(mir_surface_get_egl_native_window(surface.get())); |
1408 | +} |
1409 | |
1410 | === added file 'src/mirclient/window_mirclient_priv.h' |
1411 | --- src/mirclient/window_mirclient_priv.h 1970-01-01 00:00:00 +0000 |
1412 | +++ src/mirclient/window_mirclient_priv.h 2013-06-18 00:07:29 +0000 |
1413 | @@ -0,0 +1,76 @@ |
1414 | +/* |
1415 | + * Copyright (C) 2013 Canonical Ltd |
1416 | + * |
1417 | + * This program is free software: you can redistribute it and/or modify |
1418 | + * it under the terms of the GNU Lesser General Public License version 3 as |
1419 | + * published by the Free Software Foundation. |
1420 | + * |
1421 | + * This program is distributed in the hope that it will be useful, |
1422 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1423 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1424 | + * GNU Lesser General Public License for more details. |
1425 | + * |
1426 | + * You should have received a copy of the GNU Lesser General Public License |
1427 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1428 | + * |
1429 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
1430 | + */ |
1431 | + |
1432 | +#ifndef UBUNTU_APPLICATION_UI_WINDOW_MIRCLIENT_PRIV_H_ |
1433 | +#define UBUNTU_APPLICATION_UI_WINDOW_MIRCLIENT_PRIV_H_ |
1434 | + |
1435 | +#include <ubuntu/application/ui/window.h> |
1436 | +#include <mir_toolkit/mir_client_library.h> |
1437 | + |
1438 | +#include <EGL/egl.h> |
1439 | + |
1440 | +#include <stddef.h> |
1441 | + |
1442 | +#include <functional> |
1443 | +#include <memory> |
1444 | +#include <string> |
1445 | + |
1446 | +namespace ubuntu |
1447 | +{ |
1448 | +namespace application |
1449 | +{ |
1450 | +namespace mir |
1451 | +{ |
1452 | +namespace client |
1453 | +{ |
1454 | +class Instance; |
1455 | +class WindowProperties; |
1456 | +struct InputContext; |
1457 | + |
1458 | +class Window |
1459 | +{ |
1460 | +public: |
1461 | + Window(Instance& instance, WindowProperties* window); |
1462 | + ~Window() = default; |
1463 | + |
1464 | + UAUiWindow* as_u_window(); |
1465 | + static Window* from_u_window(UAUiWindow* u_window); |
1466 | + |
1467 | + EGLNativeWindowType get_native_type(); |
1468 | +protected: |
1469 | + Window(Window const&) = delete; |
1470 | + Window& operator=(Window const&) = delete; |
1471 | + |
1472 | +private: |
1473 | + Instance& instance; |
1474 | + |
1475 | + typedef std::unique_ptr<WindowProperties, std::function<void(WindowProperties*)>> WindowPropertiesPtr; |
1476 | + typedef std::unique_ptr<MirSurface, std::function<void(MirSurface*)>> SurfacePtr; |
1477 | + typedef std::unique_ptr<InputContext, std::function<void(InputContext*)>> InputContextPtr; |
1478 | + |
1479 | + WindowPropertiesPtr window_properties; |
1480 | + SurfacePtr surface; |
1481 | + InputContextPtr input_ctx; |
1482 | +}; |
1483 | + |
1484 | +} |
1485 | +} |
1486 | +} |
1487 | +} |
1488 | + |
1489 | +#endif // UBUNTU_APPLICATION_UI_WINDOW_MIRCLIENT_PRIV_H_ |
1490 | |
1491 | === added file 'src/mirclient/window_properties_mirclient.cpp' |
1492 | --- src/mirclient/window_properties_mirclient.cpp 1970-01-01 00:00:00 +0000 |
1493 | +++ src/mirclient/window_properties_mirclient.cpp 2013-06-18 00:07:29 +0000 |
1494 | @@ -0,0 +1,68 @@ |
1495 | +/* |
1496 | + * Copyright (C) 2013 Canonical Ltd |
1497 | + * |
1498 | + * This program is free software: you can redistribute it and/or modify |
1499 | + * it under the terms of the GNU Lesser General Public License version 3 as |
1500 | + * published by the Free Software Foundation. |
1501 | + * |
1502 | + * This program is distributed in the hope that it will be useful, |
1503 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1504 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1505 | + * GNU Lesser General Public License for more details. |
1506 | + * |
1507 | + * You should have received a copy of the GNU Lesser General Public License |
1508 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1509 | + * |
1510 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
1511 | + */ |
1512 | + |
1513 | +#include "window_properties_mirclient_priv.h" |
1514 | + |
1515 | +namespace uamc = ubuntu::application::mir::client; |
1516 | + |
1517 | +uamc::WindowProperties::WindowProperties() |
1518 | + : cb(nullptr), |
1519 | + input_ctx(nullptr) |
1520 | +{ |
1521 | + parameters.name = nullptr; |
1522 | + parameters.width = 0; |
1523 | + parameters.height = 0; |
1524 | + parameters.buffer_usage = mir_buffer_usage_hardware; |
1525 | +} |
1526 | + |
1527 | +UAUiWindowProperties* uamc::WindowProperties::as_u_window_properties() |
1528 | +{ |
1529 | + return static_cast<UAUiWindowProperties*>(this); |
1530 | +} |
1531 | +uamc::WindowProperties* uamc::WindowProperties::from_u_window_properties(UAUiWindowProperties* u_properties) |
1532 | +{ |
1533 | + return static_cast<uamc::WindowProperties*>(u_properties); |
1534 | +} |
1535 | + |
1536 | +void uamc::WindowProperties::set_title(char const* window_title, size_t length) |
1537 | +{ |
1538 | + title = std::string(window_title, length); |
1539 | + parameters.name = title.c_str(); |
1540 | +} |
1541 | + |
1542 | +void uamc::WindowProperties::set_input_cb_and_ctx(UAUiWindowInputEventCb callback, void* ctx) |
1543 | +{ |
1544 | + cb = callback; |
1545 | + input_ctx = ctx; |
1546 | +} |
1547 | + |
1548 | +MirSurfaceParameters const& uamc::WindowProperties::surface_parameters() const |
1549 | +{ |
1550 | + return parameters; |
1551 | +} |
1552 | + |
1553 | +UAUiWindowInputEventCb uamc::WindowProperties::input_cb() const |
1554 | +{ |
1555 | + return cb; |
1556 | +} |
1557 | + |
1558 | +void* uamc::WindowProperties::input_context() const |
1559 | +{ |
1560 | + return input_ctx; |
1561 | +} |
1562 | + |
1563 | |
1564 | === added file 'src/mirclient/window_properties_mirclient_priv.h' |
1565 | --- src/mirclient/window_properties_mirclient_priv.h 1970-01-01 00:00:00 +0000 |
1566 | +++ src/mirclient/window_properties_mirclient_priv.h 2013-06-18 00:07:29 +0000 |
1567 | @@ -0,0 +1,72 @@ |
1568 | +/* |
1569 | + * Copyright (C) 2013 Canonical Ltd |
1570 | + * |
1571 | + * This program is free software: you can redistribute it and/or modify |
1572 | + * it under the terms of the GNU Lesser General Public License version 3 as |
1573 | + * published by the Free Software Foundation. |
1574 | + * |
1575 | + * This program is distributed in the hope that it will be useful, |
1576 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1577 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1578 | + * GNU Lesser General Public License for more details. |
1579 | + * |
1580 | + * You should have received a copy of the GNU Lesser General Public License |
1581 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1582 | + * |
1583 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
1584 | + */ |
1585 | + |
1586 | +#ifndef UBUNTU_APPLICATION_UI_WINDOW_PROPERTIES_MIRCLIENT_PRIV_H_ |
1587 | +#define UBUNTU_APPLICATION_UI_WINDOW_PROPERTIES_MIRCLIENT_PRIV_H_ |
1588 | + |
1589 | +#include <ubuntu/application/ui/window.h> |
1590 | +#include <mir_toolkit/mir_client_library.h> |
1591 | + |
1592 | +#include <stddef.h> |
1593 | + |
1594 | +#include <string> |
1595 | + |
1596 | +namespace ubuntu |
1597 | +{ |
1598 | +namespace application |
1599 | +{ |
1600 | +namespace mir |
1601 | +{ |
1602 | +namespace client |
1603 | +{ |
1604 | + |
1605 | +class WindowProperties |
1606 | +{ |
1607 | +public: |
1608 | + WindowProperties(); |
1609 | + ~WindowProperties() = default; |
1610 | + |
1611 | + UAUiWindowProperties* as_u_window_properties(); |
1612 | + static WindowProperties* from_u_window_properties(UAUiWindowProperties* u_properties); |
1613 | + |
1614 | + void set_title(char const* title, size_t length); |
1615 | + void set_input_cb_and_ctx(UAUiWindowInputEventCb cb, void* ctx); |
1616 | + |
1617 | + MirSurfaceParameters const& surface_parameters() const; |
1618 | + UAUiWindowInputEventCb input_cb() const; |
1619 | + void* input_context() const; |
1620 | + |
1621 | +protected: |
1622 | + WindowProperties(WindowProperties const&) = delete; |
1623 | + WindowProperties& operator=(WindowProperties const&) = delete; |
1624 | + |
1625 | +private: |
1626 | + MirSurfaceParameters parameters; |
1627 | + |
1628 | + std::string title; |
1629 | + |
1630 | + UAUiWindowInputEventCb cb; |
1631 | + void *input_ctx; |
1632 | +}; |
1633 | + |
1634 | +} |
1635 | +} |
1636 | +} |
1637 | +} |
1638 | + |
1639 | +#endif // UBUNTU_APPLICATION_UI_WINDOW_PROPERTIES_MIRCLIENT_PRIV_H_ |
1640 | |
1641 | === added directory 'src/mircommon' |
1642 | === added file 'src/mircommon/CMakeLists.txt' |
1643 | --- src/mircommon/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1644 | +++ src/mircommon/CMakeLists.txt 2013-06-18 00:07:29 +0000 |
1645 | @@ -0,0 +1,44 @@ |
1646 | +set(SOURCES |
1647 | + event_helpers_mir.cpp |
1648 | + application_id_mir.cpp |
1649 | + application_options_mir.cpp |
1650 | + application_description_mir.cpp |
1651 | + lifecycle_delegate_mir.cpp |
1652 | + session_mir.cpp |
1653 | +) |
1654 | + |
1655 | +set(LINK_LIBRARIES |
1656 | + ${MIR_COMMON_LDFLAGS} ${MIR_COMMON_LIBRARIES} |
1657 | +) |
1658 | + |
1659 | +if(ENABLE_HYBRIS_IMPLEMENTATION) |
1660 | + list(APPEND SOURCES |
1661 | + ../hybris/hybris_bridge.cpp |
1662 | + ../hybris/ubuntu_application_sensors_hybris.cpp |
1663 | + ) |
1664 | + list(APPEND LINK_LIBRARIES |
1665 | + hybris-common |
1666 | + ) |
1667 | +else() |
1668 | + list(APPEND SOURCES |
1669 | + ubuntu_application_sensors_desktop.cpp |
1670 | + ) |
1671 | +endif() |
1672 | + |
1673 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC --std=c++11") |
1674 | + |
1675 | +include_directories( |
1676 | + ${MIRCOMMON_INCLUDE_DIRS} |
1677 | +) |
1678 | + |
1679 | +add_library( |
1680 | + ubuntu_application_api_mircommon STATIC |
1681 | + ${SOURCES} |
1682 | +) |
1683 | + |
1684 | +target_link_libraries( |
1685 | + ubuntu_application_api_mircommon |
1686 | + ${LINK_LIBRARIES} |
1687 | +) |
1688 | + |
1689 | + |
1690 | |
1691 | === added file 'src/mircommon/application_description_mir.cpp' |
1692 | --- src/mircommon/application_description_mir.cpp 1970-01-01 00:00:00 +0000 |
1693 | +++ src/mircommon/application_description_mir.cpp 2013-06-18 00:07:29 +0000 |
1694 | @@ -0,0 +1,94 @@ |
1695 | +/* |
1696 | + * Copyright (C) 2013 Canonical Ltd |
1697 | + * |
1698 | + * This program is free software: you can redistribute it and/or modify |
1699 | + * it under the terms of the GNU Lesser General Public License version 3 as |
1700 | + * published by the Free Software Foundation. |
1701 | + * |
1702 | + * This program is distributed in the hope that it will be useful, |
1703 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1704 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1705 | + * GNU Lesser General Public License for more details. |
1706 | + * |
1707 | + * You should have received a copy of the GNU Lesser General Public License |
1708 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1709 | + * |
1710 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
1711 | + */ |
1712 | + |
1713 | +#include "application_description_mir_priv.h" |
1714 | + |
1715 | +namespace uam = ubuntu::application::mir; |
1716 | + |
1717 | +uam::Description::Description() |
1718 | + : application_id(nullptr), |
1719 | + lifecycle_delegate(nullptr) |
1720 | +{ |
1721 | +} |
1722 | + |
1723 | +UApplicationDescription* uam::Description::as_u_application_description() |
1724 | +{ |
1725 | + return static_cast<UApplicationDescription*>(this); |
1726 | +} |
1727 | + |
1728 | +uam::Description* uam::Description::from_u_application_description(UApplicationDescription* description) |
1729 | +{ |
1730 | + return static_cast<uam::Description*>(description); |
1731 | +} |
1732 | + |
1733 | +UApplicationDescription* |
1734 | +u_application_description_new() |
1735 | +{ |
1736 | + auto description = new uam::Description(); |
1737 | + return description->as_u_application_description(); |
1738 | +} |
1739 | + |
1740 | +void |
1741 | +u_application_description_destroy(UApplicationDescription *u_description) |
1742 | +{ |
1743 | + auto description = uam::Description::from_u_application_description(u_description); |
1744 | + delete description; |
1745 | +} |
1746 | + |
1747 | +void |
1748 | +u_application_description_set_application_id(UApplicationDescription *u_description, |
1749 | + UApplicationId *id) |
1750 | +{ |
1751 | + auto description = uam::Description::from_u_application_description(u_description); |
1752 | + |
1753 | + description->application_id = std::unique_ptr<UApplicationId, std::function<void(UApplicationId*)>>(id, |
1754 | + [](UApplicationId *p) |
1755 | + { |
1756 | + u_application_id_destroy(p); |
1757 | + }); |
1758 | +} |
1759 | + |
1760 | +UApplicationId* |
1761 | +u_application_description_get_application_id(UApplicationDescription *u_description) |
1762 | +{ |
1763 | + auto description = uam::Description::from_u_application_description(u_description); |
1764 | + return description->application_id.get(); |
1765 | +} |
1766 | + |
1767 | +void |
1768 | +u_application_description_set_application_lifecycle_delegate(UApplicationDescription *u_description, |
1769 | + UApplicationLifecycleDelegate *lifecycle_delegate) |
1770 | +{ |
1771 | + auto description = uam::Description::from_u_application_description(u_description); |
1772 | + |
1773 | + // TODO: We don't take a ref as it is created with a floating ref but this should be made more explicit... |
1774 | + description->lifecycle_delegate = |
1775 | + std::unique_ptr<UApplicationLifecycleDelegate, std::function<void(UApplicationLifecycleDelegate*)>>(lifecycle_delegate, |
1776 | + [](UApplicationLifecycleDelegate *p) |
1777 | + { |
1778 | + u_application_lifecycle_delegate_unref(p); |
1779 | + }); |
1780 | + |
1781 | +} |
1782 | + |
1783 | +UApplicationLifecycleDelegate* |
1784 | +u_application_description_get_application_lifecycle_delegate(UApplicationDescription *u_description) |
1785 | +{ |
1786 | + auto description = uam::Description::from_u_application_description(u_description); |
1787 | + return description->lifecycle_delegate.get(); |
1788 | +} |
1789 | |
1790 | === added file 'src/mircommon/application_description_mir_priv.h' |
1791 | --- src/mircommon/application_description_mir_priv.h 1970-01-01 00:00:00 +0000 |
1792 | +++ src/mircommon/application_description_mir_priv.h 2013-06-18 00:07:29 +0000 |
1793 | @@ -0,0 +1,56 @@ |
1794 | +/* |
1795 | + * Copyright (C) 2013 Canonical Ltd |
1796 | + * |
1797 | + * This program is free software: you can redistribute it and/or modify |
1798 | + * it under the terms of the GNU Lesser General Public License version 3 as |
1799 | + * published by the Free Software Foundation. |
1800 | + * |
1801 | + * This program is distributed in the hope that it will be useful, |
1802 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1803 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1804 | + * GNU Lesser General Public License for more details. |
1805 | + * |
1806 | + * You should have received a copy of the GNU Lesser General Public License |
1807 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1808 | + * |
1809 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
1810 | + */ |
1811 | + |
1812 | +#ifndef UBUNTU_APPLICATION_DESCRIPTION_MIR_PRIV_H_ |
1813 | +#define UBUNTU_APPLICATION_DESCRIPTION_MIR_PRIV_H_ |
1814 | + |
1815 | +#include <ubuntu/application/description.h> |
1816 | + |
1817 | +#include <memory> |
1818 | +#include <functional> |
1819 | + |
1820 | +namespace ubuntu |
1821 | +{ |
1822 | +namespace application |
1823 | +{ |
1824 | +namespace mir |
1825 | +{ |
1826 | + |
1827 | +class Description |
1828 | +{ |
1829 | +public: |
1830 | + Description(); |
1831 | + ~Description() = default; |
1832 | + |
1833 | + UApplicationDescription* as_u_application_description(); |
1834 | + static Description* from_u_application_description(UApplicationDescription* u_description); |
1835 | + |
1836 | + // TODO<papi> Do we really own these? |
1837 | + std::unique_ptr<UApplicationId, std::function<void(UApplicationId*)>> application_id; |
1838 | + std::unique_ptr<UApplicationLifecycleDelegate, std::function<void(UApplicationLifecycleDelegate*)>> lifecycle_delegate; |
1839 | + |
1840 | +protected: |
1841 | + Description(Description const&) = delete; |
1842 | + Description& operator=(Description const&) = delete; |
1843 | +}; |
1844 | + |
1845 | +} |
1846 | +} |
1847 | +} // namespace ubuntu |
1848 | + |
1849 | +#endif // UBUNTU_APPLICATION_DESCRIPTION_MIR_PRIV_H_ |
1850 | |
1851 | === added file 'src/mircommon/application_id_mir.cpp' |
1852 | --- src/mircommon/application_id_mir.cpp 1970-01-01 00:00:00 +0000 |
1853 | +++ src/mircommon/application_id_mir.cpp 2013-06-18 00:07:29 +0000 |
1854 | @@ -0,0 +1,56 @@ |
1855 | +/* |
1856 | + * Copyright (C) 2013 Canonical Ltd |
1857 | + * |
1858 | + * This program is free software: you can redistribute it and/or modify |
1859 | + * it under the terms of the GNU Lesser General Public License version 3 as |
1860 | + * published by the Free Software Foundation. |
1861 | + * |
1862 | + * This program is distributed in the hope that it will be useful, |
1863 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1864 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1865 | + * GNU Lesser General Public License for more details. |
1866 | + * |
1867 | + * You should have received a copy of the GNU Lesser General Public License |
1868 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1869 | + * |
1870 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
1871 | + */ |
1872 | + |
1873 | +#include "application_id_mir_priv.h" |
1874 | + |
1875 | +namespace uam = ubuntu::application::mir; |
1876 | + |
1877 | +uam::Id::Id(const char *name, size_t size) |
1878 | + : name(name, size) |
1879 | +{ |
1880 | +} |
1881 | + |
1882 | +UApplicationId* uam::Id::as_u_application_id() |
1883 | +{ |
1884 | + return static_cast<UApplicationId*>(this); |
1885 | +} |
1886 | + |
1887 | +uam::Id* uam::Id::from_u_application_id(UApplicationId *id) |
1888 | +{ |
1889 | + return static_cast<uam::Id*>(id); |
1890 | +} |
1891 | + |
1892 | +UApplicationId* |
1893 | +u_application_id_new_from_stringn(const char *string, size_t size) |
1894 | +{ |
1895 | + auto id = new uam::Id(string, size); |
1896 | + return id->as_u_application_id(); |
1897 | +} |
1898 | + |
1899 | +void u_application_id_destroy(UApplicationId *u_id) |
1900 | +{ |
1901 | + auto id = uam::Id::from_u_application_id(u_id); |
1902 | + delete id; |
1903 | +} |
1904 | + |
1905 | +int u_application_id_compare(UApplicationId* u_lhs, UApplicationId* u_rhs) |
1906 | +{ |
1907 | + auto lhs = uam::Id::from_u_application_id(u_lhs); |
1908 | + auto rhs = uam::Id::from_u_application_id(u_rhs); |
1909 | + return lhs->name.compare(rhs->name); |
1910 | +} |
1911 | |
1912 | === added file 'src/mircommon/application_id_mir_priv.h' |
1913 | --- src/mircommon/application_id_mir_priv.h 1970-01-01 00:00:00 +0000 |
1914 | +++ src/mircommon/application_id_mir_priv.h 2013-06-18 00:07:29 +0000 |
1915 | @@ -0,0 +1,53 @@ |
1916 | +/* |
1917 | + * Copyright (C) 2013 Canonical Ltd |
1918 | + * |
1919 | + * This program is free software: you can redistribute it and/or modify |
1920 | + * it under the terms of the GNU Lesser General Public License version 3 as |
1921 | + * published by the Free Software Foundation. |
1922 | + * |
1923 | + * This program is distributed in the hope that it will be useful, |
1924 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1925 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1926 | + * GNU Lesser General Public License for more details. |
1927 | + * |
1928 | + * You should have received a copy of the GNU Lesser General Public License |
1929 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1930 | + * |
1931 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
1932 | + */ |
1933 | + |
1934 | +#ifndef UBUNTU_APPLICATION_ID_MIR_PRIV_H_ |
1935 | +#define UBUNTU_APPLICATION_ID_MIR_PRIV_H_ |
1936 | + |
1937 | +#include <ubuntu/application/id.h> |
1938 | + |
1939 | +#include <string> |
1940 | + |
1941 | +namespace ubuntu |
1942 | +{ |
1943 | +namespace application |
1944 | +{ |
1945 | +namespace mir |
1946 | +{ |
1947 | + |
1948 | +class Id |
1949 | +{ |
1950 | +public: |
1951 | + Id(const char *name, size_t size); |
1952 | + ~Id() = default; |
1953 | + |
1954 | + UApplicationId* as_u_application_id(); |
1955 | + static Id* from_u_application_id(UApplicationId* id); |
1956 | + |
1957 | + std::string const name; |
1958 | + |
1959 | +protected: |
1960 | + Id(const Id&) = delete; |
1961 | + Id& operator=(const Id&) = delete; |
1962 | +}; |
1963 | + |
1964 | +} |
1965 | +} |
1966 | +} // namespace ubuntu |
1967 | + |
1968 | +#endif // UBUNTU_APPLICATION_ID_MIR_PRIV_H_ |
1969 | |
1970 | === added file 'src/mircommon/application_options_mir.cpp' |
1971 | --- src/mircommon/application_options_mir.cpp 1970-01-01 00:00:00 +0000 |
1972 | +++ src/mircommon/application_options_mir.cpp 2013-06-18 00:07:29 +0000 |
1973 | @@ -0,0 +1,170 @@ |
1974 | +/* |
1975 | + * Copyright (C) 2013 Canonical Ltd |
1976 | + * |
1977 | + * This program is free software: you can redistribute it and/or modify |
1978 | + * it under the terms of the GNU Lesser General Public License version 3 as |
1979 | + * published by the Free Software Foundation. |
1980 | + * |
1981 | + * This program is distributed in the hope that it will be useful, |
1982 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1983 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1984 | + * GNU Lesser General Public License for more details. |
1985 | + * |
1986 | + * You should have received a copy of the GNU Lesser General Public License |
1987 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1988 | + * |
1989 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
1990 | + */ |
1991 | + |
1992 | +#include "application_options_mir_priv.h" |
1993 | + |
1994 | +#include <string.h> |
1995 | +#include <stdio.h> |
1996 | +#include <stdlib.h> |
1997 | +#include <getopt.h> |
1998 | + |
1999 | +#include <tuple> |
2000 | +#include <string> |
2001 | + |
2002 | +namespace uam = ubuntu::application::mir; |
2003 | + |
2004 | +UApplicationOptions* uam::Options::as_u_application_options() |
2005 | +{ |
2006 | + return static_cast<UApplicationOptions*>(this); |
2007 | +} |
2008 | +uam::Options* uam::Options::from_u_application_options(UApplicationOptions* options) |
2009 | +{ |
2010 | + return static_cast<uam::Options*>(options); |
2011 | +} |
2012 | + |
2013 | +namespace |
2014 | +{ |
2015 | + |
2016 | +UAUiStage |
2017 | +string_to_stage(std::string const& s) |
2018 | +{ |
2019 | + if (s == "main_stage") |
2020 | + return U_MAIN_STAGE; |
2021 | + else if (s == "side_stage") |
2022 | + return U_SIDE_STAGE; |
2023 | + else if (s == "share_stage") |
2024 | + return U_SHARE_STAGE; |
2025 | +} |
2026 | + |
2027 | +UAUiFormFactor |
2028 | +string_to_form_factor(std::string const& s) |
2029 | +{ |
2030 | + if (s == "desktop") |
2031 | + return U_DESKTOP; |
2032 | + else if (s == "phone") |
2033 | + return U_PHONE; |
2034 | + else if (s == "tablet") |
2035 | + return U_TABLET; |
2036 | +} |
2037 | + |
2038 | +void print_help_and_exit() |
2039 | +{ |
2040 | + printf("Usage: executable " |
2041 | + "[--form_factor_hint={desktop, phone, tablet}] " |
2042 | + "[--stage_hint={main_stage, side_stage, share_stage}] " |
2043 | + "[--desktop_file_hint=absolute_path_to_desktop_file]\n"); |
2044 | + exit(EXIT_SUCCESS); |
2045 | +} |
2046 | + |
2047 | +} |
2048 | + |
2049 | +extern "C" |
2050 | +{ |
2051 | +UApplicationOptions* |
2052 | +u_application_options_new_from_cmd_line(int argc, char** argv) |
2053 | +{ |
2054 | + static const int uninteresting_flag_value = 0; |
2055 | + static struct option long_options[] = |
2056 | + { |
2057 | + {"form_factor_hint", required_argument, NULL, uninteresting_flag_value}, |
2058 | + {"stage_hint", required_argument, NULL, uninteresting_flag_value}, |
2059 | + {"desktop_file_hint", required_argument, NULL, uninteresting_flag_value}, |
2060 | + {"help", no_argument, NULL, uninteresting_flag_value}, |
2061 | + {0, 0, 0, 0} |
2062 | + }; |
2063 | + |
2064 | + static const int form_factor_hint_index = 0; |
2065 | + static const int stage_hint_index = 1; |
2066 | + static const int desktop_file_hint_index = 2; |
2067 | + static const int help_index = 3; |
2068 | + |
2069 | + auto app_options = new uam::Options; |
2070 | + |
2071 | + while(true) |
2072 | + { |
2073 | + int option_index = 0; |
2074 | + |
2075 | + int c = getopt_long(argc, |
2076 | + argv, |
2077 | + "", |
2078 | + long_options, |
2079 | + &option_index); |
2080 | + |
2081 | + if (c == -1) |
2082 | + break; |
2083 | + |
2084 | + switch (c) |
2085 | + { |
2086 | + case 0: |
2087 | + // If this option set a flag, do nothing else now. |
2088 | + if (long_options[option_index].flag != 0) |
2089 | + break; |
2090 | + if (option_index == help_index) |
2091 | + print_help_and_exit(); |
2092 | + if (optarg) |
2093 | + { |
2094 | + switch(option_index) |
2095 | + { |
2096 | + case form_factor_hint_index: |
2097 | + app_options->form_factor = string_to_form_factor(std::string(optarg)); |
2098 | + break; |
2099 | + case stage_hint_index: |
2100 | + app_options->stage = string_to_stage(std::string(optarg)); |
2101 | + break; |
2102 | + case desktop_file_hint_index: |
2103 | + app_options->desktop_file = std::string(optarg); |
2104 | + break; |
2105 | + } |
2106 | + } |
2107 | + break; |
2108 | + case '?': |
2109 | + break; |
2110 | + } |
2111 | + } |
2112 | + |
2113 | + return app_options->as_u_application_options(); |
2114 | +} |
2115 | + |
2116 | +void |
2117 | +u_application_options_destroy(UApplicationOptions* u_options) |
2118 | +{ |
2119 | + auto options = uam::Options::from_u_application_options(u_options); |
2120 | + delete options; |
2121 | +} |
2122 | + |
2123 | +UApplicationOperationMode |
2124 | +u_application_options_get_operation_mode(UApplicationOptions *u_options) |
2125 | +{ |
2126 | + auto options = uam::Options::from_u_application_options(u_options); |
2127 | + return options->operation_mode; |
2128 | +} |
2129 | + |
2130 | +UAUiFormFactor |
2131 | +u_application_options_get_form_factor(UApplicationOptions* u_options) |
2132 | +{ |
2133 | + auto options = uam::Options::from_u_application_options(u_options); |
2134 | + return options->form_factor; |
2135 | +} |
2136 | + |
2137 | +UAUiStage |
2138 | +u_application_options_get_stage(UApplicationOptions* u_options) |
2139 | +{ |
2140 | + auto options = uam::Options::from_u_application_options(u_options); |
2141 | + return options->stage; |
2142 | +} |
2143 | +} |
2144 | |
2145 | === added file 'src/mircommon/application_options_mir_priv.h' |
2146 | --- src/mircommon/application_options_mir_priv.h 1970-01-01 00:00:00 +0000 |
2147 | +++ src/mircommon/application_options_mir_priv.h 2013-06-18 00:07:29 +0000 |
2148 | @@ -0,0 +1,58 @@ |
2149 | +/* |
2150 | + * Copyright (C) 2013 Canonical Ltd |
2151 | + * |
2152 | + * This program is free software: you can redistribute it and/or modify |
2153 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2154 | + * published by the Free Software Foundation. |
2155 | + * |
2156 | + * This program is distributed in the hope that it will be useful, |
2157 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2158 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2159 | + * GNU Lesser General Public License for more details. |
2160 | + * |
2161 | + * You should have received a copy of the GNU Lesser General Public License |
2162 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2163 | + * |
2164 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
2165 | + */ |
2166 | + |
2167 | +#ifndef UBUNTU_APPLICATION_OPTIONS_MIR_PRIV_H_ |
2168 | +#define UBUNTU_APPLICATION_OPTIONS_MIR_PRIV_H_ |
2169 | + |
2170 | +#include <ubuntu/application/options.h> |
2171 | +#include <ubuntu/application/ui/options.h> |
2172 | + |
2173 | +#include <string> |
2174 | + |
2175 | +namespace ubuntu |
2176 | +{ |
2177 | +namespace application |
2178 | +{ |
2179 | +namespace mir |
2180 | +{ |
2181 | + |
2182 | +class Options |
2183 | +{ |
2184 | +public: |
2185 | + Options() = default; |
2186 | + ~Options() = default; |
2187 | + |
2188 | + UApplicationOptions* as_u_application_options(); |
2189 | + static Options* from_u_application_options(UApplicationOptions* u_options); |
2190 | + |
2191 | + UApplicationOperationMode operation_mode = U_APPLICATION_FOREGROUND_APP; |
2192 | + UAUiFormFactor form_factor = U_DESKTOP; |
2193 | + UAUiStage stage = U_MAIN_STAGE; |
2194 | + |
2195 | + std::string desktop_file; |
2196 | + |
2197 | +protected: |
2198 | + Options(Options const&) = delete; |
2199 | + Options& operator=(Options const&) = delete; |
2200 | +}; |
2201 | + |
2202 | +} |
2203 | +} |
2204 | +} // namespace ubuntu |
2205 | + |
2206 | +#endif // UBUNTU_APPLICATION_OPTIONS_MIR_PRIV_H_ |
2207 | |
2208 | === added file 'src/mircommon/event_helpers_mir.cpp' |
2209 | --- src/mircommon/event_helpers_mir.cpp 1970-01-01 00:00:00 +0000 |
2210 | +++ src/mircommon/event_helpers_mir.cpp 2013-06-18 00:07:29 +0000 |
2211 | @@ -0,0 +1,77 @@ |
2212 | +/* |
2213 | + * Copyright (C) 2013 Canonical Ltd |
2214 | + * |
2215 | + * This program is free software: you can redistribute it and/or modify |
2216 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2217 | + * published by the Free Software Foundation. |
2218 | + * |
2219 | + * This program is distributed in the hope that it will be useful, |
2220 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2221 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2222 | + * GNU Lesser General Public License for more details. |
2223 | + * |
2224 | + * You should have received a copy of the GNU Lesser General Public License |
2225 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2226 | + * |
2227 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
2228 | + */ |
2229 | + |
2230 | +#include "event_helpers_mir.h" |
2231 | + |
2232 | +namespace uaum = ubuntu::application::ui::mir; |
2233 | + |
2234 | +// TODO<mir>: This begs the question: Why does MirEvent exist? It's difficult to ensure this function is kept in sync |
2235 | +// at the unit test level. |
2236 | +void |
2237 | +uaum::event_to_ubuntu_event(MirEvent const* mir_event, Event& ubuntu_ev) |
2238 | +{ |
2239 | + switch (mir_event->type) |
2240 | + { |
2241 | + case mir_event_type_key: |
2242 | + ubuntu_ev.type = KEY_EVENT_TYPE; |
2243 | + ubuntu_ev.device_id = mir_event->key.device_id; |
2244 | + ubuntu_ev.source_id = mir_event->key.source_id; |
2245 | + ubuntu_ev.action = mir_event->key.action; |
2246 | + ubuntu_ev.flags = mir_event->key.flags; |
2247 | + ubuntu_ev.meta_state = mir_event->key.modifiers; |
2248 | + ubuntu_ev.details.key.key_code = mir_event->key.key_code; |
2249 | + ubuntu_ev.details.key.scan_code = mir_event->key.scan_code; |
2250 | + ubuntu_ev.details.key.repeat_count = mir_event->key.repeat_count; |
2251 | + ubuntu_ev.details.key.down_time = mir_event->key.down_time; |
2252 | + ubuntu_ev.details.key.event_time = mir_event->key.event_time; |
2253 | + ubuntu_ev.details.key.is_system_key = mir_event->key.is_system_key; |
2254 | + break; |
2255 | + case mir_event_type_motion: |
2256 | + ubuntu_ev.type = MOTION_EVENT_TYPE; |
2257 | + ubuntu_ev.device_id = mir_event->motion.device_id; |
2258 | + ubuntu_ev.source_id = mir_event->motion.source_id; |
2259 | + ubuntu_ev.action = mir_event->motion.action; |
2260 | + ubuntu_ev.flags = mir_event->motion.flags; |
2261 | + ubuntu_ev.meta_state = mir_event->motion.modifiers; |
2262 | + ubuntu_ev.details.motion.edge_flags = mir_event->motion.edge_flags; |
2263 | + ubuntu_ev.details.motion.button_state = mir_event->motion.button_state; |
2264 | + ubuntu_ev.details.motion.x_offset = mir_event->motion.x_offset; |
2265 | + ubuntu_ev.details.motion.y_offset = mir_event->motion.y_offset; |
2266 | + ubuntu_ev.details.motion.x_precision = mir_event->motion.x_precision; |
2267 | + ubuntu_ev.details.motion.y_precision = mir_event->motion.y_precision; |
2268 | + ubuntu_ev.details.motion.down_time = mir_event->motion.down_time; |
2269 | + ubuntu_ev.details.motion.event_time = mir_event->motion.event_time; |
2270 | + ubuntu_ev.details.motion.pointer_count = mir_event->motion.pointer_count; |
2271 | + for (int i = 0; i < mir_event->motion.pointer_count; i++) |
2272 | + { |
2273 | + ubuntu_ev.details.motion.pointer_coordinates[i].id = mir_event->motion.pointer_coordinates[i].id; |
2274 | + ubuntu_ev.details.motion.pointer_coordinates[i].x = mir_event->motion.pointer_coordinates[i].x; |
2275 | + ubuntu_ev.details.motion.pointer_coordinates[i].raw_x = mir_event->motion.pointer_coordinates[i].raw_x; |
2276 | + ubuntu_ev.details.motion.pointer_coordinates[i].y = mir_event->motion.pointer_coordinates[i].y; |
2277 | + ubuntu_ev.details.motion.pointer_coordinates[i].raw_y = mir_event->motion.pointer_coordinates[i].raw_y; |
2278 | + ubuntu_ev.details.motion.pointer_coordinates[i].touch_major = mir_event->motion.pointer_coordinates[i].touch_major; |
2279 | + ubuntu_ev.details.motion.pointer_coordinates[i].touch_minor = mir_event->motion.pointer_coordinates[i].touch_minor; |
2280 | + ubuntu_ev.details.motion.pointer_coordinates[i].size = mir_event->motion.pointer_coordinates[i].size; |
2281 | + ubuntu_ev.details.motion.pointer_coordinates[i].pressure = mir_event->motion.pointer_coordinates[i].pressure; |
2282 | + ubuntu_ev.details.motion.pointer_coordinates[i].orientation = mir_event->motion.pointer_coordinates[i].orientation; |
2283 | + } |
2284 | + break; |
2285 | + default: |
2286 | + break; |
2287 | + } |
2288 | +} |
2289 | |
2290 | === added file 'src/mircommon/event_helpers_mir.h' |
2291 | --- src/mircommon/event_helpers_mir.h 1970-01-01 00:00:00 +0000 |
2292 | +++ src/mircommon/event_helpers_mir.h 2013-06-18 00:07:29 +0000 |
2293 | @@ -0,0 +1,39 @@ |
2294 | +/* |
2295 | + * Copyright (C) 2013 Canonical Ltd |
2296 | + * |
2297 | + * This program is free software: you can redistribute it and/or modify |
2298 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2299 | + * published by the Free Software Foundation. |
2300 | + * |
2301 | + * This program is distributed in the hope that it will be useful, |
2302 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2303 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2304 | + * GNU Lesser General Public License for more details. |
2305 | + * |
2306 | + * You should have received a copy of the GNU Lesser General Public License |
2307 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2308 | + * |
2309 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
2310 | + */ |
2311 | + |
2312 | +#ifndef UBUNTU_EVENT_HELPERS_MIR_COMMON_H_ |
2313 | +#define UBUNTU_EVENT_HELPERS_MIR_COMMON_H_ |
2314 | + |
2315 | +#include <ubuntu/application/ui/input/event.h> |
2316 | +#include <mir_toolkit/event.h> |
2317 | + |
2318 | +namespace ubuntu |
2319 | +{ |
2320 | +namespace application |
2321 | +{ |
2322 | +namespace ui |
2323 | +{ |
2324 | +namespace mir |
2325 | +{ |
2326 | +void event_to_ubuntu_event(MirEvent const* mir_event, Event& ubuntu_ev); |
2327 | +} |
2328 | +} |
2329 | +} |
2330 | +} |
2331 | + |
2332 | +#endif // UBUNTU_EVENT_HELPERS_MIR_COMMON_H_ |
2333 | |
2334 | === added file 'src/mircommon/lifecycle_delegate_mir.cpp' |
2335 | --- src/mircommon/lifecycle_delegate_mir.cpp 1970-01-01 00:00:00 +0000 |
2336 | +++ src/mircommon/lifecycle_delegate_mir.cpp 2013-06-18 00:07:29 +0000 |
2337 | @@ -0,0 +1,136 @@ |
2338 | +/* |
2339 | + * Copyright (C) 2013 Canonical Ltd |
2340 | + * |
2341 | + * This program is free software: you can redistribute it and/or modify |
2342 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2343 | + * published by the Free Software Foundation. |
2344 | + * |
2345 | + * This program is distributed in the hope that it will be useful, |
2346 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2347 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2348 | + * GNU Lesser General Public License for more details. |
2349 | + * |
2350 | + * You should have received a copy of the GNU Lesser General Public License |
2351 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2352 | + * |
2353 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
2354 | + */ |
2355 | + |
2356 | +#include "lifecycle_delegate_mir_priv.h" |
2357 | + |
2358 | +namespace uam = ubuntu::application::mir; |
2359 | + |
2360 | +// TODO<papi, mir>: This implementation as a stub as we |
2361 | +// currently don't do anything with this in Mir. I am not sure |
2362 | +// what exactly we should be doing either so we need some alignment |
2363 | +// on this. |
2364 | + |
2365 | +uam::LifecycleDelegate::LifecycleDelegate() |
2366 | + : resumed_cb(nullptr), |
2367 | + stop_cb(nullptr), |
2368 | + ctx(nullptr) |
2369 | +{ |
2370 | +} |
2371 | + |
2372 | +UApplicationLifecycleDelegate* uam::LifecycleDelegate::as_u_lifecycle_delegate() |
2373 | +{ |
2374 | + return static_cast<UApplicationLifecycleDelegate*>(this); |
2375 | +} |
2376 | + |
2377 | +uam::LifecycleDelegate* uam::LifecycleDelegate::from_u_lifecycle_delegate(UApplicationLifecycleDelegate *u_delegate) |
2378 | +{ |
2379 | + return static_cast<uam::LifecycleDelegate*>(u_delegate); |
2380 | +} |
2381 | + |
2382 | +void uam::LifecycleDelegate::ref() |
2383 | +{ |
2384 | + ref_count++; |
2385 | +} |
2386 | + |
2387 | +void uam::LifecycleDelegate::unref() |
2388 | +{ |
2389 | + ref_count--; |
2390 | + if (ref_count == 0) |
2391 | + delete this; |
2392 | +} |
2393 | + |
2394 | + |
2395 | +extern "C" |
2396 | +{ |
2397 | + |
2398 | +UApplicationLifecycleDelegate* |
2399 | +u_application_lifecycle_delegate_new() |
2400 | +{ |
2401 | + return (new uam::LifecycleDelegate)->as_u_lifecycle_delegate(); |
2402 | +} |
2403 | + |
2404 | +void |
2405 | +u_application_lifecycle_delegate_destroy(UApplicationLifecycleDelegate *u_delegate) |
2406 | +{ |
2407 | + auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate); |
2408 | + |
2409 | + // TODO: What are the intended semantics of this? |
2410 | + delegate->unref(); |
2411 | +} |
2412 | + |
2413 | +void |
2414 | +u_application_lifecycle_delegate_ref(UApplicationLifecycleDelegate *u_delegate) |
2415 | +{ |
2416 | + auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate); |
2417 | + delegate->ref(); |
2418 | +} |
2419 | + |
2420 | +void |
2421 | +u_application_lifecycle_delegate_unref(UApplicationLifecycleDelegate *u_delegate) |
2422 | +{ |
2423 | + auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate); |
2424 | + delegate->unref(); |
2425 | +} |
2426 | + |
2427 | +void |
2428 | +u_application_lifecycle_delegate_set_application_resumed_cb(UApplicationLifecycleDelegate *u_delegate, |
2429 | + u_on_application_resumed cb) |
2430 | +{ |
2431 | + auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate); |
2432 | + delegate->resumed_cb = cb; |
2433 | +} |
2434 | + |
2435 | +u_on_application_resumed |
2436 | +u_application_lifecycle_delegate_get_application_resumed_cb(UApplicationLifecycleDelegate *u_delegate) |
2437 | +{ |
2438 | + auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate); |
2439 | + return delegate->resumed_cb; |
2440 | +} |
2441 | + |
2442 | +void |
2443 | +u_application_lifecycle_delegate_set_application_about_to_stop_cb(UApplicationLifecycleDelegate *u_delegate, |
2444 | + u_on_application_about_to_stop cb) |
2445 | +{ |
2446 | + auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate); |
2447 | + delegate->stop_cb = cb; |
2448 | +} |
2449 | + |
2450 | +u_on_application_about_to_stop |
2451 | +u_application_lifecycle_delegate_get_application_about_to_stop_cb(UApplicationLifecycleDelegate *u_delegate) |
2452 | +{ |
2453 | + auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate); |
2454 | + return delegate->stop_cb; |
2455 | +} |
2456 | + |
2457 | +void |
2458 | +u_application_lifecycle_delegate_set_context(UApplicationLifecycleDelegate *u_delegate, |
2459 | + void *context) |
2460 | +{ |
2461 | + auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate); |
2462 | + delegate->ctx = context; |
2463 | +} |
2464 | + |
2465 | +void* |
2466 | +u_application_lifecycle_delegate_get_context(UApplicationLifecycleDelegate *u_delegate, |
2467 | + void *context) |
2468 | +{ |
2469 | + auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate); |
2470 | + return delegate->ctx; |
2471 | +} |
2472 | + |
2473 | +} |
2474 | |
2475 | === added file 'src/mircommon/lifecycle_delegate_mir_priv.h' |
2476 | --- src/mircommon/lifecycle_delegate_mir_priv.h 1970-01-01 00:00:00 +0000 |
2477 | +++ src/mircommon/lifecycle_delegate_mir_priv.h 2013-06-18 00:07:29 +0000 |
2478 | @@ -0,0 +1,59 @@ |
2479 | +/* |
2480 | + * Copyright (C) 2013 Canonical Ltd |
2481 | + * |
2482 | + * This program is free software: you can redistribute it and/or modify |
2483 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2484 | + * published by the Free Software Foundation. |
2485 | + * |
2486 | + * This program is distributed in the hope that it will be useful, |
2487 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2488 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2489 | + * GNU Lesser General Public License for more details. |
2490 | + * |
2491 | + * You should have received a copy of the GNU Lesser General Public License |
2492 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2493 | + * |
2494 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
2495 | + */ |
2496 | + |
2497 | +#ifndef UBUNTU_APPLICATION_LIECYCLE_DELEGATE_MIR_PRIV_H_ |
2498 | +#define UBUNTU_APPLICATION_LIECYCLE_DELEGATE_MIR_PRIV_H_ |
2499 | + |
2500 | +#include <ubuntu/application/lifecycle_delegate.h> |
2501 | + |
2502 | +namespace ubuntu |
2503 | +{ |
2504 | +namespace application |
2505 | +{ |
2506 | +namespace mir |
2507 | +{ |
2508 | + |
2509 | +class LifecycleDelegate |
2510 | +{ |
2511 | +public: |
2512 | + LifecycleDelegate(); |
2513 | + ~LifecycleDelegate() = default; |
2514 | + |
2515 | + UApplicationLifecycleDelegate* as_u_lifecycle_delegate(); |
2516 | + static LifecycleDelegate* from_u_lifecycle_delegate(UApplicationLifecycleDelegate *u_delegate); |
2517 | + |
2518 | + void ref(); |
2519 | + void unref(); |
2520 | + |
2521 | + u_on_application_resumed resumed_cb; |
2522 | + u_on_application_about_to_stop stop_cb; |
2523 | + void *ctx; |
2524 | + |
2525 | +protected: |
2526 | + LifecycleDelegate(LifecycleDelegate const&) = delete; |
2527 | + LifecycleDelegate& operator=(LifecycleDelegate const&) = delete; |
2528 | + |
2529 | +private: |
2530 | + unsigned int ref_count; |
2531 | +}; |
2532 | + |
2533 | +} |
2534 | +} |
2535 | +} |
2536 | + |
2537 | +#endif // UBUNTU_APPLICATION_LIECYCLE_DELEGATE_MIR_PRIV_H_ |
2538 | |
2539 | === added file 'src/mircommon/session_mir.cpp' |
2540 | --- src/mircommon/session_mir.cpp 1970-01-01 00:00:00 +0000 |
2541 | +++ src/mircommon/session_mir.cpp 2013-06-18 00:07:29 +0000 |
2542 | @@ -0,0 +1,43 @@ |
2543 | +/* |
2544 | + * Copyright (C) 2013 Canonical Ltd |
2545 | + * |
2546 | + * This program is free software: you can redistribute it and/or modify |
2547 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2548 | + * published by the Free Software Foundation. |
2549 | + * |
2550 | + * This program is distributed in the hope that it will be useful, |
2551 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2552 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2553 | + * GNU Lesser General Public License for more details. |
2554 | + * |
2555 | + * You should have received a copy of the GNU Lesser General Public License |
2556 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2557 | + * |
2558 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
2559 | + */ |
2560 | + |
2561 | +#include <ubuntu/application/ui/session.h> |
2562 | + |
2563 | +// TODO<papi>: Not sure what this should do for mir. ApplicationInstance maps to the mir |
2564 | +// concept of a session and this doesn't really seem to be used |
2565 | + |
2566 | +extern "C" |
2567 | +{ |
2568 | + |
2569 | +UAUiSession* ua_ui_session_new_with_properties(UAUiSessionProperties *properties) |
2570 | +{ |
2571 | + return nullptr; |
2572 | +} |
2573 | + |
2574 | +UAUiSessionProperties* ua_ui_session_properties_new() |
2575 | +{ |
2576 | + return nullptr; |
2577 | +} |
2578 | + |
2579 | +void ua_ui_session_properties_set_type(UAUiSessionProperties* properties, |
2580 | + UAUiSessionType type) |
2581 | +{ |
2582 | + (void) properties; |
2583 | + (void) type; |
2584 | +} |
2585 | +} |
2586 | |
2587 | === added file 'src/mircommon/ubuntu_application_sensors_desktop.cpp' |
2588 | --- src/mircommon/ubuntu_application_sensors_desktop.cpp 1970-01-01 00:00:00 +0000 |
2589 | +++ src/mircommon/ubuntu_application_sensors_desktop.cpp 2013-06-18 00:07:29 +0000 |
2590 | @@ -0,0 +1,190 @@ |
2591 | +/* |
2592 | + * Copyright (C) 2012 Canonical Ltd |
2593 | + * |
2594 | + * This program is free software: you can redistribute it and/or modify |
2595 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2596 | + * published by the Free Software Foundation. |
2597 | + * |
2598 | + * This program is distributed in the hope that it will be useful, |
2599 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2600 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2601 | + * GNU Lesser General Public License for more details. |
2602 | + * |
2603 | + * You should have received a copy of the GNU Lesser General Public License |
2604 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2605 | + * |
2606 | + * Authored by: Thomas Voss <thomas.voss@canonical.com> |
2607 | + * Ricardo Mendoza <ricardo.mendoza@canonical.com> |
2608 | + */ |
2609 | + |
2610 | +#include <ubuntu/application/sensors/accelerometer.h> |
2611 | +#include <ubuntu/application/sensors/proximity.h> |
2612 | +#include <ubuntu/application/sensors/light.h> |
2613 | + |
2614 | +#include <stddef.h> |
2615 | + |
2616 | +// Ubuntu Application Sensors. Null desktop implementation |
2617 | + |
2618 | +// Acceleration Sensor |
2619 | +UASensorsAccelerometer* ua_sensors_accelerometer_new() |
2620 | +{ |
2621 | + return NULL; |
2622 | +} |
2623 | + |
2624 | +UStatus ua_sensors_accelerometer_enable(UASensorsAccelerometer*) |
2625 | +{ |
2626 | + return (UStatus) 0; |
2627 | +} |
2628 | + |
2629 | +UStatus ua_sensors_accelerometer_disable(UASensorsAccelerometer*) |
2630 | +{ |
2631 | + return (UStatus) 0; |
2632 | +} |
2633 | + |
2634 | +uint32_t ua_sensors_accelerometer_get_min_delay(UASensorsAccelerometer*) |
2635 | +{ |
2636 | + return 0; |
2637 | +} |
2638 | + |
2639 | +float ua_sensors_accelerometer_get_min_value(UASensorsAccelerometer*) |
2640 | +{ |
2641 | + return 0.0; |
2642 | +} |
2643 | + |
2644 | +float ua_sensors_accelerometer_get_max_value(UASensorsAccelerometer*) |
2645 | +{ |
2646 | + return 0.0; |
2647 | +} |
2648 | + |
2649 | +float ua_sensors_accelerometer_get_resolution(UASensorsAccelerometer*) |
2650 | +{ |
2651 | + return 0.0; |
2652 | +} |
2653 | + |
2654 | +void ua_sensors_accelerometer_set_reading_cb(UASensorsAccelerometer*, on_accelerometer_event_cb, void*) |
2655 | +{ |
2656 | +} |
2657 | + |
2658 | +// Acceleration Sensor Event |
2659 | +uint64_t uas_accelerometer_event_get_timestamp(UASAccelerometerEvent*) |
2660 | +{ |
2661 | + return 0; |
2662 | +} |
2663 | + |
2664 | +float uas_accelerometer_event_get_acceleration_x(UASAccelerometerEvent*) |
2665 | +{ |
2666 | + return 0.0; |
2667 | +} |
2668 | + |
2669 | +float uas_accelerometer_event_get_acceleration_y(UASAccelerometerEvent*) |
2670 | +{ |
2671 | + return 0.0; |
2672 | +} |
2673 | + |
2674 | +float uas_accelerometer_event_get_acceleration_z(UASAccelerometerEvent*) |
2675 | +{ |
2676 | + return 0.0; |
2677 | +} |
2678 | + |
2679 | +// Proximity Sensor |
2680 | +UASensorsProximity* ua_sensors_proximity_new() |
2681 | +{ |
2682 | + return NULL; |
2683 | +} |
2684 | + |
2685 | +UStatus ua_sensors_proximity_enable(UASensorsProximity*) |
2686 | +{ |
2687 | + return (UStatus) 0; |
2688 | +} |
2689 | + |
2690 | +UStatus ua_sensors_proximity_disable(UASensorsProximity*) |
2691 | +{ |
2692 | + return (UStatus) 0; |
2693 | +} |
2694 | + |
2695 | +uint32_t ua_sensors_proximity_get_min_delay(UASensorsProximity*) |
2696 | +{ |
2697 | + return 0; |
2698 | +} |
2699 | + |
2700 | +float ua_sensors_proximity_get_min_value(UASensorsProximity*) |
2701 | +{ |
2702 | + return 0.0; |
2703 | +} |
2704 | + |
2705 | +float ua_sensors_proximity_get_max_value(UASensorsProximity*) |
2706 | +{ |
2707 | + return 0.0; |
2708 | +} |
2709 | + |
2710 | +float ua_sensors_proximity_get_resolution(UASensorsProximity*) |
2711 | +{ |
2712 | + return 0.0; |
2713 | +} |
2714 | + |
2715 | +void ua_sensors_proximity_set_reading_cb(UASensorsProximity*, on_proximity_event_cb, void*) |
2716 | +{ |
2717 | +} |
2718 | + |
2719 | +// Proximity Sensor Event |
2720 | +uint64_t uas_proximity_event_get_timestamp(UASProximityEvent*) |
2721 | +{ |
2722 | + return 0; |
2723 | +} |
2724 | + |
2725 | +UASProximityDistance uas_proximity_event_get_distance(UASProximityEvent*) |
2726 | +{ |
2727 | + return (UASProximityDistance) 0; |
2728 | +} |
2729 | + |
2730 | + |
2731 | +// Ambient Light Sensor |
2732 | +UASensorsLight* ua_sensors_light_new() |
2733 | +{ |
2734 | + return NULL; |
2735 | +} |
2736 | + |
2737 | +UStatus ua_sensors_light_enable(UASensorsLight*) |
2738 | +{ |
2739 | + return (UStatus) 0; |
2740 | +} |
2741 | + |
2742 | +UStatus ua_sensors_light_disable(UASensorsLight*) |
2743 | +{ |
2744 | + return (UStatus) 0; |
2745 | +} |
2746 | + |
2747 | +uint32_t ua_sensors_light_get_min_delay(UASensorsLight*) |
2748 | +{ |
2749 | + return 0; |
2750 | +} |
2751 | + |
2752 | +float ua_sensors_light_get_min_value(UASensorsLight*) |
2753 | +{ |
2754 | + return 0.0; |
2755 | +} |
2756 | + |
2757 | +float ua_sensors_light_get_max_value(UASensorsLight*) |
2758 | +{ |
2759 | + return 0.0; |
2760 | +} |
2761 | + |
2762 | +float ua_sensors_light_get_resolution(UASensorsLight*) |
2763 | +{ |
2764 | + return 0.0; |
2765 | +} |
2766 | + |
2767 | +void ua_sensors_light_set_reading_cb(UASensorsLight*, on_light_event_cb, void*) |
2768 | +{ |
2769 | +} |
2770 | + |
2771 | +// Ambient Light Sensor Event |
2772 | +uint64_t uas_light_event_get_timestamp(UASLightEvent*) |
2773 | +{ |
2774 | + return 0; |
2775 | +} |
2776 | + |
2777 | +float uas_light_event_get_light(UASLightEvent*) |
2778 | +{ |
2779 | + return 0.0; |
2780 | +} |
2781 | |
2782 | === added directory 'src/mirserver' |
2783 | === added file 'src/mirserver/CMakeLists.txt' |
2784 | --- src/mirserver/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
2785 | +++ src/mirserver/CMakeLists.txt 2013-06-18 00:07:29 +0000 |
2786 | @@ -0,0 +1,38 @@ |
2787 | +set(SOURCES |
2788 | + ubuntu_application_api_mirserver.cpp |
2789 | + application_instance_mirserver.cpp |
2790 | + window_properties_mirserver.cpp |
2791 | + window_mirserver.cpp |
2792 | +) |
2793 | + |
2794 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -fPIC") |
2795 | + |
2796 | +add_library( |
2797 | + ubuntu_application_api_mirserver SHARED |
2798 | + ${SOURCES} |
2799 | +) |
2800 | + |
2801 | +include_directories( |
2802 | + ${CMAKE_BINARY_DIR}/include |
2803 | + ${MIRSERVER_INCLUDE_DIRS} |
2804 | +) |
2805 | + |
2806 | +target_link_libraries( |
2807 | + ubuntu_application_api_mirserver |
2808 | + ${MIRSERVER_LDFLAGS} ${MIRSERVER_LIBRARIES} |
2809 | + -Wl,--whole-archive ubuntu_application_api_mircommon |
2810 | + -Wl,--no-whole-archive |
2811 | +) |
2812 | + |
2813 | + |
2814 | +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ubuntu_application_api_mirserver_priv.h DESTINATION include/ubuntu/priv/mirserver) |
2815 | + |
2816 | +set_target_properties( |
2817 | + ubuntu_application_api_mirserver |
2818 | + PROPERTIES |
2819 | + VERSION 1.0 |
2820 | + SOVERSION 1 |
2821 | +) |
2822 | + |
2823 | +install(TARGETS ubuntu_application_api_mirserver ${INSTALL_TARGETS_DEFAULT_ARGS}) |
2824 | +install(FILES ubuntu_application_api_mirserver_priv.h DESTINATION include/ubuntu/application) |
2825 | |
2826 | === added file 'src/mirserver/application_instance_mirserver.cpp' |
2827 | --- src/mirserver/application_instance_mirserver.cpp 1970-01-01 00:00:00 +0000 |
2828 | +++ src/mirserver/application_instance_mirserver.cpp 2013-06-18 00:07:29 +0000 |
2829 | @@ -0,0 +1,83 @@ |
2830 | +/* |
2831 | + * Copyright (C) 2013 Canonical Ltd |
2832 | + * |
2833 | + * This program is free software: you can redistribute it and/or modify |
2834 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2835 | + * published by the Free Software Foundation. |
2836 | + * |
2837 | + * This program is distributed in the hope that it will be useful, |
2838 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2839 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2840 | + * GNU Lesser General Public License for more details. |
2841 | + * |
2842 | + * You should have received a copy of the GNU Lesser General Public License |
2843 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2844 | + * |
2845 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
2846 | + */ |
2847 | + |
2848 | +#include "application_instance_mirserver_priv.h" |
2849 | + |
2850 | +#include "mircommon/application_description_mir_priv.h" |
2851 | +#include "mircommon/application_options_mir_priv.h" |
2852 | +#include "mircommon/application_id_mir_priv.h" |
2853 | + |
2854 | +#include <mir/shell/surface.h> |
2855 | +#include <mir/shell/surface_factory.h> |
2856 | +#include <mir/shell/surface_creation_parameters.h> |
2857 | + |
2858 | +namespace uam = ubuntu::application::mir; |
2859 | +namespace uams = uam::server; |
2860 | + |
2861 | +namespace mf = mir::frontend; |
2862 | +namespace me = mir::events; |
2863 | +namespace msh = mir::shell; |
2864 | + |
2865 | +uams::Instance::Instance(std::shared_ptr<msh::SurfaceFactory> const &surface_factory, |
2866 | + uam::Description* description_, |
2867 | + uam::Options *options_) |
2868 | + : surface_factory(surface_factory), |
2869 | + ref_count(1) |
2870 | +{ |
2871 | + description = DescriptionPtr(description_, |
2872 | + [] (uam::Description* p) |
2873 | + { |
2874 | + delete p; |
2875 | + }); |
2876 | + options = OptionsPtr(options_, |
2877 | + [] (uam::Options* p) |
2878 | + { |
2879 | + delete p; |
2880 | + }); |
2881 | +} |
2882 | + |
2883 | +UApplicationInstance* uams::Instance::as_u_application_instance() |
2884 | +{ |
2885 | + return static_cast<UApplicationInstance*>(this); |
2886 | +} |
2887 | + |
2888 | +uams::Instance* uams::Instance::from_u_application_instance(UApplicationInstance *u_instance) |
2889 | +{ |
2890 | + return static_cast<uams::Instance*>(u_instance); |
2891 | +} |
2892 | + |
2893 | +void uams::Instance::ref() |
2894 | +{ |
2895 | + ref_count++; |
2896 | +} |
2897 | + |
2898 | +void uams::Instance::unref() |
2899 | +{ |
2900 | + ref_count--; |
2901 | + if (ref_count == 0) |
2902 | + delete this; |
2903 | +} |
2904 | + |
2905 | +std::shared_ptr<msh::Surface> uams::Instance::create_surface(msh::SurfaceCreationParameters const& parameters) |
2906 | +{ |
2907 | + static std::shared_ptr<me::EventSink> const null_event_sink{nullptr}; |
2908 | + static mf::SurfaceId const default_surface_id{0}; |
2909 | + |
2910 | + return surface_factory->create_surface(parameters, default_surface_id, |
2911 | + null_event_sink); |
2912 | +} |
2913 | |
2914 | === added file 'src/mirserver/application_instance_mirserver_priv.h' |
2915 | --- src/mirserver/application_instance_mirserver_priv.h 1970-01-01 00:00:00 +0000 |
2916 | +++ src/mirserver/application_instance_mirserver_priv.h 2013-06-18 00:07:29 +0000 |
2917 | @@ -0,0 +1,85 @@ |
2918 | +/* |
2919 | + * Copyright (C) 2013 Canonical Ltd |
2920 | + * |
2921 | + * This program is free software: you can redistribute it and/or modify |
2922 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2923 | + * published by the Free Software Foundation. |
2924 | + * |
2925 | + * This program is distributed in the hope that it will be useful, |
2926 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2927 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2928 | + * GNU Lesser General Public License for more details. |
2929 | + * |
2930 | + * You should have received a copy of the GNU Lesser General Public License |
2931 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2932 | + * |
2933 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
2934 | + */ |
2935 | + |
2936 | +#ifndef UBUNTU_APPLICATION_INSTANCE_MIRSERVER_PRIV_H_ |
2937 | +#define UBUNTU_APPLICATION_INSTANCE_MIRSERVER_PRIV_H_ |
2938 | + |
2939 | +#include <ubuntu/application/instance.h> |
2940 | + |
2941 | +#include <memory> |
2942 | +#include <functional> |
2943 | + |
2944 | +namespace mir |
2945 | +{ |
2946 | +namespace shell |
2947 | +{ |
2948 | +class SurfaceCreationParameters; |
2949 | +class Surface; |
2950 | +class SurfaceFactory; |
2951 | +} |
2952 | +} |
2953 | + |
2954 | +namespace ubuntu |
2955 | +{ |
2956 | +namespace application |
2957 | +{ |
2958 | +namespace mir |
2959 | +{ |
2960 | +class Description; |
2961 | +class Options; |
2962 | + |
2963 | +namespace server |
2964 | +{ |
2965 | + |
2966 | +class Instance |
2967 | +{ |
2968 | +public: |
2969 | + Instance(std::shared_ptr< ::mir::shell::SurfaceFactory> const& surface_factory, |
2970 | + ubuntu::application::mir::Description* description, |
2971 | + ubuntu::application::mir::Options *options); |
2972 | + ~Instance() = default; |
2973 | + |
2974 | + UApplicationInstance* as_u_application_instance(); |
2975 | + static Instance* from_u_application_instance(UApplicationInstance* u_instance); |
2976 | + |
2977 | + void ref(); |
2978 | + void unref(); |
2979 | + |
2980 | + std::shared_ptr< ::mir::shell::Surface> create_surface( ::mir::shell::SurfaceCreationParameters const& parameters); |
2981 | + |
2982 | +protected: |
2983 | + Instance(Instance const&) = delete; |
2984 | + Instance& operator=(Instance const&) = delete; |
2985 | + |
2986 | +private: |
2987 | + typedef std::unique_ptr<Description, std::function<void(Description*)>> DescriptionPtr; |
2988 | + typedef std::unique_ptr<Options, std::function<void(Options*)>> OptionsPtr; |
2989 | + |
2990 | + OptionsPtr options; |
2991 | + DescriptionPtr description; |
2992 | + |
2993 | + std::shared_ptr< ::mir::shell::SurfaceFactory> const surface_factory; |
2994 | + int ref_count; |
2995 | +}; |
2996 | + |
2997 | +} |
2998 | +} |
2999 | +} |
3000 | +} // namespace ubuntu |
3001 | + |
3002 | +#endif // UBUNTU_APPLICATION_INSTANCE_MIRSERVER_PRIV_H_ |
3003 | |
3004 | === added file 'src/mirserver/ubuntu_application_api_mirserver.cpp' |
3005 | --- src/mirserver/ubuntu_application_api_mirserver.cpp 1970-01-01 00:00:00 +0000 |
3006 | +++ src/mirserver/ubuntu_application_api_mirserver.cpp 2013-06-18 00:07:29 +0000 |
3007 | @@ -0,0 +1,320 @@ |
3008 | +/* |
3009 | + * Copyright (C) 2013 Canonical Ltd |
3010 | + * |
3011 | + * This program is free software: you can redistribute it and/or modify |
3012 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3013 | + * published by the Free Software Foundation. |
3014 | + * |
3015 | + * This program is distributed in the hope that it will be useful, |
3016 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3017 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3018 | + * GNU Lesser General Public License for more details. |
3019 | + * |
3020 | + * You should have received a copy of the GNU Lesser General Public License |
3021 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3022 | + * |
3023 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
3024 | + */ |
3025 | + |
3026 | +#include "ubuntu_application_api_mirserver_priv.h" |
3027 | +#include "application_instance_mirserver_priv.h" |
3028 | +#include "window_properties_mirserver_priv.h" |
3029 | +#include "window_mirserver_priv.h" |
3030 | + |
3031 | +#include "mircommon/application_id_mir_priv.h" |
3032 | +#include "mircommon/application_description_mir_priv.h" |
3033 | +#include "mircommon/application_options_mir_priv.h" |
3034 | + |
3035 | +// C APIs |
3036 | +#include <ubuntu/application/lifecycle_delegate.h> |
3037 | +#include <ubuntu/application/ui/window.h> |
3038 | +#include <ubuntu/application/ui/options.h> |
3039 | +#include <ubuntu/application/ui/session.h> |
3040 | +#include <ubuntu/application/ui/clipboard.h> |
3041 | +#include <ubuntu/application/ui/display.h> |
3042 | +#include <ubuntu/application/sensors/accelerometer.h> |
3043 | +#include <ubuntu/application/sensors/proximity.h> |
3044 | +#include <ubuntu/application/sensors/light.h> |
3045 | + |
3046 | +#include <mir/default_server_configuration.h> |
3047 | + |
3048 | +#include <mir/graphics/display.h> |
3049 | +#include <mir/graphics/platform.h> |
3050 | +#include <mir/compositor/graphic_buffer_allocator.h> |
3051 | +#include <mir/frontend/session.h> |
3052 | +#include <mir/frontend/shell.h> |
3053 | +#include <mir/shell/surface_creation_parameters.h> |
3054 | +#include <mir/shell/surface.h> |
3055 | +#include <mir/graphics/internal_client.h> |
3056 | +#include <mir/input/input_platform.h> |
3057 | + |
3058 | +#include <assert.h> |
3059 | + |
3060 | +#include <memory> |
3061 | +#include <functional> |
3062 | + |
3063 | +namespace uam = ubuntu::application::mir; |
3064 | +namespace uams = ubuntu::application::mir::server; |
3065 | + |
3066 | +namespace |
3067 | +{ |
3068 | + |
3069 | +struct MirServerContext |
3070 | +{ |
3071 | + std::shared_ptr<mir::graphics::Display> display; |
3072 | + std::shared_ptr<mir::compositor::GraphicBufferAllocator> buffer_allocator; |
3073 | + std::shared_ptr<mir::shell::SurfaceFactory> surface_factory; |
3074 | + std::shared_ptr<mir::input::receiver::InputPlatform> input_platform; |
3075 | + std::shared_ptr<mir::graphics::InternalClient> egl_client; |
3076 | +}; |
3077 | + |
3078 | +MirServerContext * |
3079 | +global_mirserver_context() |
3080 | +{ |
3081 | + static MirServerContext context; |
3082 | + return &context; |
3083 | +} |
3084 | + |
3085 | +extern "C" |
3086 | +{ |
3087 | +void ua_ui_mirserver_init(mir::DefaultServerConfiguration& config) |
3088 | +{ |
3089 | + auto context = global_mirserver_context(); |
3090 | + |
3091 | + context->display = config.the_display(); |
3092 | + context->buffer_allocator = config.the_buffer_allocator(); |
3093 | + context->surface_factory = config.the_shell_surface_factory(); |
3094 | + context->input_platform = mir::input::receiver::InputPlatform::create(); |
3095 | + context->egl_client = config.the_graphics_platform()->create_internal_client(); |
3096 | +} |
3097 | + |
3098 | +void ua_ui_mirserver_finish() |
3099 | +{ |
3100 | + auto context = global_mirserver_context(); |
3101 | + |
3102 | + context->display.reset(); |
3103 | + context->surface_factory.reset(); |
3104 | + context->input_platform.reset(); |
3105 | + context->egl_client.reset(); |
3106 | +} |
3107 | +} |
3108 | + |
3109 | +} |
3110 | + |
3111 | + |
3112 | +extern "C" |
3113 | +{ |
3114 | + |
3115 | +UApplicationInstance* u_application_instance_new_from_description_with_options(UApplicationDescription* u_description, UApplicationOptions* u_options) |
3116 | +{ |
3117 | + auto surface_factory = global_mirserver_context()->surface_factory; |
3118 | + assert(surface_factory); |
3119 | + |
3120 | + auto description = uam::Description::from_u_application_description(u_description); |
3121 | + auto options = uam::Options::from_u_application_options(u_options); |
3122 | + |
3123 | + auto instance = new uams::Instance(surface_factory, description, options); |
3124 | + |
3125 | + return instance->as_u_application_instance(); |
3126 | +} |
3127 | + |
3128 | +void |
3129 | +u_application_instance_ref(UApplicationInstance *u_instance) |
3130 | +{ |
3131 | + auto instance = uams::Instance::from_u_application_instance(u_instance); |
3132 | + instance->ref(); |
3133 | +} |
3134 | + |
3135 | +void |
3136 | +u_application_instance_unref(UApplicationInstance *u_instance) |
3137 | +{ |
3138 | + auto instance = uams::Instance::from_u_application_instance(u_instance); |
3139 | + instance->unref(); |
3140 | +} |
3141 | + |
3142 | +void |
3143 | +u_application_instance_destroy(UApplicationInstance *instance) |
3144 | +{ |
3145 | + // TODO<papi>: What are the proper semantics here. |
3146 | + u_application_instance_unref(instance); |
3147 | +} |
3148 | + |
3149 | +void |
3150 | +u_application_instance_run(UApplicationInstance *instance) |
3151 | +{ |
3152 | + // TODO<papi>: What is this supposed to do? Seems to be no-op on hybris. |
3153 | + (void) instance; |
3154 | +} |
3155 | + |
3156 | +void ua_ui_set_clipboard_content(void* content, size_t content_size) |
3157 | +{ |
3158 | + // TODO<mir,papi>: Implement. Probably need more arguments? |
3159 | + (void) content; |
3160 | + (void) content_size; |
3161 | +} |
3162 | + |
3163 | +void ua_ui_get_clipboard_content(void** out_content, size_t* out_content_size) |
3164 | +{ |
3165 | + // TODO<mir,papi>: Implement |
3166 | + *out_content = NULL; |
3167 | + *out_content_size = 0; |
3168 | +} |
3169 | + |
3170 | +UAUiDisplay* ua_ui_display_new_with_index(size_t index) |
3171 | +{ |
3172 | + // TODO<mir>: Make use of index. This is kind of strangely done... |
3173 | + return reinterpret_cast<UAUiDisplay*>(index); |
3174 | +} |
3175 | + |
3176 | +void ua_ui_display_destroy(UAUiDisplay* display) |
3177 | +{ |
3178 | + // TODO: Implement. Or is this a noop for mirserver? |
3179 | + (void) display; |
3180 | +} |
3181 | + |
3182 | +uint32_t ua_ui_display_query_horizontal_res(UAUiDisplay* display) |
3183 | +{ |
3184 | + (void) display; // TODO<mir>: Multiple displays |
3185 | + |
3186 | + auto mir_display = global_mirserver_context()->display; |
3187 | + assert(mir_display); |
3188 | + |
3189 | + return mir_display->view_area().size.width.as_uint32_t(); |
3190 | +} |
3191 | + |
3192 | +uint32_t ua_ui_display_query_vertical_res(UAUiDisplay* display) |
3193 | +{ |
3194 | + (void) display; // TODO<mir>: Multiple displays |
3195 | + |
3196 | + auto mir_display = global_mirserver_context()->display; |
3197 | + assert(mir_display); |
3198 | + |
3199 | + return mir_display->view_area().size.height.as_uint32_t(); |
3200 | +} |
3201 | + |
3202 | +EGLNativeDisplayType ua_ui_display_get_native_type(UAUiDisplay* display) |
3203 | +{ |
3204 | + auto internal_client = global_mirserver_context()->egl_client; |
3205 | + assert(internal_client); |
3206 | + |
3207 | + return internal_client->egl_native_display(); |
3208 | +} |
3209 | + |
3210 | +namespace |
3211 | +{ |
3212 | +static mir::geometry::PixelFormat choose_pixel_format(std::shared_ptr<mir::compositor::GraphicBufferAllocator> const& allocator) |
3213 | +{ |
3214 | + auto formats = allocator->supported_pixel_formats(); |
3215 | + return formats[0]; |
3216 | +} |
3217 | +} |
3218 | + |
3219 | +UAUiWindowProperties* ua_ui_window_properties_new_for_normal_window() |
3220 | +{ |
3221 | + auto properties = new uams::WindowProperties(); |
3222 | + |
3223 | + return properties->as_u_window_properties(); |
3224 | +} |
3225 | + |
3226 | +void ua_ui_window_properties_destroy(UAUiWindowProperties* u_properties) |
3227 | +{ |
3228 | + auto properties = uams::WindowProperties::from_u_window_properties(u_properties); |
3229 | + delete properties; |
3230 | +} |
3231 | + |
3232 | +void ua_ui_window_properties_set_titlen(UAUiWindowProperties* u_properties, const char* title, size_t title_length) |
3233 | +{ |
3234 | + auto properties = uams::WindowProperties::from_u_window_properties(u_properties); |
3235 | + properties->set_title(title, title_length); |
3236 | +} |
3237 | + |
3238 | +const char* ua_ui_window_properties_get_title(UAUiWindowProperties* u_properties) |
3239 | +{ |
3240 | + auto properties = uams::WindowProperties::from_u_window_properties(u_properties); |
3241 | + return properties->surface_parameters().name.c_str(); |
3242 | +} |
3243 | + |
3244 | +void ua_ui_window_properties_set_role(UAUiWindowProperties* properties, UAUiWindowRole role) |
3245 | +{ |
3246 | + // TODO<papi>: Implement. Or is this a noop for us? |
3247 | + (void) properties; |
3248 | + (void) role; |
3249 | +} |
3250 | + |
3251 | +void ua_ui_window_properties_set_input_cb_and_ctx(UAUiWindowProperties* u_properties, UAUiWindowInputEventCb cb, void* ctx) |
3252 | +{ |
3253 | + auto properties = uams::WindowProperties::from_u_window_properties(u_properties); |
3254 | + properties->set_input_cb_and_ctx(cb, ctx); |
3255 | +} |
3256 | + |
3257 | +UAUiWindow* ua_ui_window_new_for_application_with_properties(UApplicationInstance* u_instance, UAUiWindowProperties* u_properties) |
3258 | +{ |
3259 | + auto input_platform = global_mirserver_context()->input_platform; |
3260 | + assert(input_platform); |
3261 | + auto internal_client = global_mirserver_context()->egl_client; |
3262 | + assert(internal_client); |
3263 | + |
3264 | + auto instance = uams::Instance::from_u_application_instance(u_instance); |
3265 | + auto properties = uams::WindowProperties::from_u_window_properties(u_properties); |
3266 | + |
3267 | + // A bit of a wart. |
3268 | + properties->set_pixel_format(choose_pixel_format(global_mirserver_context()->buffer_allocator)); |
3269 | + |
3270 | + auto window = new uams::Window(*instance, properties, input_platform, internal_client); |
3271 | + |
3272 | + return window->as_u_window(); |
3273 | +} |
3274 | + |
3275 | +void ua_ui_window_destroy(UAUiWindow* u_window) |
3276 | +{ |
3277 | + auto window = uams::Window::from_u_window(u_window); |
3278 | + delete window; |
3279 | +} |
3280 | + |
3281 | +UStatus ua_ui_window_move(UAUiWindow* window, uint32_t x, uint32_t y) |
3282 | +{ |
3283 | + // TODO<mir,papi>: Implement. But should this exist? |
3284 | + (void) window; |
3285 | + (void) x; |
3286 | + (void) y; |
3287 | + return (UStatus) 0; |
3288 | +} |
3289 | + |
3290 | +UStatus ua_ui_window_resize(UAUiWindow* window, uint32_t width, uint32_t height) |
3291 | +{ |
3292 | + // TODO<mir>: Implement |
3293 | + (void) window; |
3294 | + (void) width; |
3295 | + (void) height; |
3296 | + return (UStatus) 0; |
3297 | +} |
3298 | + |
3299 | +UStatus ua_ui_window_hide(UAUiWindow* window) |
3300 | +{ |
3301 | + // TODO<mir>: Implement |
3302 | + (void) window; |
3303 | + return (UStatus) 0; |
3304 | +} |
3305 | + |
3306 | +UStatus ua_ui_window_show(UAUiWindow* window) |
3307 | +{ |
3308 | + // TODO<mir>: Implement |
3309 | + (void) window; |
3310 | + return (UStatus) 0; |
3311 | +} |
3312 | + |
3313 | +void ua_ui_window_request_fullscreen(UAUiWindow* window) |
3314 | +{ |
3315 | + // TODO<mir>: Implement |
3316 | + (void) window; |
3317 | +} |
3318 | + |
3319 | +EGLNativeWindowType ua_ui_window_get_native_type(UAUiWindow* u_window) |
3320 | +{ |
3321 | + auto window = uams::Window::from_u_window(u_window); |
3322 | + |
3323 | + return window->get_native_type(); |
3324 | +} |
3325 | + |
3326 | +// TODO: Sensors |
3327 | +} |
3328 | |
3329 | === added file 'src/mirserver/ubuntu_application_api_mirserver_priv.h' |
3330 | --- src/mirserver/ubuntu_application_api_mirserver_priv.h 1970-01-01 00:00:00 +0000 |
3331 | +++ src/mirserver/ubuntu_application_api_mirserver_priv.h 2013-06-18 00:07:29 +0000 |
3332 | @@ -0,0 +1,41 @@ |
3333 | +/* |
3334 | + * Copyright (C) 2013 Canonical Ltd |
3335 | + * |
3336 | + * This program is free software: you can redistribute it and/or modify |
3337 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3338 | + * published by the Free Software Foundation. |
3339 | + * |
3340 | + * This program is distributed in the hope that it will be useful, |
3341 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3342 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3343 | + * GNU Lesser General Public License for more details. |
3344 | + * |
3345 | + * You should have received a copy of the GNU Lesser General Public License |
3346 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3347 | + * |
3348 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
3349 | + */ |
3350 | + |
3351 | +#ifndef UBUNTU_APPLICATION_API_MIRSERVER_PRIV_H_ |
3352 | +#define UBUNTU_APPLICATION_API_MIRSERVER_PRIV_H_ |
3353 | + |
3354 | +namespace mir |
3355 | +{ |
3356 | +class DefaultServerConfiguration; |
3357 | +} |
3358 | + |
3359 | +// We need to provide the platform API with Mir server objects as dependency. The analog |
3360 | +// on the client side is of course the named socket for connection to Mir. This should be |
3361 | +// invoked from the run_mir handler prior to creation of a UApplicationInstance or usage of |
3362 | +// any ua_ui functions. |
3363 | + |
3364 | +extern "C" |
3365 | +{ |
3366 | +void ua_ui_mirserver_init(mir::DefaultServerConfiguration& config); |
3367 | + |
3368 | +// Release platform-api ownership of Mir server objects to allow for clean shutdown. |
3369 | +void ua_ui_mirserver_finish(); |
3370 | +} |
3371 | + |
3372 | +#endif // UBUNTU_APPLICATION_API_MIRSERVER_PRIV_H_ |
3373 | + |
3374 | |
3375 | === added file 'src/mirserver/window_mirserver.cpp' |
3376 | --- src/mirserver/window_mirserver.cpp 1970-01-01 00:00:00 +0000 |
3377 | +++ src/mirserver/window_mirserver.cpp 2013-06-18 00:07:29 +0000 |
3378 | @@ -0,0 +1,81 @@ |
3379 | +/* |
3380 | + * Copyright (C) 2013 Canonical Ltd |
3381 | + * |
3382 | + * This program is free software: you can redistribute it and/or modify |
3383 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3384 | + * published by the Free Software Foundation. |
3385 | + * |
3386 | + * This program is distributed in the hope that it will be useful, |
3387 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3388 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3389 | + * GNU Lesser General Public License for more details. |
3390 | + * |
3391 | + * You should have received a copy of the GNU Lesser General Public License |
3392 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3393 | + * |
3394 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
3395 | + */ |
3396 | + |
3397 | +#include "mircommon/event_helpers_mir.h" |
3398 | + |
3399 | +#include "window_mirserver_priv.h" |
3400 | +#include "application_instance_mirserver_priv.h" |
3401 | +#include "window_properties_mirserver_priv.h" |
3402 | + |
3403 | + |
3404 | +#include <mir/shell/surface.h> |
3405 | +#include <mir/input/input_platform.h> |
3406 | +#include <mir/input/input_receiver_thread.h> |
3407 | +#include <mir/graphics/internal_client.h> |
3408 | + |
3409 | +namespace uams = ubuntu::application::mir::server; |
3410 | +namespace uaum = ubuntu::application::ui::mir; |
3411 | + |
3412 | +namespace mg = mir::graphics; |
3413 | +namespace msh = mir::shell; |
3414 | +namespace mircv = mir::input::receiver; |
3415 | + |
3416 | +namespace |
3417 | +{ |
3418 | + |
3419 | +static void ua_ui_window_handle_event(UAUiWindowInputEventCb cb, void* ctx, MirEvent* mir_event) |
3420 | +{ |
3421 | + Event ubuntu_ev; |
3422 | + uaum::event_to_ubuntu_event(mir_event, ubuntu_ev); |
3423 | + cb(ctx, &ubuntu_ev); |
3424 | +} |
3425 | + |
3426 | +} |
3427 | + |
3428 | +uams::Window::Window(uams::Instance& instance, uams::WindowProperties* properties, |
3429 | + std::shared_ptr<mircv::InputPlatform> const& input_platform, |
3430 | + std::shared_ptr<mg::InternalClient> const& internal_client) |
3431 | + : window_properties(properties), |
3432 | + surface(instance.create_surface(properties->surface_parameters())), |
3433 | + internal_client(internal_client) |
3434 | +{ |
3435 | + input_thread = input_platform->create_input_thread(surface->client_input_fd(), |
3436 | + std::bind(ua_ui_window_handle_event, properties->input_cb(), properties->input_context(), std::placeholders::_1)); |
3437 | + input_thread->start(); |
3438 | +} |
3439 | + |
3440 | +uams::Window::~Window() |
3441 | +{ |
3442 | + input_thread->stop(); |
3443 | + input_thread->join(); |
3444 | +} |
3445 | + |
3446 | +UAUiWindow* uams::Window::as_u_window() |
3447 | +{ |
3448 | + return static_cast<UAUiWindow*>(this); |
3449 | +} |
3450 | + |
3451 | +uams::Window* uams::Window::from_u_window(UAUiWindow *u_window) |
3452 | +{ |
3453 | + return static_cast<uams::Window*>(u_window); |
3454 | +} |
3455 | + |
3456 | +EGLNativeWindowType uams::Window::get_native_type() |
3457 | +{ |
3458 | + return internal_client->egl_native_window(surface); |
3459 | +} |
3460 | |
3461 | === added file 'src/mirserver/window_mirserver_priv.h' |
3462 | --- src/mirserver/window_mirserver_priv.h 1970-01-01 00:00:00 +0000 |
3463 | +++ src/mirserver/window_mirserver_priv.h 2013-06-18 00:07:29 +0000 |
3464 | @@ -0,0 +1,92 @@ |
3465 | +/* |
3466 | + * Copyright (C) 2013 Canonical Ltd |
3467 | + * |
3468 | + * This program is free software: you can redistribute it and/or modify |
3469 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3470 | + * published by the Free Software Foundation. |
3471 | + * |
3472 | + * This program is distributed in the hope that it will be useful, |
3473 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3474 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3475 | + * GNU Lesser General Public License for more details. |
3476 | + * |
3477 | + * You should have received a copy of the GNU Lesser General Public License |
3478 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3479 | + * |
3480 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
3481 | + */ |
3482 | + |
3483 | +#ifndef UBUNTU_APPLICATION_UI_WINDOW_MIRSERVER_PRIV_H_ |
3484 | +#define UBUNTU_APPLICATION_UI_WINDOW_MIRSERVER_PRIV_H_ |
3485 | + |
3486 | +#include <ubuntu/application/ui/window.h> |
3487 | + |
3488 | +#include <EGL/egl.h> |
3489 | + |
3490 | +#include <stddef.h> |
3491 | + |
3492 | +#include <functional> |
3493 | +#include <memory> |
3494 | +#include <string> |
3495 | + |
3496 | +namespace mir |
3497 | +{ |
3498 | +namespace shell |
3499 | +{ |
3500 | +class Surface; |
3501 | +} |
3502 | +namespace input |
3503 | +{ |
3504 | +namespace receiver |
3505 | +{ |
3506 | +class InputReceiverThread; |
3507 | +class InputPlatform; |
3508 | +} |
3509 | +} |
3510 | +namespace graphics |
3511 | +{ |
3512 | +class InternalClient; |
3513 | +} |
3514 | +} |
3515 | + |
3516 | +namespace ubuntu |
3517 | +{ |
3518 | +namespace application |
3519 | +{ |
3520 | +namespace mir |
3521 | +{ |
3522 | +namespace server |
3523 | +{ |
3524 | +class Instance; |
3525 | +class WindowProperties; |
3526 | + |
3527 | +class Window |
3528 | +{ |
3529 | +public: |
3530 | + Window(Instance& instance, WindowProperties* properties, |
3531 | + std::shared_ptr< ::mir::input::receiver::InputPlatform> const& platform, |
3532 | + std::shared_ptr< ::mir::graphics::InternalClient> const& internal_client); |
3533 | + ~Window(); |
3534 | + |
3535 | + UAUiWindow* as_u_window(); |
3536 | + static Window* from_u_window(UAUiWindow* u_window); |
3537 | + |
3538 | + EGLNativeWindowType get_native_type(); |
3539 | + |
3540 | +protected: |
3541 | + Window(Window const&) = delete; |
3542 | + Window& operator=(Window const&) = delete; |
3543 | + |
3544 | +private: |
3545 | + std::unique_ptr<WindowProperties> window_properties; |
3546 | + std::shared_ptr< ::mir::shell::Surface> surface; |
3547 | + std::shared_ptr< ::mir::input::receiver::InputReceiverThread> input_thread; |
3548 | + std::shared_ptr< ::mir::graphics::InternalClient> internal_client; |
3549 | +}; |
3550 | + |
3551 | +} |
3552 | +} |
3553 | +} |
3554 | +} |
3555 | + |
3556 | +#endif // UBUNTU_APPLICATION_UI_WINDOW_MIRSERVER_PRIV_H_ |
3557 | |
3558 | === added file 'src/mirserver/window_properties_mirserver.cpp' |
3559 | --- src/mirserver/window_properties_mirserver.cpp 1970-01-01 00:00:00 +0000 |
3560 | +++ src/mirserver/window_properties_mirserver.cpp 2013-06-18 00:07:29 +0000 |
3561 | @@ -0,0 +1,73 @@ |
3562 | +/* |
3563 | + * Copyright (C) 2013 Canonical Ltd |
3564 | + * |
3565 | + * This program is free software: you can redistribute it and/or modify |
3566 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3567 | + * published by the Free Software Foundation. |
3568 | + * |
3569 | + * This program is distributed in the hope that it will be useful, |
3570 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3571 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3572 | + * GNU Lesser General Public License for more details. |
3573 | + * |
3574 | + * You should have received a copy of the GNU Lesser General Public License |
3575 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3576 | + * |
3577 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
3578 | + */ |
3579 | + |
3580 | +#include "window_properties_mirserver_priv.h" |
3581 | + |
3582 | +#include <string> |
3583 | + |
3584 | +namespace uams = ubuntu::application::mir::server; |
3585 | +namespace msh = mir::shell; |
3586 | +namespace geom = mir::geometry; |
3587 | + |
3588 | +uams::WindowProperties::WindowProperties() |
3589 | + : parameters(msh::a_surface()), |
3590 | + cb(nullptr), |
3591 | + input_ctx(nullptr) |
3592 | +{ |
3593 | +} |
3594 | + |
3595 | +UAUiWindowProperties* uams::WindowProperties::as_u_window_properties() |
3596 | +{ |
3597 | + return static_cast<UAUiWindowProperties*>(this); |
3598 | +} |
3599 | + |
3600 | +uams::WindowProperties* uams::WindowProperties::from_u_window_properties(UAUiWindowProperties* u_properties) |
3601 | +{ |
3602 | + return static_cast<uams::WindowProperties*>(u_properties); |
3603 | +} |
3604 | + |
3605 | +void uams::WindowProperties::set_title(char const* title, size_t length) |
3606 | +{ |
3607 | + parameters = parameters.of_name(std::string(title, length)); |
3608 | +} |
3609 | + |
3610 | +void uams::WindowProperties::set_input_cb_and_ctx(UAUiWindowInputEventCb callback, void* ctx) |
3611 | +{ |
3612 | + cb = callback; |
3613 | + input_ctx = ctx; |
3614 | +} |
3615 | + |
3616 | +void uams::WindowProperties::set_pixel_format(geom::PixelFormat const& format) |
3617 | +{ |
3618 | + parameters = parameters.of_pixel_format(format); |
3619 | +} |
3620 | + |
3621 | +msh::SurfaceCreationParameters const& uams::WindowProperties::surface_parameters() const |
3622 | +{ |
3623 | + return parameters; |
3624 | +} |
3625 | + |
3626 | +UAUiWindowInputEventCb uams::WindowProperties::input_cb() const |
3627 | +{ |
3628 | + return cb; |
3629 | +} |
3630 | + |
3631 | +void* uams::WindowProperties::input_context() const |
3632 | +{ |
3633 | + return input_ctx; |
3634 | +} |
3635 | |
3636 | === added file 'src/mirserver/window_properties_mirserver_priv.h' |
3637 | --- src/mirserver/window_properties_mirserver_priv.h 1970-01-01 00:00:00 +0000 |
3638 | +++ src/mirserver/window_properties_mirserver_priv.h 2013-06-18 00:07:29 +0000 |
3639 | @@ -0,0 +1,69 @@ |
3640 | +/* |
3641 | + * Copyright (C) 2013 Canonical Ltd |
3642 | + * |
3643 | + * This program is free software: you can redistribute it and/or modify |
3644 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3645 | + * published by the Free Software Foundation. |
3646 | + * |
3647 | + * This program is distributed in the hope that it will be useful, |
3648 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3649 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3650 | + * GNU Lesser General Public License for more details. |
3651 | + * |
3652 | + * You should have received a copy of the GNU Lesser General Public License |
3653 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3654 | + * |
3655 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
3656 | + */ |
3657 | + |
3658 | +#ifndef UBUNTU_APPLICATION_UI_WINDOW_PROPERTIES_MIRSERVER_PRIV_H_ |
3659 | +#define UBUNTU_APPLICATION_UI_WINDOW_PROPERTIES_MIRSERVER_PRIV_H_ |
3660 | + |
3661 | +#include <ubuntu/application/ui/window.h> |
3662 | + |
3663 | +#include <mir/shell/surface_creation_parameters.h> |
3664 | +#include <mir/geometry/pixel_format.h> |
3665 | + |
3666 | +namespace ubuntu |
3667 | +{ |
3668 | +namespace application |
3669 | +{ |
3670 | +namespace mir |
3671 | +{ |
3672 | +namespace server |
3673 | +{ |
3674 | + |
3675 | +class WindowProperties |
3676 | +{ |
3677 | +public: |
3678 | + WindowProperties(); |
3679 | + ~WindowProperties() = default; |
3680 | + |
3681 | + UAUiWindowProperties* as_u_window_properties(); |
3682 | + static WindowProperties* from_u_window_properties(UAUiWindowProperties* u_properties); |
3683 | + |
3684 | + void set_title(char const* title, size_t length); |
3685 | + void set_input_cb_and_ctx(UAUiWindowInputEventCb cb, void* ctx); |
3686 | + void set_pixel_format( ::mir::geometry::PixelFormat const& format); |
3687 | + |
3688 | + ::mir::shell::SurfaceCreationParameters const& surface_parameters() const; |
3689 | + UAUiWindowInputEventCb input_cb() const; |
3690 | + void* input_context() const; |
3691 | + |
3692 | +protected: |
3693 | + WindowProperties(WindowProperties const&) = delete; |
3694 | + WindowProperties& operator=(WindowProperties const&) = delete; |
3695 | + |
3696 | +private: |
3697 | + ::mir::shell::SurfaceCreationParameters parameters; |
3698 | + |
3699 | + UAUiWindowInputEventCb cb; |
3700 | + void *input_ctx; |
3701 | +}; |
3702 | + |
3703 | +} |
3704 | +} |
3705 | +} |
3706 | +} |
3707 | + |
3708 | +#endif |
PASSED: Continuous integration, rev:128 jenkins. qa.ubuntu. com/job/ platform- api-ci/ 40/ jenkins. qa.ubuntu. com/job/ platform- api-saucy- amd64-ci/ 10 jenkins. qa.ubuntu. com/job/ platform- api-saucy- armhf-ci/ 10 jenkins. qa.ubuntu. com/job/ platform- api-saucy- armhf-ci/ 10/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ platform- api-saucy- i386-ci/ 10
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ platform- api-ci/ 40/rebuild
http://