summaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorBryce Harrington <bryce@osg.samsung.com>2016-07-14 18:28:03 -0700
committerBryce Harrington <bryce@osg.samsung.com>2016-07-26 15:57:14 -0700
commite776f2a4d9a335a41d9cbc8b06ba97a660051614 (patch)
tree53c674532942a7d24a2a44a22bf9abaaa92210ab /clients
parentcbfde138597e5a3f0693aa4bc7c08a515d1e0f82 (diff)
config-parser: Add weston_config_section_get_color
Previously weston_config_section_get_uint was serving dual purpose for parsing both unsigned decimal integer values (ids, counts, seconds, etc.) and hexadecimal values (colors), by relying on strtoul's auto-detection mechanism. However, this usage is unable to catch certain kinds of error conditions, such as specifying a negative number where an unsigned should be used. And for colors in particular, it would misparse hex values if the leading 0x was omitted. E.g. "background-color=99999999" would render a near-black background (effectively 0x05f5e0ff) instead of medium grey, and "background-color=ffffffff" would be treated as an error rather than white. "background-color=0x01234567", "background-color=01234567", and "background-color=1234567" each resulted in the value being parsed as hexadecimal, octal, and decimal respectively, resulting in colors 0x01234567, 0x00053977, and 0x0012d687 being displayed. This new routine forces hexadecimal to be used in all cases when parsing color values, so "0x01234567" and "01234567" result in the same color value, "99999999" is grey, and "ffffffff" is white. It also requires exactly 8 or 10 digits (other lengths likely indicate typos), or the value "0" (black). Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Diffstat (limited to 'clients')
-rw-r--r--clients/desktop-shell.c8
-rw-r--r--clients/ivi-shell-user-interface.c2
2 files changed, 5 insertions, 5 deletions
diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index f5e0ba2e..18b8f9ea 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -571,8 +571,8 @@ panel_create(struct desktop *desktop)
free (clock_format_option);
s = weston_config_get_section(desktop->config, "shell", NULL, NULL);
- weston_config_section_get_uint(s, "panel-color",
- &panel->color, 0xaa000000);
+ weston_config_section_get_color(s, "panel-color",
+ &panel->color, 0xaa000000);
panel_add_launchers(panel, desktop);
@@ -1068,8 +1068,8 @@ background_create(struct desktop *desktop)
s = weston_config_get_section(desktop->config, "shell", NULL, NULL);
weston_config_section_get_string(s, "background-image",
&background->image, NULL);
- weston_config_section_get_uint(s, "background-color",
- &background->color, 0);
+ weston_config_section_get_color(s, "background-color",
+ &background->color, 0x00000000);
weston_config_section_get_string(s, "background-type",
&type, "tile");
diff --git a/clients/ivi-shell-user-interface.c b/clients/ivi-shell-user-interface.c
index 06b79a22..465def1a 100644
--- a/clients/ivi-shell-user-interface.c
+++ b/clients/ivi-shell-user-interface.c
@@ -1143,7 +1143,7 @@ hmi_homescreen_setting_create(void)
weston_config_section_get_uint(
shellSection, "home-id", &setting->home.id, 1007);
- weston_config_section_get_uint(
+ weston_config_section_get_color(
shellSection, "workspace-background-color",
&setting->workspace_background.color, 0x99000000);