aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorLibravatar Zandr Martin <zandrmartin@gmail.com>2016-07-30 18:50:13 -0500
committerLibravatar Zandr Martin <zandrmartin@gmail.com>2016-07-30 18:50:13 -0500
commit98aa59fdda5fcc9a589e93f7c6ef40d3eaee3972 (patch)
treea7acb9aab8520040d49be04184d70984a66b95e7 /common
parentMerge pull request #803 from zandrmartin/x11-pids (diff)
downloadsway-98aa59fdda5fcc9a589e93f7c6ef40d3eaee3972.tar.gz
sway-98aa59fdda5fcc9a589e93f7c6ef40d3eaee3972.tar.zst
sway-98aa59fdda5fcc9a589e93f7c6ef40d3eaee3972.zip
implement solid color rendering for swaybg
Diffstat (limited to 'common')
-rw-r--r--common/CMakeLists.txt2
-rw-r--r--common/util.c13
2 files changed, 15 insertions, 0 deletions
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 9c2c0a99..3d6e0fb9 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -12,6 +12,8 @@ add_library(sway-common STATIC
12 stringop.c 12 stringop.c
13 ) 13 )
14 14
15target_link_libraries(sway-common m)
16
15if(Backtrace_FOUND) 17if(Backtrace_FOUND)
16 set_target_properties(sway-common 18 set_target_properties(sway-common
17 PROPERTIES 19 PROPERTIES
diff --git a/common/util.c b/common/util.c
index 31a75a9b..86120769 100644
--- a/common/util.c
+++ b/common/util.c
@@ -97,3 +97,16 @@ pid_t get_parent_pid(pid_t child) {
97 97
98 return -1; 98 return -1;
99} 99}
100
101uint32_t parse_color(const char *color) {
102 int len = strlen(color);
103 if (color[0] != '#' || (len != 7 && len != 9)) {
104 sway_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color);
105 return 0xFFFFFFFF;
106 }
107 uint32_t res = (uint32_t)strtol(color + 1, NULL, 16);
108 if (strlen(color) == 7) {
109 res = (res << 8) | 0xFF;
110 }
111 return res;
112}