Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use HCL color space (Rec.2020 for luma) instead of HSV #1235

Merged
merged 24 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,13 @@ if(BUILD_INTEL_BACKLIGHT)
set(optional_sources ${optional_sources} ${intel_backlight})
endif(BUILD_INTEL_BACKLIGHT)

if(BUILD_HSV_GRADIENT)
if(BUILD_HCL_GRADIENT)
set(hcl_gradient hcl_gradient.cc hcl_gradient.h)
set(optional_sources ${optional_sources} ${hcl_gradient})
elseif(BUILD_HSV_GRADIENT)
set(hsv_gradient hsv_gradient.cc hsv_gradient.h)
set(optional_sources ${optional_sources} ${hsv_gradient})
endif(BUILD_HSV_GRADIENT)
endif(BUILD_HCL_GRADIENT)

if(BUILD_TESTS)
# Create a library strictly for testing
Expand Down
16 changes: 9 additions & 7 deletions src/cmus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ void cmus_cb::work() {

} else if (strncmp(line, "position ", 9) == 0) {
cmus.curtime = line + 9;
cmus.timeleft =
strtol(cmus.totaltime.c_str(), nullptr, 10) -
strtol(cmus.curtime.c_str(), nullptr, 10);
cmus.timeleft = strtol(cmus.totaltime.c_str(), nullptr, 10) -
strtol(cmus.curtime.c_str(), nullptr, 10);
if (cmus.curtime.size() > 0) {
cmus.progress = static_cast<float>(strtol(cmus.curtime.c_str(), nullptr, 10)) /
strtol(cmus.totaltime.c_str(), nullptr, 10);
cmus.progress =
static_cast<float>(strtol(cmus.curtime.c_str(), nullptr, 10)) /
strtol(cmus.totaltime.c_str(), nullptr, 10);
} else {
cmus.progress = 0;
}
Expand Down Expand Up @@ -189,7 +189,8 @@ void print_cmus_totaltime(struct text_object *obj, char *p,
lround(music_player_interval.get(*state) / active_update_interval()), 1l);
const cmus_result &cmus =
conky::register_cb<cmus_cb>(period)->get_result_copy();
format_seconds_short(p, p_max_size, strtol(cmus.totaltime.c_str(), nullptr, 10));
format_seconds_short(p, p_max_size,
strtol(cmus.totaltime.c_str(), nullptr, 10));
}

void print_cmus_timeleft(struct text_object *obj, char *p,
Expand All @@ -209,7 +210,8 @@ void print_cmus_curtime(struct text_object *obj, char *p,
lround(music_player_interval.get(*state) / active_update_interval()), 1l);
const cmus_result &cmus =
conky::register_cb<cmus_cb>(period)->get_result_copy();
format_seconds_short(p, p_max_size, strtol(cmus.curtime.c_str(), nullptr, 10));
format_seconds_short(p, p_max_size,
strtol(cmus.curtime.c_str(), nullptr, 10));
}

#undef CMUS_PRINT_GENERATOR
3 changes: 2 additions & 1 deletion src/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ void print_cached(struct text_object *obj, char *p, unsigned int p_max_size) {
p_max_size);
}

