From ad675495e62840c34c1bef3aac93b37a044d3764 Mon Sep 17 00:00:00 2001 From: o9000 Date: Tue, 29 Mar 2016 14:59:02 +0200 Subject: [PATCH] Position task icon correctly (issue #575) --- src/taskbar/task.c | 8 ++++---- src/taskbar/taskbar.c | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/taskbar/task.c b/src/taskbar/task.c index 9858cf1..e5f70fa 100644 --- a/src/taskbar/task.c +++ b/src/taskbar/task.c @@ -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"); } } diff --git a/src/taskbar/taskbar.c b/src/taskbar/taskbar.c index 7c7d9b9..7df80de 100644 --- a/src/taskbar/taskbar.c +++ b/src/taskbar/taskbar.c @@ -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;