all repos — tint2 @ abe8a0eeb11ccde0fda786d3c82316d2ee1920aa

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Implement tinting by icon content (do not apply task state asb effects)
o9000 mrovi9000@gmail.com
commit

abe8a0eeb11ccde0fda786d3c82316d2ee1920aa

parent

d82d782541f8f05156a5980576d576d07f4d75be

2 files changed, 33 insertions(+), 39 deletions(-)

jump to
M src/taskbar/task.csrc/taskbar/task.c

@@ -136,13 +136,13 @@ if (panels[monitor].g_task.tooltip_enabled) {

task_instance->area._get_tooltip_text = task_get_tooltip; task_instance->area._get_tooltip_image = task_get_thumbnail; } + task_instance->icon_color = task_template.icon_color; + task_instance->icon_color_hover = task_template.icon_color_hover; + task_instance->icon_color_press = task_template.icon_color_press; for (int k = 0; k < TASK_STATE_COUNT; ++k) { task_instance->icon[k] = task_template.icon[k]; - task_instance->icon_color[k] = task_template.icon_color[k]; task_instance->icon_hover[k] = task_template.icon_hover[k]; - task_instance->icon_color_hover[k] = task_template.icon_color_hover[k]; task_instance->icon_press[k] = task_template.icon_press[k]; - task_instance->icon_color_press[k] = task_template.icon_color_press[k]; } task_instance->icon_width = task_template.icon_width; task_instance->icon_height = task_template.icon_height;

@@ -330,33 +330,30 @@

return img; } +void task_set_icon_color(Task *task, Imlib_Image icon) +{ + get_image_mean_color(icon, &task->icon_color); + if (panel_config.mouse_effects) { + task->icon_color_hover = task->icon_color; + adjust_color(&task->icon_color_hover, + panel_config.mouse_over_alpha, + panel_config.mouse_over_saturation, + panel_config.mouse_over_brightness); + task->icon_color_press = task->icon_color; + adjust_color(&task->icon_color_press, + panel_config.mouse_pressed_alpha, + panel_config.mouse_pressed_saturation, + panel_config.mouse_pressed_brightness); + } +} + void task_update_icon(Task *task) { Panel *panel = task->area.panel; if (!panel->g_task.has_icon) { if (panel_config.g_task.has_content_tint) { Imlib_Image img = task_get_icon(task->win, panel->g_task.icon_size1); - Color icon_color; - get_image_mean_color(img, &icon_color); - for (int k = 0; k < TASK_STATE_COUNT; ++k) { - task->icon_color[k] = icon_color; - adjust_color(&task->icon_color[k], - panel->g_task.alpha[k], - panel->g_task.saturation[k], - panel->g_task.brightness[k]); - if (panel_config.mouse_effects) { - task->icon_color_hover[k] = icon_color; - adjust_color(&task->icon_color_hover[k], - panel_config.mouse_over_alpha, - panel_config.mouse_over_saturation, - panel_config.mouse_over_brightness); - task->icon_color_press[k] = icon_color; - adjust_color(&task->icon_color_press[k], - panel_config.mouse_pressed_alpha, - panel_config.mouse_pressed_saturation, - panel_config.mouse_pressed_brightness); - } - } + task_set_icon_color(task, img); imlib_context_set_image(img); imlib_free_image(); }

@@ -366,6 +363,7 @@

task_remove_icon(task); Imlib_Image img = task_get_icon(task->win, panel->g_task.icon_size1); + task_set_icon_color(task, img); // transform icons imlib_context_set_image(img);

@@ -382,7 +380,6 @@ task->icon_height = imlib_image_get_height();

for (int k = 0; k < TASK_STATE_COUNT; ++k) { imlib_context_set_image(orig_image); task->icon[k] = imlib_clone_image(); - get_image_mean_color(task->icon[k], &task->icon_color[k]); imlib_context_set_image(task->icon[k]); DATA32 *data32; if (panel->g_task.alpha[k] != 100 || panel->g_task.saturation[k] != 0 || panel->g_task.brightness[k] != 0) {

@@ -394,19 +391,16 @@ panel->g_task.alpha[k] / 100.0,

panel->g_task.saturation[k] / 100.0, panel->g_task.brightness[k] / 100.0); imlib_image_put_back_data(data32); - get_image_mean_color(task->icon[k], &task->icon_color[k]); } if (panel_config.mouse_effects) { task->icon_hover[k] = adjust_icon(task->icon[k], panel_config.mouse_over_alpha, panel_config.mouse_over_saturation, panel_config.mouse_over_brightness); - get_image_mean_color(task->icon_hover[k], &task->icon_color_hover[k]); task->icon_press[k] = adjust_icon(task->icon[k], panel_config.mouse_pressed_alpha, panel_config.mouse_pressed_saturation, panel_config.mouse_pressed_brightness); - get_image_mean_color(task->icon_press[k], &task->icon_color_press[k]); } } imlib_context_set_image(orig_image);

@@ -418,13 +412,13 @@ for (int i = 0; i < task_buttons->len; ++i) {

Task *task2 = (Task *)g_ptr_array_index(task_buttons, i); task2->icon_width = task->icon_width; task2->icon_height = task->icon_height; + task2->icon_color = task->icon_color; + task2->icon_color_hover = task->icon_color_hover; + task2->icon_color_press = task->icon_color_press; for (int k = 0; k < TASK_STATE_COUNT; ++k) { task2->icon[k] = task->icon[k]; - task2->icon_color[k] = task->icon_color[k]; task2->icon_hover[k] = task->icon_hover[k]; - task2->icon_color_hover[k] = task->icon_color_hover[k]; task2->icon_press[k] = task->icon_press[k]; - task2->icon_color_press[k] = task->icon_color_press[k]; } schedule_redraw(&task2->area); }

@@ -532,16 +526,16 @@ Task *task = (Task *)obj;

Color *content_color = NULL; if (panel_config.mouse_effects) { if (task->area.mouse_state == MOUSE_OVER) - content_color = &task->icon_color_hover[task->current_state]; + content_color = &task->icon_color_hover; else if (task->area.mouse_state == MOUSE_DOWN) - content_color = &task->icon_color_press[task->current_state]; + content_color = &task->icon_color_press; else - content_color = &task->icon_color[task->current_state]; + content_color = &task->icon_color; } else { - content_color = &task->icon_color[task->current_state]; + content_color = &task->icon_color; } if (content_color) - memcpy(color, content_color, sizeof(*content_color)); + *color = *content_color; } int task_compute_desired_size(void *obj)
M src/taskbar/task.hsrc/taskbar/task.h

@@ -64,9 +64,9 @@ Imlib_Image icon_hover[TASK_STATE_COUNT];

Imlib_Image icon_press[TASK_STATE_COUNT]; unsigned int icon_width; unsigned int icon_height; - Color icon_color[TASK_STATE_COUNT]; - Color icon_color_hover[TASK_STATE_COUNT]; - Color icon_color_press[TASK_STATE_COUNT]; + Color icon_color; + Color icon_color_hover; + Color icon_color_press; char *title; int urgent_tick; // These may not be up-to-date