void print_free_bufcache(struct text_object *obj, char *p, unsigned int p_max_size) {
void print_free_bufcache(struct text_object *obj, char *p,
unsigned int p_max_size) {
human_readable(apply_base_multiplier(obj->data.s, info.free_bufcache), p,
p_max_size);
}
Expand Down
8 changes: 8 additions & 0 deletions src/conky.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@
#include "openbsd.h"
#endif /* __OpenBSD__ */

#ifdef BUILD_HCL_GRADIENT
#include "hcl_gradient.h"
#endif /* BUILD_HCL_GRADIENT */

#ifdef BUILD_HSV_GRADIENT
#include "hsv_gradient.h"
#endif /* BUILD_HSV_GRADIENT */
Expand Down Expand Up @@ -1294,6 +1298,10 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied) {
std::unique_ptr<unsigned long[]> tmpcolour;

if (current->last_colour != 0 || current->first_colour != 0) {
#ifdef BUILD_HCL_GRADIENT
tmpcolour = do_hcl_gradient(w - 1, current->last_colour,
current->first_colour);
#endif /* BUILD_HCL_GRADIENT */
#ifdef BUILD_HSV_GRADIENT
tmpcolour = do_hsv_gradient(w - 1, current->last_colour,
current->first_colour);
Expand Down
34 changes: 22 additions & 12 deletions src/core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
END OBJ(freq, nullptr) get_cpu_count();
if ((arg == nullptr) || strlen(arg) >= 3 ||
strtol(&arg[0], nullptr, 10) == 0 ||
static_cast<unsigned int>(strtol(&arg[0], nullptr, 10)) > info.cpu_count) {
static_cast<unsigned int>(strtol(&arg[0], nullptr, 10)) >
info.cpu_count) {
obj->data.i = 1;
/* NORM_ERR("freq: Invalid CPU number or you don't have that many CPUs! "
"Displaying the clock for CPU 1."); */
Expand All @@ -445,7 +446,8 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
END OBJ(freq_g, nullptr) get_cpu_count();
if ((arg == nullptr) || strlen(arg) >= 3 ||
strtol(&arg[0], nullptr, 10) == 0 ||
static_cast<unsigned int>(strtol(&arg[0], nullptr, 10)) > info.cpu_count) {
static_cast<unsigned int>(strtol(&arg[0], nullptr, 10)) >
info.cpu_count) {
obj->data.i = 1;
/* NORM_ERR("freq_g: Invalid CPU number or you don't have that many "
"CPUs! Displaying the clock for CPU 1."); */
Expand All @@ -457,7 +459,8 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
END OBJ(cpugovernor, nullptr) get_cpu_count();
if ((arg == nullptr) || strlen(arg) >= 3 ||
strtol(&arg[0], nullptr, 10) == 0 ||
static_cast<unsigned int>(strtol(&arg[0], nullptr, 10)) > info.cpu_count) {
static_cast<unsigned int>(strtol(&arg[0], nullptr, 10)) >
info.cpu_count) {
obj->data.i = 1;
/* NORM_ERR("cpugovernor: Invalid CPU number or you don't have that "
"many CPUs! Displaying the scaling governor for CPU 1."); */
Expand All @@ -484,7 +487,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
#if defined(__linux__)
END OBJ(voltage_mv, 0) get_cpu_count();
if (!arg || strlen(arg) >= 3 || strtol(&arg[0], nullptr, 10) == 0 ||
(unsigned int)strtol(&arg[0], nullptr, 10) > info.cpu_count) {
(unsigned int)strtol(&arg[0], nullptr, 10) > info.cpu_count) {
obj->data.i = 1;
/* NORM_ERR("voltage_mv: Invalid CPU number or you don't have that many "
"CPUs! Displaying voltage for CPU 1."); */
Expand All @@ -494,7 +497,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
obj->callbacks.print = &print_voltage_mv;
END OBJ(voltage_v, 0) get_cpu_count();
if (!arg || strlen(arg) >= 3 || strtol(&arg[0], nullptr, 10) == 0 ||
(unsigned int)strtol(&arg[0], nullptr, 10) > info.cpu_count) {
(unsigned int)strtol(&arg[0], nullptr, 10) > info.cpu_count) {
obj->data.i = 1;
/* NORM_ERR("voltage_v: Invalid CPU number or you don't have that many "
"CPUs! Displaying voltage for CPU 1."); */
Expand Down Expand Up @@ -1017,20 +1020,24 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
END OBJ(fs_used, &update_fs_stats) init_fs(obj, arg);
obj->callbacks.print = &print_fs_used;
#ifdef BUILD_GUI
END OBJ(hr, nullptr) obj->data.l = arg != nullptr ? strtol(arg, nullptr, 10) : 1;
END OBJ(hr, nullptr) obj->data.l =
arg != nullptr ? strtol(arg, nullptr, 10) : 1;
obj->callbacks.print = &new_hr;
#endif /* BUILD_GUI */
END OBJ(nameserver, &update_dns_data) parse_nameserver_arg(obj, arg);
obj->callbacks.print = &print_nameserver;
obj->callbacks.free = &free_dns_data;
END OBJ(offset, nullptr) obj->data.l = arg != nullptr ? strtol(arg, nullptr, 10) : 1;
END OBJ(offset, nullptr) obj->data.l =
arg != nullptr ? strtol(arg, nullptr, 10) : 1;
obj->callbacks.print = &new_offset;
END OBJ(voffset, nullptr) obj->data.l = arg != nullptr ? strtol(arg, nullptr, 10) : 1;
END OBJ(voffset, nullptr) obj->data.l =
arg != nullptr ? strtol(arg, nullptr, 10) : 1;
obj->callbacks.print = &new_voffset;
END OBJ(save_coordinates, nullptr) obj->data.l =
arg != nullptr ? strtol(arg, nullptr, 10) : 0;
obj->callbacks.print = &new_save_coordinates;
END OBJ_ARG(goto, nullptr, "goto needs arguments") obj->data.l = strtol(arg, nullptr, 10);
END OBJ_ARG(goto, nullptr, "goto needs arguments") obj->data.l =
strtol(arg, nullptr, 10);
obj->callbacks.print = &new_goto;
#ifdef BUILD_GUI
END OBJ(tab, nullptr) scan_tab(obj, arg);
Expand Down Expand Up @@ -1493,17 +1500,20 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_totalup;
END OBJ(updates, nullptr) obj->callbacks.print = &print_updates;
END OBJ_IF(if_updatenr, nullptr) obj->data.i = arg != nullptr ? strtol(arg, nullptr, 10) : 0;
END OBJ_IF(if_updatenr, nullptr) obj->data.i =
arg != nullptr ? strtol(arg, nullptr, 10) : 0;
if (obj->data.i == 0) {
CRIT_ERR(obj, free_at_crash,
"if_updatenr needs a number above 0 as argument");
}
set_updatereset(obj->data.i > get_updatereset() ? obj->data.i
: get_updatereset());
obj->callbacks.iftest = &updatenr_iftest;
END OBJ(alignr, nullptr) obj->data.l = arg != nullptr ? strtol(arg, nullptr, 10) : 1;
END OBJ(alignr, nullptr) obj->data.l =
arg != nullptr ? strtol(arg, nullptr, 10) : 1;
obj->callbacks.print = &new_alignr;
END OBJ(alignc, nullptr) obj->data.l = arg != nullptr ? strtol(arg, nullptr, 10) : 0;
END OBJ(alignc, nullptr) obj->data.l =
arg != nullptr ? strtol(arg, nullptr, 10) : 0;
obj->callbacks.print = &new_alignc;
END OBJ(upspeed, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
Expand Down
Loading