Merge lp:~hikiko/unity/unity.ui-scale-factor into lp:unity
- unity.ui-scale-factor
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Marco Trevisan (Treviño) | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 3681 | ||||
Proposed branch: | lp:~hikiko/unity/unity.ui-scale-factor | ||||
Merge into: | lp:unity | ||||
Diff against target: |
524 lines (+61/-348) 7 files modified
debian/control (+1/-0) unity-shared/CMakeLists.txt (+0/-1) unity-shared/ConfigParser.cpp (+0/-287) unity-shared/ConfigParser.h (+0/-37) unity-shared/UScreen.cpp (+21/-9) unity-shared/UScreen.h (+1/-0) unity-shared/UnitySettings.cpp (+38/-14) |
||||
To merge this branch: | bzr merge lp:~hikiko/unity/unity.ui-scale-factor | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Stephen M. Webb (community) | Approve | ||
Brandon Schaefer | Pending | ||
Review via email: mp+207610@code.launchpad.net |
Commit message
scaling desktop according to a scale factor
Description of the change
scaling desktop according to a scale factor
PS Jenkins bot (ps-jenkins) wrote : | # |
Andrea Azzarone (azzar1) wrote : | # |
Can you revert that changes in po/*?
Stephen M. Webb (bregma) wrote : | # |
Needs .po file changes reverted and merge with trunk.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3681
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Stephen M. Webb (bregma) wrote : | # |
OK, works getting the gsetting to affect Unity, LGTM and build on it.
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
474 + g_object_
475 + g_object_
476 + g_object_
477 + g_object_
Please get rid of them, we're already doing it as they're glib::Object
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3682
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'debian/control' | |||
2 | --- debian/control 2014-02-20 07:08:01 +0000 | |||
3 | +++ debian/control 2014-02-21 17:06:30 +0000 | |||
4 | @@ -11,6 +11,7 @@ | |||
5 | 11 | google-mock (>= 1.6.0+svn437), | 11 | google-mock (>= 1.6.0+svn437), |
6 | 12 | google-mock, | 12 | google-mock, |
7 | 13 | gsettings-desktop-schemas-dev, | 13 | gsettings-desktop-schemas-dev, |
8 | 14 | gsettings-ubuntu-schemas (>= 0.0.1+14.04.20140219), | ||
9 | 14 | intltool (>= 0.35.0), | 15 | intltool (>= 0.35.0), |
10 | 15 | libatk1.0-dev, | 16 | libatk1.0-dev, |
11 | 16 | libbamf3-dev (>= 0.5.0+13.10.20130731), | 17 | libbamf3-dev (>= 0.5.0+13.10.20130731), |
12 | 17 | 18 | ||
13 | === modified file 'unity-shared/CMakeLists.txt' | |||
14 | --- unity-shared/CMakeLists.txt 2014-02-17 04:01:26 +0000 | |||
15 | +++ unity-shared/CMakeLists.txt 2014-02-21 17:06:30 +0000 | |||
16 | @@ -19,7 +19,6 @@ | |||
17 | 19 | set (UNITY_SHARED_SOURCES | 19 | set (UNITY_SHARED_SOURCES |
18 | 20 | ApplicationManager.cpp | 20 | ApplicationManager.cpp |
19 | 21 | BGHash.cpp | 21 | BGHash.cpp |
20 | 22 | ConfigParser.cpp | ||
21 | 23 | CoverArt.cpp | 22 | CoverArt.cpp |
22 | 24 | BackgroundEffectHelper.cpp | 23 | BackgroundEffectHelper.cpp |
23 | 25 | DashStyle.cpp | 24 | DashStyle.cpp |
24 | 26 | 25 | ||
25 | === removed file 'unity-shared/ConfigParser.cpp' | |||
26 | --- unity-shared/ConfigParser.cpp 2014-02-03 18:46:31 +0000 | |||
27 | +++ unity-shared/ConfigParser.cpp 1970-01-01 00:00:00 +0000 | |||
28 | @@ -1,287 +0,0 @@ | |||
29 | 1 | /* | ||
30 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
31 | 3 | * | ||
32 | 4 | * This program is free software: you can redistribute it and/or modify | ||
33 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
34 | 6 | * published by the Free Software Foundation. | ||
35 | 7 | * | ||
36 | 8 | * This program is distributed in the hope that it will be useful, | ||
37 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
38 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
39 | 11 | * GNU General Public License for more details. | ||
40 | 12 | * | ||
41 | 13 | * You should have received a copy of the GNU General Public License | ||
42 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
43 | 15 | * | ||
44 | 16 | * Authored by: Eleni Maria Stea <elenimaria.stea@canonical.com> | ||
45 | 17 | */ | ||
46 | 18 | |||
47 | 19 | #include <ctype.h> | ||
48 | 20 | #include <stdio.h> | ||
49 | 21 | #include <stdlib.h> | ||
50 | 22 | #include <string.h> | ||
51 | 23 | |||
52 | 24 | #include "ConfigParser.h" | ||
53 | 25 | |||
54 | 26 | static char *strip_whitespace (char *buf); | ||
55 | 27 | |||
56 | 28 | /* Linked List */ | ||
57 | 29 | |||
58 | 30 | struct Node { | ||
59 | 31 | char *key; | ||
60 | 32 | char *value; | ||
61 | 33 | |||
62 | 34 | struct Node *next; | ||
63 | 35 | }; | ||
64 | 36 | |||
65 | 37 | /* ConfigString */ | ||
66 | 38 | |||
67 | 39 | struct ConfigString { | ||
68 | 40 | struct Node *list; | ||
69 | 41 | char *string; | ||
70 | 42 | }; | ||
71 | 43 | |||
72 | 44 | ConfigString *cfgstr_create (const char *orig_str) | ||
73 | 45 | { | ||
74 | 46 | char *sptr, *str; | ||
75 | 47 | |||
76 | 48 | str = (char*)alloca(strlen(orig_str) + 1); | ||
77 | 49 | strcpy(str, orig_str); | ||
78 | 50 | |||
79 | 51 | ConfigString *cfgstr; | ||
80 | 52 | if (!(cfgstr = (ConfigString*)malloc(sizeof *cfgstr))) | ||
81 | 53 | return 0; | ||
82 | 54 | |||
83 | 55 | cfgstr->list = NULL; | ||
84 | 56 | cfgstr->string = NULL; | ||
85 | 57 | |||
86 | 58 | sptr = str; | ||
87 | 59 | while (sptr && *sptr != 0) | ||
88 | 60 | { | ||
89 | 61 | char *key, *value, *end, *start, *vstart; | ||
90 | 62 | struct Node *node; | ||
91 | 63 | |||
92 | 64 | if (*sptr == ';') | ||
93 | 65 | { | ||
94 | 66 | sptr++; | ||
95 | 67 | continue; | ||
96 | 68 | } | ||
97 | 69 | |||
98 | 70 | start = sptr; | ||
99 | 71 | if ((end = strchr(start, ';'))) | ||
100 | 72 | { | ||
101 | 73 | *end = 0; | ||
102 | 74 | sptr = end + 1; | ||
103 | 75 | } | ||
104 | 76 | else | ||
105 | 77 | { | ||
106 | 78 | sptr = NULL; | ||
107 | 79 | } | ||
108 | 80 | |||
109 | 81 | /* parse key/value from the string */ | ||
110 | 82 | if (!(vstart = strchr(start, '='))) | ||
111 | 83 | { | ||
112 | 84 | fprintf(stderr, "%s: invalid key-value pair: %s\n", __func__, start); | ||
113 | 85 | cfgstr_destroy(cfgstr); | ||
114 | 86 | return 0; | ||
115 | 87 | } | ||
116 | 88 | *vstart++ = 0; /* terminate the key part and move the pointer to the start of the value */ | ||
117 | 89 | |||
118 | 90 | start = strip_whitespace(start); | ||
119 | 91 | vstart = strip_whitespace(vstart); | ||
120 | 92 | |||
121 | 93 | if (!(key = (char*)malloc(strlen(start) + 1))) | ||
122 | 94 | { | ||
123 | 95 | cfgstr_destroy(cfgstr); | ||
124 | 96 | return 0; | ||
125 | 97 | } | ||
126 | 98 | |||
127 | 99 | if (!(value = (char*)malloc(strlen(vstart) + 1))) | ||
128 | 100 | { | ||
129 | 101 | free(key); | ||
130 | 102 | cfgstr_destroy(cfgstr); | ||
131 | 103 | return 0; | ||
132 | 104 | } | ||
133 | 105 | |||
134 | 106 | strcpy(key, start); | ||
135 | 107 | strcpy(value, vstart); | ||
136 | 108 | |||
137 | 109 | /* create new list node and add to the list */ | ||
138 | 110 | if (!(node = (Node*)malloc(sizeof *node))) | ||
139 | 111 | { | ||
140 | 112 | free(key); | ||
141 | 113 | free(value); | ||
142 | 114 | cfgstr_destroy(cfgstr); | ||
143 | 115 | return 0; | ||
144 | 116 | } | ||
145 | 117 | |||
146 | 118 | node->key = key; | ||
147 | 119 | node->value = value; | ||
148 | 120 | node->next = cfgstr->list; | ||
149 | 121 | cfgstr->list = node; | ||
150 | 122 | } | ||
151 | 123 | |||
152 | 124 | return cfgstr; | ||
153 | 125 | } | ||
154 | 126 | |||
155 | 127 | void cfgstr_destroy (ConfigString *cfgstr) | ||
156 | 128 | { | ||
157 | 129 | if (!cfgstr) | ||
158 | 130 | return; | ||
159 | 131 | |||
160 | 132 | while (cfgstr->list) | ||
161 | 133 | { | ||
162 | 134 | struct Node *node = cfgstr->list; | ||
163 | 135 | cfgstr->list = cfgstr->list->next; | ||
164 | 136 | free(node->key); | ||
165 | 137 | free(node->value); | ||
166 | 138 | free(node); | ||
167 | 139 | } | ||
168 | 140 | free(cfgstr->string); | ||
169 | 141 | free(cfgstr); | ||
170 | 142 | } | ||
171 | 143 | |||
172 | 144 | const char *cfgstr_get_string (const ConfigString *cfgstr) | ||
173 | 145 | { | ||
174 | 146 | int len; | ||
175 | 147 | const struct Node *node; | ||
176 | 148 | char *end; | ||
177 | 149 | |||
178 | 150 | free(cfgstr->string); | ||
179 | 151 | |||
180 | 152 | /* determine the string size */ | ||
181 | 153 | len = 0; | ||
182 | 154 | node = cfgstr->list; | ||
183 | 155 | while (node) | ||
184 | 156 | { | ||
185 | 157 | len += strlen(node->key) + strlen(node->value) + 2; | ||
186 | 158 | node = node->next; | ||
187 | 159 | } | ||
188 | 160 | |||
189 | 161 | if (!(((ConfigString*)cfgstr)->string = (char*)malloc(len + 1))) | ||
190 | 162 | return 0; | ||
191 | 163 | |||
192 | 164 | end = cfgstr->string; | ||
193 | 165 | node = cfgstr->list; | ||
194 | 166 | |||
195 | 167 | while (node) | ||
196 | 168 | { | ||
197 | 169 | end += sprintf(end, "%s=%s;", node->key, node->value); | ||
198 | 170 | node = node->next; | ||
199 | 171 | } | ||
200 | 172 | |||
201 | 173 | return cfgstr->string; | ||
202 | 174 | } | ||
203 | 175 | |||
204 | 176 | static struct Node *find_node(struct Node *node, const char *key) | ||
205 | 177 | { | ||
206 | 178 | while (node) | ||
207 | 179 | { | ||
208 | 180 | if (strcmp(node->key, key) == 0) | ||
209 | 181 | return node; | ||
210 | 182 | |||
211 | 183 | node = node->next; | ||
212 | 184 | } | ||
213 | 185 | return 0; | ||
214 | 186 | } | ||
215 | 187 | |||
216 | 188 | const char *cfgstr_get (const ConfigString *cfgstr, const char *key) | ||
217 | 189 | { | ||
218 | 190 | struct Node *node = find_node(cfgstr->list, key); | ||
219 | 191 | if (!node) | ||
220 | 192 | return 0; | ||
221 | 193 | |||
222 | 194 | return node->value; | ||
223 | 195 | } | ||
224 | 196 | |||
225 | 197 | float cfgstr_get_float (const ConfigString *cfgstr, const char *key) | ||
226 | 198 | { | ||
227 | 199 | const char *val_str = cfgstr_get(cfgstr, key); | ||
228 | 200 | return val_str ? atof(val_str) : 0; | ||
229 | 201 | } | ||
230 | 202 | |||
231 | 203 | int cfgstr_get_int (const ConfigString *cfgstr, const char *key) | ||
232 | 204 | { | ||
233 | 205 | const char *val_str = cfgstr_get(cfgstr, key); | ||
234 | 206 | return val_str ? atoi(val_str) : 0; | ||
235 | 207 | } | ||
236 | 208 | |||
237 | 209 | /* | ||
238 | 210 | * returns: | ||
239 | 211 | * -1: on error | ||
240 | 212 | * 0: successfuly updated value | ||
241 | 213 | * 1: added new key-value pair | ||
242 | 214 | * */ | ||
243 | 215 | |||
244 | 216 | int cfgstr_set (ConfigString *cfgstr, const char *key, const char *value) | ||
245 | 217 | { | ||
246 | 218 | char *new_val; | ||
247 | 219 | struct Node *node = find_node(cfgstr->list, key); | ||
248 | 220 | if (!node) | ||
249 | 221 | { | ||
250 | 222 | if ((!(node = (Node*)malloc(sizeof *node)))) | ||
251 | 223 | return -1; | ||
252 | 224 | |||
253 | 225 | if ((!(node->key = (char*)malloc(strlen(key) + 1)))) | ||
254 | 226 | { | ||
255 | 227 | free(node); | ||
256 | 228 | return -1; | ||
257 | 229 | } | ||
258 | 230 | |||
259 | 231 | if ((!(node->value = (char*)malloc(strlen(value) + 1)))) | ||
260 | 232 | { | ||
261 | 233 | free(node->key); | ||
262 | 234 | free(node); | ||
263 | 235 | return -1; | ||
264 | 236 | } | ||
265 | 237 | |||
266 | 238 | strcpy(node->key, key); | ||
267 | 239 | strcpy(node->value, value); | ||
268 | 240 | node->next = cfgstr->list; | ||
269 | 241 | cfgstr->list = node; | ||
270 | 242 | |||
271 | 243 | return 1; | ||
272 | 244 | } | ||
273 | 245 | |||
274 | 246 | if ((!(new_val = (char*)malloc(strlen(value) + 1)))) | ||
275 | 247 | return -1; | ||
276 | 248 | |||
277 | 249 | strcpy(new_val, value); | ||
278 | 250 | free(node->value); | ||
279 | 251 | node->value = new_val; | ||
280 | 252 | return 0; | ||
281 | 253 | } | ||
282 | 254 | |||
283 | 255 | int cfgstr_set_float (ConfigString *cfgstr, const char *key, float value) | ||
284 | 256 | { | ||
285 | 257 | char buf[512]; | ||
286 | 258 | snprintf(buf, sizeof buf, "%f", value); | ||
287 | 259 | buf[sizeof buf - 1] = 0; /* make sure it's null terminated */ | ||
288 | 260 | |||
289 | 261 | return cfgstr_set(cfgstr, key, buf); | ||
290 | 262 | } | ||
291 | 263 | |||
292 | 264 | int cfgstr_set_int (ConfigString *cfgstr, const char *key, int value) | ||
293 | 265 | { | ||
294 | 266 | char buf[32]; | ||
295 | 267 | snprintf(buf, sizeof buf, "%d", value); | ||
296 | 268 | buf[sizeof buf - 1] = 0; /* make sure it's null terminated */ | ||
297 | 269 | |||
298 | 270 | return cfgstr_set(cfgstr, key, buf); | ||
299 | 271 | } | ||
300 | 272 | |||
301 | 273 | static char *strip_whitespace (char *buf) | ||
302 | 274 | { | ||
303 | 275 | while (*buf && isspace(*buf)) | ||
304 | 276 | buf++; | ||
305 | 277 | |||
306 | 278 | if (!*buf) | ||
307 | 279 | return 0; | ||
308 | 280 | |||
309 | 281 | char *end = buf + strlen(buf) - 1; | ||
310 | 282 | while (end > buf && isspace(*end)) | ||
311 | 283 | end--; | ||
312 | 284 | |||
313 | 285 | end[1] = 0; | ||
314 | 286 | return buf; | ||
315 | 287 | } | ||
316 | 288 | 0 | ||
317 | === removed file 'unity-shared/ConfigParser.h' | |||
318 | --- unity-shared/ConfigParser.h 2014-02-03 10:18:52 +0000 | |||
319 | +++ unity-shared/ConfigParser.h 1970-01-01 00:00:00 +0000 | |||
320 | @@ -1,37 +0,0 @@ | |||
321 | 1 | /* | ||
322 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
323 | 3 | * | ||
324 | 4 | * This program is free software: you can redistribute it and/or modify | ||
325 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
326 | 6 | * published by the Free Software Foundation. | ||
327 | 7 | * | ||
328 | 8 | * This program is distributed in the hope that it will be useful, | ||
329 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
330 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
331 | 11 | * GNU General Public License for more details. | ||
332 | 12 | * | ||
333 | 13 | * You should have received a copy of the GNU General Public License | ||
334 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
335 | 15 | * | ||
336 | 16 | * Authored by: Eleni Maria Stea <elenimaria.stea@canonical.com> | ||
337 | 17 | */ | ||
338 | 18 | |||
339 | 19 | #ifndef CONFIG_PARSER_H_ | ||
340 | 20 | #define CONFIG_PARSER_H_ | ||
341 | 21 | |||
342 | 22 | typedef struct ConfigString ConfigString; | ||
343 | 23 | |||
344 | 24 | ConfigString *cfgstr_create (const char *str); | ||
345 | 25 | void cfgstr_destroy (ConfigString *cfgstr); | ||
346 | 26 | |||
347 | 27 | const char *cfgstr_get_string(const ConfigString *cfgstr); | ||
348 | 28 | |||
349 | 29 | const char *cfgstr_get (const ConfigString *cfgstr, const char *key); | ||
350 | 30 | float cfgstr_get_float (const ConfigString *cfgstr, const char *key); | ||
351 | 31 | int cfgstr_get_int (const ConfigString *cfgstr, const char *key); | ||
352 | 32 | |||
353 | 33 | int cfgstr_set (ConfigString *cfgstr, const char *key, const char *value); | ||
354 | 34 | int cfgstr_set_float (ConfigString *cfgstr, const char *key, float value); | ||
355 | 35 | int cfgstr_set_int (ConfigString *cfgstr, const char *key, int value); | ||
356 | 36 | |||
357 | 37 | #endif // CONFIG_PARSER_H_ | ||
358 | 38 | 0 | ||
359 | === modified file 'unity-shared/UScreen.cpp' | |||
360 | --- unity-shared/UScreen.cpp 2014-02-19 16:36:04 +0000 | |||
361 | +++ unity-shared/UScreen.cpp 2014-02-21 17:06:30 +0000 | |||
362 | @@ -96,15 +96,27 @@ | |||
363 | 96 | return nux::Geometry(0, 0, width, height); | 96 | return nux::Geometry(0, 0, width, height); |
364 | 97 | } | 97 | } |
365 | 98 | 98 | ||
375 | 99 | const std::string UScreen::GetMonitorName(int output_number) const | 99 | const std::string UScreen::GetMonitorName(int output_number = 0) const |
376 | 100 | { | 100 | { |
377 | 101 | auto const &output_name = glib::gchar_to_string(gdk_screen_get_monitor_plug_name(screen_, output_number)); | 101 | if (output_number < 0 || output_number > gdk_screen_get_n_monitors(screen_)) |
378 | 102 | if (output_name.empty()) | 102 | { |
379 | 103 | { | 103 | LOG_ERROR(logger) << "UScreen::GetMonitorName: Invalid monitor number" << output_number; |
380 | 104 | LOG_ERROR(logger) << "Failed to get monitor name"; | 104 | return ""; |
381 | 105 | } | 105 | } |
382 | 106 | 106 | ||
383 | 107 | return output_name; | 107 | char* const output_name = gdk_screen_get_monitor_plug_name(screen_, output_number); |
384 | 108 | if (!output_name) | ||
385 | 109 | { | ||
386 | 110 | LOG_ERROR(logger) << "UScreen::GetMonitorName: Failed to get monitor name for monitor" << output_number; | ||
387 | 111 | return ""; | ||
388 | 112 | } | ||
389 | 113 | |||
390 | 114 | return std::string(output_name); | ||
391 | 115 | } | ||
392 | 116 | |||
393 | 117 | int UScreen::GetPluggedMonitorsNumber() const | ||
394 | 118 | { | ||
395 | 119 | return monitors_.size(); | ||
396 | 108 | } | 120 | } |
397 | 109 | 121 | ||
398 | 110 | void UScreen::Changed(GdkScreen* screen) | 122 | void UScreen::Changed(GdkScreen* screen) |
399 | 111 | 123 | ||
400 | === modified file 'unity-shared/UScreen.h' | |||
401 | --- unity-shared/UScreen.h 2014-02-06 10:07:27 +0000 | |||
402 | +++ unity-shared/UScreen.h 2014-02-21 17:06:30 +0000 | |||
403 | @@ -53,6 +53,7 @@ | |||
404 | 53 | sigc::signal<void> resuming; | 53 | sigc::signal<void> resuming; |
405 | 54 | 54 | ||
406 | 55 | const std::string GetMonitorName(int output_number) const; | 55 | const std::string GetMonitorName(int output_number) const; |
407 | 56 | int GetPluggedMonitorsNumber() const; | ||
408 | 56 | 57 | ||
409 | 57 | private: | 58 | private: |
410 | 58 | void Changed(GdkScreen* screen); | 59 | void Changed(GdkScreen* screen); |
411 | 59 | 60 | ||
412 | === modified file 'unity-shared/UnitySettings.cpp' | |||
413 | --- unity-shared/UnitySettings.cpp 2014-02-19 16:40:07 +0000 | |||
414 | +++ unity-shared/UnitySettings.cpp 2014-02-21 17:06:30 +0000 | |||
415 | @@ -21,6 +21,7 @@ | |||
416 | 21 | #include <gdk/gdk.h> | 21 | #include <gdk/gdk.h> |
417 | 22 | #include <gtk/gtk.h> | 22 | #include <gtk/gtk.h> |
418 | 23 | #include <gio/gio.h> | 23 | #include <gio/gio.h> |
419 | 24 | #include <glib.h> | ||
420 | 24 | 25 | ||
421 | 25 | #include <NuxCore/Logger.h> | 26 | #include <NuxCore/Logger.h> |
422 | 26 | 27 | ||
423 | @@ -39,15 +40,12 @@ | |||
424 | 39 | const std::string SETTINGS_NAME = "com.canonical.Unity"; | 40 | const std::string SETTINGS_NAME = "com.canonical.Unity"; |
425 | 40 | const std::string FORM_FACTOR = "form-factor"; | 41 | const std::string FORM_FACTOR = "form-factor"; |
426 | 41 | const std::string DOUBLE_CLICK_ACTIVATE = "double-click-activate"; | 42 | const std::string DOUBLE_CLICK_ACTIVATE = "double-click-activate"; |
427 | 43 | const std::string SCALE_FACTOR = "scale-factor"; | ||
428 | 42 | const std::string LIM_KEY = "integrated-menus"; | 44 | const std::string LIM_KEY = "integrated-menus"; |
429 | 43 | |||
430 | 44 | const std::string LIM_SETTINGS = "com.canonical.Unity.IntegratedMenus"; | 45 | const std::string LIM_SETTINGS = "com.canonical.Unity.IntegratedMenus"; |
431 | 45 | const std::string CLICK_MOVEMENT_THRESHOLD = "click-movement-threshold"; | 46 | const std::string CLICK_MOVEMENT_THRESHOLD = "click-movement-threshold"; |
432 | 46 | const std::string DOUBLE_CLICK_WAIT = "double-click-wait"; | 47 | const std::string DOUBLE_CLICK_WAIT = "double-click-wait"; |
437 | 47 | 48 | const std::string UI_SETTINGS = "com.ubuntu.user-interface"; | |
434 | 48 | // FIXME Update this when hikikos settings changes land in unity | ||
435 | 49 | const std::string GNOME_SETTINGS = "org.gnome.desktop.interface"; | ||
436 | 50 | const std::string SCALING_FACTOR = "scaling-factor"; | ||
438 | 51 | } | 49 | } |
439 | 52 | 50 | ||
440 | 53 | // | 51 | // |
441 | @@ -58,9 +56,10 @@ | |||
442 | 58 | public: | 56 | public: |
443 | 59 | Impl(Settings* owner) | 57 | Impl(Settings* owner) |
444 | 60 | : parent_(owner) | 58 | : parent_(owner) |
445 | 59 | , gsettings_(g_settings_new(SETTINGS_NAME.c_str())) | ||
446 | 60 | , ubuntu_settings_(g_settings_new(UI_SETTINGS.c_str())) | ||
447 | 61 | , usettings_(g_settings_new(SETTINGS_NAME.c_str())) | 61 | , usettings_(g_settings_new(SETTINGS_NAME.c_str())) |
448 | 62 | , lim_settings_(g_settings_new(LIM_SETTINGS.c_str())) | 62 | , lim_settings_(g_settings_new(LIM_SETTINGS.c_str())) |
449 | 63 | , gnome_settings_(g_settings_new(GNOME_SETTINGS.c_str())) | ||
450 | 64 | , cached_form_factor_(FormFactor::DESKTOP) | 63 | , cached_form_factor_(FormFactor::DESKTOP) |
451 | 65 | , cached_double_click_activate_(true) | 64 | , cached_double_click_activate_(true) |
452 | 66 | , lowGfx_(false) | 65 | , lowGfx_(false) |
453 | @@ -82,6 +81,9 @@ | |||
454 | 82 | CacheDoubleClickActivate(); | 81 | CacheDoubleClickActivate(); |
455 | 83 | parent_->double_click_activate.changed.emit(cached_double_click_activate_); | 82 | parent_->double_click_activate.changed.emit(cached_double_click_activate_); |
456 | 84 | }); | 83 | }); |
457 | 84 | signals_.Add<void, GSettings*, const gchar*>(ubuntu_settings_, "changed::" + SCALE_FACTOR, [this] (GSettings*, const gchar* t) { | ||
458 | 85 | UpdateEMConverter(); | ||
459 | 86 | }); | ||
460 | 85 | 87 | ||
461 | 86 | signals_.Add<void, GSettings*, const gchar*>(usettings_, "changed::" + LIM_KEY, [this] (GSettings*, const gchar*) { | 88 | signals_.Add<void, GSettings*, const gchar*>(usettings_, "changed::" + LIM_KEY, [this] (GSettings*, const gchar*) { |
462 | 87 | UpdateLimSetting(); | 89 | UpdateLimSetting(); |
463 | @@ -90,10 +92,6 @@ | |||
464 | 90 | signals_.Add<void, GSettings*, const gchar*>(lim_settings_, "changed", [this] (GSettings*, const gchar*) { | 92 | signals_.Add<void, GSettings*, const gchar*>(lim_settings_, "changed", [this] (GSettings*, const gchar*) { |
465 | 91 | UpdateLimSetting(); | 93 | UpdateLimSetting(); |
466 | 92 | }); | 94 | }); |
467 | 93 | |||
468 | 94 | signals_.Add<void, GSettings*, const gchar*>(gnome_settings_, "changed::" + SCALING_FACTOR, [this] (GSettings*, const gchar* t) { | ||
469 | 95 | UpdateEMConverter(); | ||
470 | 96 | }); | ||
471 | 97 | } | 95 | } |
472 | 98 | 96 | ||
473 | 99 | void CacheFormFactor() | 97 | void CacheFormFactor() |
474 | @@ -154,13 +152,37 @@ | |||
475 | 154 | return font_size / 1024; | 152 | return font_size / 1024; |
476 | 155 | } | 153 | } |
477 | 156 | 154 | ||
479 | 157 | // FIXME Add in getting the specific dpi scale from each monitor | 155 | float GetUIScaleFactor(int monitor = 0) const |
480 | 156 | { | ||
481 | 157 | GVariant* dict; | ||
482 | 158 | g_settings_get(ubuntu_settings_, SCALE_FACTOR.c_str(), "@a{si}", &dict); | ||
483 | 159 | |||
484 | 160 | std::string monitor_name = UScreen::GetDefault()->GetMonitorName(monitor); | ||
485 | 161 | |||
486 | 162 | int value; | ||
487 | 163 | float ui_scale; | ||
488 | 164 | if (!g_variant_lookup (dict, monitor_name.c_str(), "i", &value)) | ||
489 | 165 | { | ||
490 | 166 | ui_scale = 1.0; | ||
491 | 167 | } | ||
492 | 168 | else | ||
493 | 169 | { | ||
494 | 170 | ui_scale = (float)value / 8.0; | ||
495 | 171 | } | ||
496 | 172 | |||
497 | 173 | return ui_scale; | ||
498 | 174 | } | ||
499 | 175 | |||
500 | 158 | int GetDPI(int monitor = 0) const | 176 | int GetDPI(int monitor = 0) const |
501 | 159 | { | 177 | { |
502 | 160 | int dpi = 96; | 178 | int dpi = 96; |
506 | 161 | int scale = g_settings_get_uint(gnome_settings_, SCALING_FACTOR.c_str()); | 179 | int valid_monitors = UScreen::GetDefault()->GetPluggedMonitorsNumber(); |
507 | 162 | 180 | if (monitor >= 0 && monitor < valid_monitors) | |
508 | 163 | return dpi * (scale > 0 ? scale : 1); | 181 | { |
509 | 182 | float new_dpi = (float)dpi * GetUIScaleFactor(monitor); | ||
510 | 183 | dpi = (int)new_dpi; | ||
511 | 184 | } | ||
512 | 185 | return dpi; | ||
513 | 164 | } | 186 | } |
514 | 165 | 187 | ||
515 | 166 | void UpdateFontSize() | 188 | void UpdateFontSize() |
516 | @@ -189,6 +211,8 @@ | |||
517 | 189 | } | 211 | } |
518 | 190 | 212 | ||
519 | 191 | Settings* parent_; | 213 | Settings* parent_; |
520 | 214 | glib::Object<GSettings> gsettings_; | ||
521 | 215 | glib::Object<GSettings> ubuntu_settings_; | ||
522 | 192 | glib::Object<GSettings> usettings_; | 216 | glib::Object<GSettings> usettings_; |
523 | 193 | glib::Object<GSettings> lim_settings_; | 217 | glib::Object<GSettings> lim_settings_; |
524 | 194 | glib::Object<GSettings> gnome_settings_; | 218 | glib::Object<GSettings> gnome_settings_; |
PASSED: Continuous integration, rev:3674 jenkins. qa.ubuntu. com/job/ unity-ci/ 698/ jenkins. qa.ubuntu. com/job/ unity-trusty- amd64-ci/ 234 jenkins. qa.ubuntu. com/job/ unity-trusty- armhf-ci/ 230 jenkins. qa.ubuntu. com/job/ unity-trusty- i386-ci/ 232
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- ci/698/ rebuild
http://