X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Ftint2;a=blobdiff_plain;f=src%2Ftaskbar%2Ftask.c;h=83e827f5247ef181e1df0e51e5c95186f0c8b823;hp=26f8bea759020be1383522c55ac81fa17811b24b;hb=63bbffa4af17926ba2d52728883988eae402b07a;hpb=ea034ed97924271fbda23bd217984931605374e3 diff --git a/src/taskbar/task.c b/src/taskbar/task.c index 26f8bea..83e827f 100644 --- a/src/taskbar/task.c +++ b/src/taskbar/task.c @@ -35,8 +35,8 @@ #include "tooltip.h" #include "timer.h" -static timeout* urgent_timeout = 0; -static GSList* urgent_list = 0; +timeout* urgent_timeout; +GSList* urgent_list; const char* task_get_tooltip(void* obj) { @@ -67,8 +67,10 @@ Task *add_task (Window win) // even with task_on_all_desktop and with task_on_all_panel new_tsk.title = 0; int k; - for (k=0; kg_task.icon_size1); - #ifdef __x86_64__ DATA32 icon_data[w * h]; int length = w * h; @@ -323,7 +324,7 @@ void draw_task_icon (Task *tsk, int text_width) // Render imlib_context_set_image (tsk->icon[tsk->current_state]); - if (real_transparency) { + if (server.real_transparency) { render_image(tsk->area.pix, pos_x, panel->g_task.icon_posy, imlib_image_get_width(), imlib_image_get_height() ); } else { @@ -341,16 +342,19 @@ void draw_task (void *obj, cairo_t *c) Color *config_text; int width=0, height; Panel *panel = (Panel*)tsk->area.panel; + //printf("draw_task %d %d\n", tsk->area.posx, tsk->area.posy); if (panel->g_task.text) { /* Layout */ layout = pango_cairo_create_layout (c); pango_layout_set_font_description (layout, panel->g_task.font_desc); - pango_layout_set_text (layout, tsk->title, -1); + pango_layout_set_text(layout, tsk->title, -1); /* Drawing width and Cut text */ // pango use U+22EF or U+2026 - pango_layout_set_width (layout, ((Taskbar*)tsk->area.parent)->text_width * PANGO_SCALE); + pango_layout_set_width(layout, ((Taskbar*)tsk->area.parent)->text_width * PANGO_SCALE); + pango_layout_set_height(layout, panel->g_task.text_height * PANGO_SCALE); + pango_layout_set_wrap(layout, PANGO_WRAP_CHAR); pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END); /* Center text */ @@ -360,24 +364,23 @@ void draw_task (void *obj, cairo_t *c) pango_layout_get_pixel_size (layout, &width, &height); config_text = &panel->g_task.font[tsk->current_state]; - cairo_set_source_rgba (c, config_text->color[0], config_text->color[1], config_text->color[2], config_text->alpha); pango_cairo_update_layout (c, layout); - cairo_move_to (c, panel->g_task.text_posx, panel->g_task.text_posy); + double text_posy = (panel->g_task.area.height - height) / 2.0; + cairo_move_to (c, panel->g_task.text_posx, text_posy); pango_cairo_show_layout (c, layout); if (panel->g_task.font_shadow) { cairo_set_source_rgba (c, 0.0, 0.0, 0.0, 0.5); pango_cairo_update_layout (c, layout); - cairo_move_to (c, panel->g_task.text_posx + 1, panel->g_task.text_posy + 1); + cairo_move_to (c, panel->g_task.text_posx + 1, text_posy + 1); pango_cairo_show_layout (c, layout); } g_object_unref (layout); } if (panel->g_task.icon) { - // icon use same opacity as text draw_task_icon (tsk, width); } } @@ -441,9 +444,11 @@ void active_task() //printf("Change active task %ld\n", w1); if (w1) { - Window w2; - if (XGetTransientForHint(server.dsp, w1, &w2) != 0) - if (w2) w1 = w2; + if (!task_get_tasks(w1)) { + Window w2; + while (XGetTransientForHint(server.dsp, w1, &w2)) + w1 = w2; + } set_task_state((task_active = task_get_task(w1)), TASK_ACTIVE); } } @@ -456,18 +461,20 @@ void set_task_state(Task *tsk, int state) if (tsk->current_state != state) { GPtrArray* task_group = task_get_tasks(tsk->win); - int i; - for (i=0; ilen; ++i) { - Task* tsk1 = g_ptr_array_index(task_group, i); - tsk1->current_state = state; - tsk1->area.bg = panel1[0].g_task.background[state]; - tsk1->area.pix = tsk1->state_pix[state]; - if (tsk1->state_pix[state] == 0) - tsk1->area.redraw = 1; - if (state == TASK_ACTIVE && g_slist_find(urgent_list, tsk1)) - del_urgent(tsk1); + if (task_group) { + int i; + for (i=0; ilen; ++i) { + Task* tsk1 = g_ptr_array_index(task_group, i); + tsk1->current_state = state; + tsk1->area.bg = panel1[0].g_task.background[state]; + tsk1->area.pix = tsk1->state_pix[state]; + if (tsk1->state_pix[state] == 0) + tsk1->area.redraw = 1; + if (state == TASK_ACTIVE && g_slist_find(urgent_list, tsk1)) + del_urgent(tsk1); + } + panel_refresh = 1; } - panel_refresh = 1; } }