Merge lp:~ricmm/platform-api/set-dimensions into lp:platform-api

Proposed by Ricardo Mendoza on 2013-12-11
Status: Merged
Approved by: Ricardo Mendoza on 2014-01-08
Approved revision: 186
Merged at revision: 180
Proposed branch: lp:~ricmm/platform-api/set-dimensions
Merge into: lp:platform-api
Diff against target: 256 lines (+111/-3)
11 files modified
android/default/default_ubuntu_application_ui.cpp (+11/-0)
debian/changelog (+6/-0)
include/ubuntu/application/ui/window_properties.h (+6/-0)
src/ubuntu/hybris/ubuntu_application_api_hybris.cpp (+1/-0)
src/ubuntu/mirclient/ubuntu_application_api_mirclient.cpp (+6/-0)
src/ubuntu/mirclient/window_properties_mirclient.cpp (+6/-0)
src/ubuntu/mirclient/window_properties_mirclient_priv.h (+1/-0)
src/ubuntu/mircommon/application_options_mir.cpp (+62/-3)
src/ubuntu/mirserver/ubuntu_application_api_mirserver.cpp (+6/-0)
src/ubuntu/mirserver/window_properties_mirserver.cpp (+5/-0)
src/ubuntu/mirserver/window_properties_mirserver_priv.h (+1/-0)
To merge this branch: bzr merge lp:~ricmm/platform-api/set-dimensions
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2014-01-07
Gerry Boland (community) 2013-12-11 Approve on 2014-01-07
Review via email: mp+198490@code.launchpad.net

Commit message

Add function to specify initial window geometry before creation.

To post a comment you must log in.
Gerry Boland (gerboland) wrote :

What is APP_DESKTOP_FILE_PATH? I can't find reference to it. It is supposed to be defined as $HOME/.local/share/applications ?

+ std::getline(infile, line);
+ while (std::getline(infile, line))
Why the first getline? Just to skip the [--] line?

Looks fine otherwise

Gerry Boland (gerboland) wrote :

LGTM

review: Approve
186. By Ricardo Mendoza on 2014-01-07

