From 97f9f0b699316ba60009b395948a712ec0b671d2 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Fri, 27 Dec 2019 23:33:55 -0500 Subject: parse_color: return success + drop fallback color This is the first in a series of commits to refactor the color handling in sway. This changes parse_color to return whether it was success and no longer uses 0xFFFFFFFF as the fallback color. This also verifies that the string actually contains a valid hexadecimal number along with the length checks. In the process of altering the calls to parse_color, I also took the opportunity to heavily refactor swaybar's ipc_parse_colors function. This allowed for several lines of duplicated code to be removed. --- include/swaybar/i3bar.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/swaybar') diff --git a/include/swaybar/i3bar.h b/include/swaybar/i3bar.h index 5b6001ce..0b3bee21 100644 --- a/include/swaybar/i3bar.h +++ b/include/swaybar/i3bar.h @@ -9,7 +9,8 @@ struct i3bar_block { int ref_count; char *full_text, *short_text, *align, *min_width_str; bool urgent; - uint32_t *color; + uint32_t color; + bool color_set; int min_width; char *name, *instance; bool separator; -- cgit v1.2.3