Position task icon correctly (issue #575)

This commit is contained in:
o9000 2016-03-29 14:59:02 +02:00
parent 48e7e38b11
commit ad675495e6
2 changed files with 17 additions and 6 deletions

View file

@ -369,7 +369,7 @@ void draw_task_icon(Task *task, int text_width)
else
pos_x = (task->area.width - panel->g_task.icon_size1) / 2;
} else {
pos_x = panel->g_task.area.paddingxlr + task->area.bg->border.width;
pos_x = task->area.bg->border.width + task->area.paddingxlr;
}
// Render
@ -388,12 +388,12 @@ 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);
render_image(task->area.pix, pos_x, (task->area.height - panel->g_task.icon_size1) / 2);
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 icon size: %d %d pos %d %d\n", imlib_image_get_width(), imlib_image_get_height(), pos_x, panel->g_task.icon_posy);
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, "Task border : %d\n", task->area.bg->border.width);
fprintf(stderr, "\n");
}
}

View file

@ -232,6 +232,7 @@ void init_taskbar_panel(void *p)
panel->g_task.area.posy = panel->g_taskbar.area.posy +
panel->g_taskbar.background[TASKBAR_NORMAL]->border.width +
panel->g_taskbar.area.paddingy;
panel->g_task.area.width = panel->g_task.maximum_width;
panel->g_task.area.height = panel->area.height - (2 * panel->g_task.area.posy);
} else {
panel->g_task.area.posx = panel->g_taskbar.area.posx +
@ -271,12 +272,22 @@ void init_taskbar_panel(void *p)
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 =
MIN(panel->g_task.maximum_width, MIN(panel->g_task.maximum_height, panel->g_task.area.height)) -
MIN(MIN(panel->g_task.maximum_width, panel->g_task.maximum_height),
MIN(panel->g_task.area.width, 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;
if (0)
printf("task: icon_size = %d, textx = %f, texth = %f, icony = %d, w = %d, h = %d, maxw = %d, maxh = %d\n",
panel->g_task.icon_size1,
panel->g_task.text_posx,
panel->g_task.text_height,
panel->g_task.icon_posy,
panel->g_task.area.width,
panel->g_task.area.height,
panel->g_task.maximum_width,
panel->g_task.maximum_height);
}
// printf("monitor %d, task_maximum_width %d\n", panel->monitor, panel->g_task.maximum_width);
Taskbar *taskbar;
panel->num_desktops = server.num_desktops;