Fix conflicts

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'android/default/default_ubuntu_application_ui.cpp'
2--- android/default/default_ubuntu_application_ui.cpp 2013-06-18 00:05:11 +0000
3+++ android/default/default_ubuntu_application_ui.cpp 2014-01-07 20:37:41 +0000
4@@ -228,6 +228,17 @@
5 p->value->set_input_event_cb_and_ctx(cb, ctx);
6 }
7
8+void
9+ua_ui_window_properties_set_dimensions(
10+ UAUiWindowProperties *properties,
11+ uint32_t width,
12+ uint32_t height)
13+{
14+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
15+ (void) width;
16+ (void) height;
17+}
18+
19 /*
20 * Session
21 */
22
23=== modified file 'debian/changelog'
24--- debian/changelog 2013-11-28 10:51:15 +0000
25+++ debian/changelog 2014-01-07 20:37:41 +0000
26@@ -1,3 +1,9 @@
27+platform-api (0.20-0ubuntu1) trusty; urgency=low
28+
29+ * Added *_set_dimensions() function to the window properties.
30+
31+ -- Ricardo Mendoza <ricardo.mendoza@canonical.com> Tue, 10 Dec 2013 23:24:57 -0500
32+
33 platform-api (0.19+14.04.20131128.1-0ubuntu1) trusty; urgency=low
34
35 [ Kevin Gunn ]
36
37=== modified file 'include/ubuntu/application/ui/window_properties.h'
38--- include/ubuntu/application/ui/window_properties.h 2013-08-22 06:32:14 +0000
39+++ include/ubuntu/application/ui/window_properties.h 2014-01-07 20:37:41 +0000
40@@ -76,6 +76,12 @@
41 UAUiWindowProperties *properties,
42 UAUiWindowInputEventCb cb,
43 void *ctx);
44+
45+ UBUNTU_DLL_PUBLIC void
46+ ua_ui_window_properties_set_dimensions(
47+ UAUiWindowProperties *properties,
48+ uint32_t width,
49+ uint32_t height);
50
51 #ifdef __cplusplus
52 }
53
54=== modified file 'src/ubuntu/hybris/ubuntu_application_api_hybris.cpp'
55--- src/ubuntu/hybris/ubuntu_application_api_hybris.cpp 2013-06-20 12:37:44 +0000
56+++ src/ubuntu/hybris/ubuntu_application_api_hybris.cpp 2014-01-07 20:37:41 +0000
57@@ -92,6 +92,7 @@
58 IMPLEMENT_FUNCTION1(const char*, ua_ui_window_properties_get_title, UAUiWindowProperties*);
59 IMPLEMENT_VOID_FUNCTION2(ua_ui_window_properties_set_role, UAUiWindowProperties*, UAUiWindowRole);
60 IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_input_cb_and_ctx, UAUiWindowProperties*, UAUiWindowInputEventCb, void*);
61+IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_dimensions, UAUiWindowProperties*, uint32_t, uint32_t);
62
63 // UAUiWindow
64 IMPLEMENT_FUNCTION2(UAUiWindow*, ua_ui_window_new_for_application_with_properties, UApplicationInstance*, UAUiWindowProperties*);
65
66=== modified file 'src/ubuntu/mirclient/ubuntu_application_api_mirclient.cpp'
67--- src/ubuntu/mirclient/ubuntu_application_api_mirclient.cpp 2013-10-14 09:47:52 +0000
68+++ src/ubuntu/mirclient/ubuntu_application_api_mirclient.cpp 2014-01-07 20:37:41 +0000
69@@ -232,6 +232,12 @@
70 properties->set_input_cb_and_ctx(cb, ctx);
71 }
72
73+void ua_ui_window_properties_set_dimensions(UAUiWindowProperties *u_properties, uint32_t width, uint32_t height)
74+{
75+ auto properties = uamc::WindowProperties::from_u_window_properties(u_properties);
76+ properties->set_dimensions(width, height);
77+}
78+
79 UAUiWindow* ua_ui_window_new_for_application_with_properties(UApplicationInstance* u_instance, UAUiWindowProperties* u_properties)
80 {
81 auto instance = uamc::Instance::from_u_application_instance(u_instance);
82
83=== modified file 'src/ubuntu/mirclient/window_properties_mirclient.cpp'
84--- src/ubuntu/mirclient/window_properties_mirclient.cpp 2013-11-20 09:39:29 +0000
85+++ src/ubuntu/mirclient/window_properties_mirclient.cpp 2014-01-07 20:37:41 +0000
86@@ -54,6 +54,12 @@
87 input_ctx = ctx;
88 }
89
90+void uamc::WindowProperties::set_dimensions(uint32_t width, uint32_t height)
91+{
92+ parameters.width = width;
93+ parameters.height = height;
94+}
95+
96 void uamc::WindowProperties::set_role(UAUiWindowRole role)
97 {
98 if (role == U_ON_SCREEN_KEYBOARD_ROLE) {
99
100=== modified file 'src/ubuntu/mirclient/window_properties_mirclient_priv.h'
101--- src/ubuntu/mirclient/window_properties_mirclient_priv.h 2013-08-19 21:02:27 +0000
102+++ src/ubuntu/mirclient/window_properties_mirclient_priv.h 2014-01-07 20:37:41 +0000
103@@ -47,6 +47,7 @@
104
105 void set_title(char const* title, size_t length);
106 void set_input_cb_and_ctx(UAUiWindowInputEventCb cb, void* ctx);
107+ void set_dimensions(uint32_t width, uint32_t height);
108 void set_role(UAUiWindowRole role);
109
110 MirSurfaceParameters const& surface_parameters() const;
111
112=== modified file 'src/ubuntu/mircommon/application_options_mir.cpp'
113--- src/ubuntu/mircommon/application_options_mir.cpp 2013-06-06 23:35:14 +0000
114+++ src/ubuntu/mircommon/application_options_mir.cpp 2014-01-07 20:37:41 +0000
115@@ -24,8 +24,12 @@
116 #include <getopt.h>
117
118 #include <tuple>
119+#include <iostream>
120+#include <fstream>
121 #include <string>
122
123+#include <unistd.h>
124+
125 namespace uam = ubuntu::application::mir;
126
127 UApplicationOptions* uam::Options::as_u_application_options()
128@@ -43,11 +47,11 @@
129 UAUiStage
130 string_to_stage(std::string const& s)
131 {
132- if (s == "main_stage")
133+ if (s == "main_stage" || s == "MainStage")
134 return U_MAIN_STAGE;
135- else if (s == "side_stage")
136+ else if (s == "side_stage" || s == "SideStage")
137 return U_SIDE_STAGE;
138- else if (s == "share_stage")
139+ else if (s == "share_stage" || s == "ShareStage")
140 return U_SHARE_STAGE;
141 }
142
143@@ -95,6 +99,60 @@
144
145 auto app_options = new uam::Options;
146
147+ // Construct legacy desktop file path
148+ std::string desktop_file_name;
149+ if (getenv("APP_ID"))
150+ {
151+ desktop_file_name = getenv("APP_ID");
152+ desktop_file_name.append(".desktop");
153+ }
154+
155+ // Click desktop path
156+ std::string local_path;
157+ if (getenv("APP_DESKTOP_FILE_PATH"))
158+ local_path = getenv("APP_DESKTOP_FILE_PATH");;
159+
160+ // Check StageHint
161+ std::string line, stage_hint;
162+ std::string stage_key("X-Ubuntu-StageHint");
163+
164+ std::ifstream infile;
165+ std::string search_paths[2] = {"/usr/share/applications/", local_path};
166+ search_paths[0].append(desktop_file_name);
167+ for (std::string path : search_paths)
168+ {
169+ if (path.empty())
170+ continue;
171+
172+ infile.open(path);
173+ if (!infile)
174+ continue;
175+
176+ std::getline(infile, line);
177+ while (std::getline(infile, line))
178+ {
179+ if (infile.eof())
180+ break;
181+
182+ // Check for non key-value line
183+ if (line.find("=") == std::string::npos)
184+ continue;
185+
186+ std::string lhs = line.substr(0,line.find("="));
187+ std::string rhs = line.substr(line.find("="));
188+
189+ // Fetch Stage
190+ if (lhs.compare(stage_key) == 0)
191+ {
192+ stage_hint = rhs.substr(1);
193+ break;
194+ }
195+ }
196+ }
197+
198+ if (!stage_hint.empty())
199+ app_options->stage = string_to_stage(stage_hint);
200+
201 while(true)
202 {
203 int option_index = 0;
204@@ -124,6 +182,7 @@
205 app_options->form_factor = string_to_form_factor(std::string(optarg));
206 break;
207 case stage_hint_index:
208+ // Override if set
209 app_options->stage = string_to_stage(std::string(optarg));
210 break;
211 case desktop_file_hint_index:
212
213=== modified file 'src/ubuntu/mirserver/ubuntu_application_api_mirserver.cpp'
214--- src/ubuntu/mirserver/ubuntu_application_api_mirserver.cpp 2014-01-07 11:00:33 +0000
215+++ src/ubuntu/mirserver/ubuntu_application_api_mirserver.cpp 2014-01-07 20:37:41 +0000
216@@ -259,6 +259,12 @@
217 properties->set_input_cb_and_ctx(cb, ctx);
218 }
219
220+void ua_ui_window_properties_set_dimensions(UAUiWindowProperties *u_properties, uint32_t width, uint32_t height)
221+{
222+ auto properties = uams::WindowProperties::from_u_window_properties(u_properties);
223+ properties->set_dimensions(width, height);
224+}
225+
226 UAUiWindow* ua_ui_window_new_for_application_with_properties(UApplicationInstance* u_instance, UAUiWindowProperties* u_properties)
227 {
228 auto input_platform = global_mirserver_context()->input_platform;
229
230=== modified file 'src/ubuntu/mirserver/window_properties_mirserver.cpp'
231--- src/ubuntu/mirserver/window_properties_mirserver.cpp 2014-01-07 11:00:33 +0000
232+++ src/ubuntu/mirserver/window_properties_mirserver.cpp 2014-01-07 20:37:41 +0000
233@@ -51,6 +51,11 @@
234 input_ctx = ctx;
235 }
236
237+void uams::WindowProperties::set_dimensions(uint32_t width, uint32_t height)
238+{
239+ parameters = parameters.of_size(width, height);
240+}
241+
242 void uams::WindowProperties::set_pixel_format(MirPixelFormat const& format)
243 {
244 parameters = parameters.of_pixel_format(format);
245
246=== modified file 'src/ubuntu/mirserver/window_properties_mirserver_priv.h'
247--- src/ubuntu/mirserver/window_properties_mirserver_priv.h 2014-01-07 11:00:33 +0000
248+++ src/ubuntu/mirserver/window_properties_mirserver_priv.h 2014-01-07 20:37:41 +0000
249@@ -44,6 +44,7 @@
250
251 void set_title(char const* title, size_t length);
252 void set_input_cb_and_ctx(UAUiWindowInputEventCb cb, void* ctx);
253+ void set_dimensions(uint32_t width, uint32_t height);
254 void set_pixel_format( MirPixelFormat const& format);
255
256 ::mir::shell::SurfaceCreationParameters const& surface_parameters() const;

Subscribers

People subscribed via source and target branches