Merge lp:~robertcarr/platform-api/mir-client-and-server into lp:platform-api

Proposed by Robert Carr
Status: Rejected
Rejected by: Gerry Boland
Proposed branch: lp:~robertcarr/platform-api/mir-client-and-server
Merge into: lp:platform-api
Diff against target: 448 lines (+405/-1)
7 files modified
CMakeLists.txt (+20/-0)
src/CMakeLists.txt (+11/-1)
src/mirclient/CMakeLists.txt (+28/-0)
src/mirclient/ubuntu_application_api_mirclient.cpp (+219/-0)
src/mircommon/CMakeLists.txt (+19/-0)
src/mircommon/ubuntu_application_api_mircommon.cpp (+73/-0)
src/mircommon/ubuntu_application_api_mircommon.h (+35/-0)
To merge this branch: bzr merge lp:~robertcarr/platform-api/mir-client-and-server
Reviewer Review Type Date Requested Status
Gerry Boland (community) Needs Resubmitting
PS Jenkins bot continuous-integration Approve
Review via email: mp+163616@code.launchpad.net

Commit message

Provide mirclient and mirserver based implementations of ubuntu_application_ui_* to form mir support in qtubuntu.

Description of the change

Provide mirclient and mirserver based implementations of ubuntu_application_ui_* to form mir support in qtubuntu.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Old, please update and resubmit if you want it

review: Needs Resubmitting

Unmerged revisions

57. By Robert Carr

Initial mirserver draft

56. By Robert Carr

Move some code to mircommon

55. By Robert Carr

Import mirclient impl

54. By Robert Carr

Check for mirclient in pkgconfig

53. By Robert Carr

Only build android with hybris implementation

52. By Robert Carr

