diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-07-30 23:28:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-30 23:28:02 -0400 |
commit | 44a4905466599155fb7203a585dfca1ce1720b33 (patch) | |
tree | a7acb9aab8520040d49be04184d70984a66b95e7 /common | |
parent | 2e4ece65da7e2afe5da1d3347c88bda48b1efa90 (diff) | |
parent | 98aa59fdda5fcc9a589e93f7c6ef40d3eaee3972 (diff) |
Merge pull request #805 from zandrmartin/swaybg-solid-color
implement solid color rendering for swaybg
Diffstat (limited to 'common')
-rw-r--r-- | common/CMakeLists.txt | 2 | ||||
-rw-r--r-- | common/util.c | 13 |
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 stringop.c ) +target_link_libraries(sway-common m) + if(Backtrace_FOUND) set_target_properties(sway-common 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) { return -1; } + +uint32_t parse_color(const char *color) { + int len = strlen(color); + if (color[0] != '#' || (len != 7 && len != 9)) { + sway_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color); + return 0xFFFFFFFF; + } + uint32_t res = (uint32_t)strtol(color + 1, NULL, 16); + if (strlen(color) == 7) { + res = (res << 8) | 0xFF; + } + return res; +} |