summaryrefslogtreecommitdiff
path: root/clients/desktop-shell.c
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/desktop-shell.c
parentcbfde138597e5a3f0693aa4bc7c08a515d1e0f82 (diff)
downloadweston-e776f2a4d9a335a41d9cbc8b06ba97a660051614.tar.gz
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/desktop-shell.c')
-rw-r--r--clients/desktop-shell.c8
1 files changed, 4 insertions, 4 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");