Define APPLICATION_UI_IMPLEMENTATION

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-02-06 00:32:45 +0000
3+++ CMakeLists.txt 2013-05-13 21:03:28 +0000
4@@ -9,6 +9,26 @@
5 LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
6 ARCHIVE DESTINATION "${LIB_INSTALL_DIR}")
7
8+set(
9+ APPLICATION_UI_IMPLEMENTATION
10+ hybris
11+ CACHE
12+ STRING
13+ "Application ui implementation to build (options are 'hybris', 'mirclient', or 'mirserver')" # TODO: Update with mir options ~racarr
14+)
15+
16+if (APPLICATION_UI_IMPLEMENTATION STREQUAL "mirclient")
17+ find_package(PkgConfig)
18+ pkg_check_modules(MIR_CLIENT mirclient)
19+ pkg_check_modules(MIR_COMMON mircommon)
20+endif()
21+
22+if (APPLICATION_UI_IMPLEMENTATION STREQUAL "mirserver")
23+ find_package(PkgConfig)
24+ pkg_check_modules(MIR_SERVER mirserver)
25+ pkg_check_modules(MIR_COMMON mircommon)
26+endif()
27+
28 include_directories(include/)
29
30 add_subdirectory(src/)
31
32=== modified file 'src/CMakeLists.txt'
33--- src/CMakeLists.txt 2013-02-05 06:58:40 +0000
34+++ src/CMakeLists.txt 2013-05-13 21:03:28 +0000
35@@ -1,1 +1,11 @@
36-add_subdirectory(android/)
37+include_directories(.)
38+
39+if (APPLICATION_UI_IMPLEMENTATION STREQUAL "hybris")
40+ add_subdirectory(android/)
41+elseif(APPLICATION_UI_IMPLEMENTATION STREQUAL "mirclient")
42+ add_subdirectory(mirclient/)
43+ add_subdirectory(mircommon/)
44+elseif(APPLICATION_UI_IMPLEMENTATION STREQUAL "mirserver")
45+ add_subdirectory(mirserver/)
46+ add_subdirectory(mircommon/)
47+endif()
48
49=== added directory 'src/mirclient'
50=== added file 'src/mirclient/CMakeLists.txt'
51--- src/mirclient/CMakeLists.txt 1970-01-01 00:00:00 +0000
52+++ src/mirclient/CMakeLists.txt 2013-05-13 21:03:28 +0000
53@@ -0,0 +1,28 @@
54+set(SOURCES ubuntu_application_api_mirclient.cpp)
55+
56+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++0x")
57+
58+include_directories(
59+ ${MIR_CLIENT_INCLUDE_DIRS}
60+)
61+
62+add_library(
63+ ubuntu_application_api_mirclient SHARED
64+ ${SOURCES}
65+)
66+
67+target_link_libraries(
68+ ubuntu_application_api_mirclient
69+ ${MIR_CLIENT_LDFLAGS} ${MIR_CLIENT_LIBRARIES}
70+ ubuntu_application_api_mircommon
71+)
72+
73+set_target_properties(
74+ ubuntu_application_api_mirclient
75+ PROPERTIES
76+ VERSION 1.0
77+ SOVERSION 1
78+)
79+
80+install(TARGETS ubuntu_application_api_mirclient ${INSTALL_TARGETS_DEFAULT_ARGS})
81+
82
83=== added file 'src/mirclient/ubuntu_application_api_mirclient.cpp'
84--- src/mirclient/ubuntu_application_api_mirclient.cpp 1970-01-01 00:00:00 +0000
85+++ src/mirclient/ubuntu_application_api_mirclient.cpp 2013-05-13 21:03:28 +0000
86@@ -0,0 +1,219 @@
87+/*
88+ * Copyright (C) 2013 Canonical Ltd
89+ *
90+ * This program is free software: you can redistribute it and/or modify
91+ * it under the terms of the GNU Lesser General Public License version 3 as
92+ * published by the Free Software Foundation.
93+ *
94+ * This program is distributed in the hope that it will be useful,
95+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
96+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
97+ * GNU Lesser General Public License for more details.
98+ *
99+ * You should have received a copy of the GNU Lesser General Public License
100+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
101+ *
102+ * Authored by: Robert Carr <robert.carr@canonical.com>
103+ */
104+
105+#include <ubuntu/application/ui/ubuntu_application_ui.h>
106+#include <mir_toolkit/mir_client_library.h>
107+
108+#include "mircommon/ubuntu_application_api_mircommon.h"
109+
110+#include <assert.h>
111+
112+namespace
113+{
114+ char const* const socket_file = "/tmp/mir_socket";
115+ MirConnection *global_connection = NULL;
116+}
117+
118+typedef struct {
119+ MirSurface *mir_surface;
120+ input_event_cb ubuntu_input_cb;
121+ void *input_ctx;
122+} ubuntu_application_ui_mir_surface;
123+
124+
125+void
126+ubuntu_application_ui_init(int argc, char**argv)
127+{
128+ if (global_connection)
129+ return;
130+ global_connection = mir_connect_sync(socket_file, argc ? argv[0] : "");
131+ assert(global_connection);
132+}
133+
134+StageHint
135+ubuntu_application_ui_setup_get_stage_hint()
136+{
137+ // TODO: Implement ~racarr
138+ return MAIN_STAGE_HINT;
139+}
140+
141+FormFactorHint
142+ubuntu_application_ui_setup_get_form_factor_hint()
143+{
144+ // TODO: Implement ~racarr
145+ return DESKTOP_FORM_FACTOR_HINT;
146+}
147+
148+void
149+ubuntu_application_ui_start_a_new_session(SessionCredentials* creds)
150+{
151+ // TODO: Is this the correct place to call mir_connect_sync?
152+ // It seems this is never called by QtUbuntu ~racarr
153+}
154+
155+EGLNativeDisplayType
156+ubuntu_application_ui_get_native_display()
157+{
158+ return static_cast<EGLNativeDisplayType>(mir_connection_get_egl_native_display(global_connection));
159+}
160+
161+void
162+ubuntu_application_ui_set_clipboard_content(void* data, size_t size)
163+{
164+ // TODO: Implement ~racarr
165+}
166+
167+void
168+ubuntu_application_ui_get_clipboard_content(void** data, size_t* size)
169+{
170+ *size = 0;
171+ *data = NULL;
172+ // TODO: Implement ~racarr
173+}
174+
175+void
176+ubuntu_application_ui_create_display_info(ubuntu_application_ui_physical_display_info* info, size_t index)
177+{
178+ // TODO: Implement ~racarr
179+ // Noop for mirclient?
180+}
181+
182+void
183+ubuntu_application_ui_destroy_display_info(ubuntu_application_ui_physical_display_info info)
184+{
185+ // TODO: Implement ~racarr
186+ // Noop for mirclient?
187+}
188+
189+int32_t
190+ubuntu_application_ui_query_horizontal_resolution(ubuntu_application_ui_physical_display_info info)
191+{
192+ MirDisplayInfo display_info;
193+
194+ assert(global_connection);
195+
196+ mir_connection_get_display_info(global_connection, &display_info);
197+ return static_cast<int32_t>(display_info.width);
198+}
199+
200+int32_t
201+ubuntu_application_ui_query_vertical_resolution(ubuntu_application_ui_physical_display_info info)
202+{
203+ MirDisplayInfo display_info;
204+
205+ assert(global_connection);
206+
207+ mir_connection_get_display_info(global_connection, &display_info);
208+ return static_cast<int32_t>(display_info.height);
209+}
210+
211+float
212+ubuntu_application_ui_query_horizontal_dpi(ubuntu_application_ui_physical_display_info info)
213+{
214+ // TODO: Implement ~racarr
215+ return (float)0.0;
216+}
217+
218+float
219+ubuntu_application_ui_query_vertical_dpi(ubuntu_application_ui_physical_display_info info)
220+{
221+ // TODO: Implement ~racarr
222+ return (float)0.0;
223+}
224+
225+namespace
226+{
227+static void ubuntu_application_ui_mir_handle_event(MirSurface* mir_surface, MirEvent const* mir_ev, void* context)
228+{
229+ ubuntu_application_ui_mir_surface *surface = static_cast<ubuntu_application_ui_mir_surface*>(context);
230+ Event ubuntu_ev;
231+ mir_event_to_ubuntu_event(mir_ev, ubuntu_ev);
232+ surface->ubuntu_input_cb(surface->input_ctx, &ubuntu_ev);
233+}
234+}
235+
236+void
237+ubuntu_application_ui_create_surface(ubuntu_application_ui_surface* out_surface,
238+ const char* title,
239+ int width,
240+ int height,
241+ SurfaceRole role,
242+ uint32_t flags,
243+ input_event_cb cb,
244+ void* ctx)
245+{
246+ assert(global_connection);
247+ MirDisplayInfo display_info;
248+ mir_connection_get_display_info(global_connection, &display_info);
249+ MirSurfaceParameters params = { title, width, height, display_info.supported_pixel_format[0], mir_buffer_usage_hardware};
250+ ubuntu_application_ui_mir_surface *surface = new ubuntu_application_ui_mir_surface;
251+ surface->ubuntu_input_cb = cb;
252+ surface->input_ctx = ctx;
253+ MirEventDelegate event_delegate = { ubuntu_application_ui_mir_handle_event, surface };
254+ surface->mir_surface = mir_connection_create_surface_sync(global_connection, &params);
255+ mir_surface_set_event_handler(surface->mir_surface, &event_delegate);
256+ assert(surface);
257+ *out_surface = static_cast<ubuntu_application_ui_surface>(surface);
258+}
259+
260+void
261+ubuntu_application_ui_request_fullscreen_for_surface(ubuntu_application_ui_surface surface)
262+{
263+ // TODO: Implement ~racarr
264+}
265+
266+void
267+ubuntu_application_ui_destroy_surface(ubuntu_application_ui_surface s)
268+{
269+ ubuntu_application_ui_mir_surface *surface = static_cast<ubuntu_application_ui_mir_surface*>(s);
270+ mir_surface_release_sync(surface->mir_surface);
271+ delete surface;
272+}
273+
274+EGLNativeWindowType
275+ubuntu_application_ui_surface_to_native_window_type(ubuntu_application_ui_surface s)
276+{
277+ ubuntu_application_ui_mir_surface *surface = static_cast<ubuntu_application_ui_mir_surface*>(s);
278+ return reinterpret_cast<EGLNativeWindowType>(mir_surface_get_egl_native_window(surface->mir_surface));
279+}
280+
281+void
282+ubuntu_application_ui_show_surface(ubuntu_application_ui_surface surface)
283+{
284+ // TODO: Implement ~racarr
285+}
286+
287+void
288+ubuntu_application_ui_hide_surface(ubuntu_application_ui_surface surface)
289+{
290+ // TODO: Implement ~racarr
291+}
292+
293+void
294+ubuntu_application_ui_move_surface_to(ubuntu_application_ui_surface surface,
295+ int x, int y)
296+{
297+ // TODO: Implement ~racarr
298+}
299+
300+void
301+ubuntu_application_ui_resize_surface_to(ubuntu_application_ui_surface surface,
302+ int w, int h)
303+{
304+ // TODO: Implement ~racarr
305+}
306
307=== added directory 'src/mircommon'
308=== added file 'src/mircommon/CMakeLists.txt'
309--- src/mircommon/CMakeLists.txt 1970-01-01 00:00:00 +0000
310+++ src/mircommon/CMakeLists.txt 2013-05-13 21:03:28 +0000
311@@ -0,0 +1,19 @@
312+set(SOURCES ubuntu_application_api_mircommon.cpp)
313+
314+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++0x")
315+
316+include_directories(
317+ ${MIR_COMMON_INCLUDE_DIRS}
318+)
319+
320+add_library(
321+ ubuntu_application_api_mircommon STATIC
322+ ${SOURCES}
323+)
324+
325+target_link_libraries(
326+ ubuntu_application_api_mircommon
327+ ${MIR_COMMON_LDFLAGS} ${MIR_COMMON_LIBRARIES}
328+)
329+
330+
331
332=== added file 'src/mircommon/ubuntu_application_api_mircommon.cpp'
333--- src/mircommon/ubuntu_application_api_mircommon.cpp 1970-01-01 00:00:00 +0000
334+++ src/mircommon/ubuntu_application_api_mircommon.cpp 2013-05-13 21:03:28 +0000
335@@ -0,0 +1,73 @@
336+/*
337+ * Copyright (C) 2013 Canonical Ltd
338+ *
339+ * This program is free software: you can redistribute it and/or modify
340+ * it under the terms of the GNU Lesser General Public License version 3 as
341+ * published by the Free Software Foundation.
342+ *
343+ * This program is distributed in the hope that it will be useful,
344+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
345+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
346+ * GNU Lesser General Public License for more details.
347+ *
348+ * You should have received a copy of the GNU Lesser General Public License
349+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
350+ *
351+ * Authored by: Robert Carr <robert.carr@canonical.com>
352+ */
353+
354+#include "ubuntu_application_api_mircommon.h"
355+
356+void
357+mir_event_to_ubuntu_event(MirEvent const* mir_event, Event& ubuntu_ev)
358+{
359+ switch (mir_event->type)
360+ {
361+ case mir_event_type_key:
362+ ubuntu_ev.type = KEY_EVENT_TYPE;
363+ ubuntu_ev.device_id = mir_event->key.device_id;
364+ ubuntu_ev.source_id = mir_event->key.source_id;
365+ ubuntu_ev.action = mir_event->key.action;
366+ ubuntu_ev.flags = mir_event->key.flags;
367+ ubuntu_ev.meta_state = mir_event->key.modifiers;
368+ ubuntu_ev.details.key.key_code = mir_event->key.key_code;
369+ ubuntu_ev.details.key.scan_code = mir_event->key.scan_code;
370+ ubuntu_ev.details.key.repeat_count = mir_event->key.repeat_count;
371+ ubuntu_ev.details.key.down_time = mir_event->key.down_time;
372+ ubuntu_ev.details.key.event_time = mir_event->key.event_time;
373+ ubuntu_ev.details.key.is_system_key = mir_event->key.is_system_key;
374+ break;
375+ case mir_event_type_motion:
376+ ubuntu_ev.type = MOTION_EVENT_TYPE;
377+ ubuntu_ev.device_id = mir_event->motion.device_id;
378+ ubuntu_ev.source_id = mir_event->motion.source_id;
379+ ubuntu_ev.action = mir_event->motion.action;
380+ ubuntu_ev.flags = mir_event->motion.flags;
381+ ubuntu_ev.meta_state = mir_event->motion.modifiers;
382+ ubuntu_ev.details.motion.edge_flags = mir_event->motion.edge_flags;
383+ ubuntu_ev.details.motion.button_state = mir_event->motion.button_state;
384+ ubuntu_ev.details.motion.x_offset = mir_event->motion.x_offset;
385+ ubuntu_ev.details.motion.y_offset = mir_event->motion.y_offset;
386+ ubuntu_ev.details.motion.x_precision = mir_event->motion.x_precision;
387+ ubuntu_ev.details.motion.y_precision = mir_event->motion.y_precision;
388+ ubuntu_ev.details.motion.down_time = mir_event->motion.down_time;
389+ ubuntu_ev.details.motion.event_time = mir_event->motion.event_time;
390+ ubuntu_ev.details.motion.pointer_count = mir_event->motion.pointer_count;
391+ for (int i = 0; i < mir_event->motion.pointer_count; i++)
392+ {
393+ ubuntu_ev.details.motion.pointer_coordinates[i].id = mir_event->motion.pointer_coordinates[i].id;
394+ ubuntu_ev.details.motion.pointer_coordinates[i].x = mir_event->motion.pointer_coordinates[i].x;
395+ ubuntu_ev.details.motion.pointer_coordinates[i].raw_x = mir_event->motion.pointer_coordinates[i].raw_x;
396+ ubuntu_ev.details.motion.pointer_coordinates[i].y = mir_event->motion.pointer_coordinates[i].y;
397+ ubuntu_ev.details.motion.pointer_coordinates[i].raw_y = mir_event->motion.pointer_coordinates[i].raw_y;
398+ ubuntu_ev.details.motion.pointer_coordinates[i].touch_major = mir_event->motion.pointer_coordinates[i].touch_major;
399+ ubuntu_ev.details.motion.pointer_coordinates[i].touch_minor = mir_event->motion.pointer_coordinates[i].touch_minor;
400+ ubuntu_ev.details.motion.pointer_coordinates[i].size = mir_event->motion.pointer_coordinates[i].size;
401+ ubuntu_ev.details.motion.pointer_coordinates[i].pressure = mir_event->motion.pointer_coordinates[i].pressure;
402+ ubuntu_ev.details.motion.pointer_coordinates[i].orientation = mir_event->motion.pointer_coordinates[i].orientation;
403+ }
404+ break;
405+ default:
406+ break;
407+ }
408+}
409
410=== added file 'src/mircommon/ubuntu_application_api_mircommon.h'
411--- src/mircommon/ubuntu_application_api_mircommon.h 1970-01-01 00:00:00 +0000
412+++ src/mircommon/ubuntu_application_api_mircommon.h 2013-05-13 21:03:28 +0000
413@@ -0,0 +1,35 @@
414+/*
415+ * Copyright (C) 2013 Canonical Ltd
416+ *
417+ * This program is free software: you can redistribute it and/or modify
418+ * it under the terms of the GNU Lesser General Public License version 3 as
419+ * published by the Free Software Foundation.
420+ *
421+ * This program is distributed in the hope that it will be useful,
422+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
423+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
424+ * GNU Lesser General Public License for more details.
425+ *
426+ * You should have received a copy of the GNU Lesser General Public License
427+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
428+ *
429+ * Authored by: Robert Carr <robert.carr@canonical.com>
430+ */
431+
432+#ifndef UBUNTU_APPLICATION_API_MIR_COMMON_H_
433+#define UBUNTU_APPLICATION_API_MIR_COMMON_H_
434+
435+#include <ubuntu/application/ui/input/event.h>
436+#include <mir_toolkit/event.h>
437+
438+#ifndef __cplusplus
439+extern "C" {
440+#endif
441+
442+void mir_event_to_ubuntu_event(MirEvent const* mir_event, Event& ubuntu_ev);
443+
444+#ifndef __cplusplus
445+}
446+#endif
447+
448+#endif // UBUNTU_APPLICATION_API_MIR_COMMON_H_

Subscribers

People subscribed via source and target branches