aboutsummaryrefslogtreecommitdiffstats
path: root/include/util.h
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-12-27 23:33:55 -0500
committerLibravatar Simon Ser <contact@emersion.fr>2019-12-28 10:07:25 +0100
commit97f9f0b699316ba60009b395948a712ec0b671d2 (patch)
treeb5916b36f4161c1c4d670295254d0f3fd9e793df /include/util.h
parentlayer-shell: refocus if keyboard interactive lost (diff)
downloadsway-97f9f0b699316ba60009b395948a712ec0b671d2.tar.gz
sway-97f9f0b699316ba60009b395948a712ec0b671d2.tar.zst
sway-97f9f0b699316ba60009b395948a712ec0b671d2.zip
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.
Diffstat (limited to 'include/util.h')
-rw-r--r--include/util.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/include/util.h b/include/util.h
index 3cba49f0..931ac691 100644
--- a/include/util.h
+++ b/include/util.h
@@ -11,10 +11,11 @@
11int wrap(int i, int max); 11int wrap(int i, int max);
12 12
13/** 13/**
14 * Given a string that represents an RGB(A) color, return a uint32_t 14 * Given a string that represents an RGB(A) color, result will be set to a
15 * version of the color. 15 * uint32_t version of the color, as long as it is valid. If it is invalid,
16 * then false will be returned and result will be untouched.
16 */ 17 */
17uint32_t parse_color(const char *color); 18bool parse_color(const char *color, uint32_t *result);
18 19
19/** 20/**
20 * Given a string that represents a boolean, return the boolean value. This 21 * Given a string that represents a boolean, return the boolean value. This