Compute task icon size correctly

This commit is contained in:
o9000 2016-02-26 11:06:28 +01:00
parent 995a257b2c
commit 6ce441ecf1
2 changed files with 9 additions and 1 deletions

View file

@ -383,6 +383,13 @@ void draw_task_icon(Task *task, int text_width)
imlib_context_set_image(image);
render_image(task->area.pix, pos_x, panel->g_task.icon_posy);
if (0) {
fprintf(stderr, "Task icon size: %d %d pos %d\n", imlib_image_get_width(), imlib_image_get_height(), pos_x);
fprintf(stderr, "Task max size : %d %d\n", panel->g_task.maximum_width, panel->g_task.maximum_height);
fprintf(stderr, "Task area size: %d %d\n", task->area.width, task->area.height);
fprintf(stderr, "Task area bord: %d\n", task->area.bg->border.width);
fprintf(stderr, "\n");
}
}
void draw_task(void *obj, cairo_t *c)

View file

@ -263,7 +263,8 @@ void init_taskbar_panel(void *p)
panel->g_task.text_posx = panel->g_task.background[0]->border.width + panel->g_task.area.paddingxlr;
panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
if (panel->g_task.has_icon) {
panel->g_task.icon_size1 = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
panel->g_task.icon_size1 = MIN(panel->g_task.maximum_width, MIN(panel->g_task.maximum_height, panel->g_task.area.height)) -
(2 * panel->g_task.area.paddingy) - 2 * panel->g_task.area.bg->border.width;
panel->g_task.text_posx += panel->g_task.icon_size1 + panel->g_task.area.paddingx;
panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2;
}