X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Ftaskbar%2Ftask.c;h=2e0cc93133a237ba231293fe17da38e3300a5980;hb=b68d4db999a5912c2fc7f29aef8ab75e2f742706;hp=da12189aaa52ffbf09ea2ea067eac1964b5f143c;hpb=0357305cec0f78ba4d4717467025ead6be25ce0c;p=chaz%2Ftint2 diff --git a/src/taskbar/task.c b/src/taskbar/task.c index da12189..2e0cc93 100644 --- a/src/taskbar/task.c +++ b/src/taskbar/task.c @@ -34,10 +34,10 @@ -void add_task (Window win) +Task *add_task (Window win) { - if (!win) return; - if (window_is_hidden(win)) return; + if (!win) return 0; + if (window_is_hidden(win)) return 0; int monitor; @@ -45,7 +45,7 @@ void add_task (Window win) new_tsk.win = win; new_tsk.area.panel = &panel1[0]; new_tsk.desktop = window_get_desktop (win); - if (panel_mode == SINGLE_MONITOR) monitor = window_get_monitor (win); + if (nb_panel > 1) monitor = window_get_monitor (win); else monitor = 0; // allocate only one title and one icon @@ -59,12 +59,12 @@ void add_task (Window win) XSelectInput (server.dsp, new_tsk.win, PropertyChangeMask|StructureNotifyMask); Taskbar *tskbar; - Task *new_tsk2; + Task *new_tsk2=0; int i, j; for (i=0 ; i < nb_panel ; i++) { for (j=0 ; j < panel1[i].nb_desktop ; j++) { if (new_tsk.desktop != ALLDESKTOP && new_tsk.desktop != j) continue; - if (panel_mode == SINGLE_MONITOR && panel1[i].monitor != monitor) continue; + if (nb_panel > 1 && panel1[i].monitor != monitor) continue; tskbar = &panel1[i].taskbar[j]; new_tsk2 = malloc(sizeof(Task)); @@ -77,12 +77,11 @@ void add_task (Window win) new_tsk2->icon_width = new_tsk.icon_width; new_tsk2->icon_height = new_tsk.icon_height; tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk2); - + tskbar->area.resize = 1; //printf("add_task panel %d, desktop %d, task %s\n", i, j, new_tsk2->title); - if (resize_tasks (tskbar)) - set_redraw (&tskbar->area); } } + return new_tsk2; } @@ -91,11 +90,11 @@ void remove_task (Task *tsk) if (!tsk) return; Window win = tsk->win; + int desktop = tsk->desktop; // free title and icon just for the first task // even with task_on_all_desktop and with task_on_all_panel //printf("remove_task %s %d\n", tsk->title, tsk->desktop); - //printf("remove_task %s \n", tsk->title); if (tsk->title) free (tsk->title); if (tsk->icon_data) @@ -106,8 +105,7 @@ void remove_task (Task *tsk) Taskbar *tskbar; for (i=0 ; i < nb_panel ; i++) { for (j=0 ; j < panel1[i].nb_desktop ; j++) { - //if (tsk->desktop != ALLDESKTOP && tsk->desktop != j) continue; - if (!panel1[i].taskbar) continue; + if (desktop != ALLDESKTOP && desktop != j) continue; GSList *l0; tskbar = &panel1[i].taskbar[j]; @@ -116,8 +114,7 @@ void remove_task (Task *tsk) l0 = l0->next; if (win == tsk2->win) { tskbar->area.list = g_slist_remove(tskbar->area.list, tsk2); - resize_tasks (tskbar); - set_redraw (&tskbar->area); + tskbar->area.resize = 1; if (tsk2 == task_active) task_active = 0; @@ -183,8 +180,7 @@ void get_icon (Task *tsk) int num; data = server_get_property (tsk->win, server.atom._NET_WM_ICON, XA_CARDINAL, &num); if (data) { - //printf("get_icon plein\n"); - // ARGB + // get ARGB icon int w, h; long *tmp_data; tmp_data = get_best_icon (data, get_icon_count (data, num), num, &w, &h, panel->g_task.icon_size1); @@ -197,13 +193,35 @@ void get_icon (Task *tsk) XFree (data); } else { - //printf("get_icon vide\n"); + // get Pixmap icon XWMHints *hints = XGetWMHints(server.dsp, tsk->win); if (hints) { - if (hints->flags & IconPixmapHint) { + if (hints->flags & IconPixmapHint && hints->icon_pixmap != 0) { + // get width, height and depth for the pixmap + Window root; + int icon_x, icon_y; + uint border_width, bpp; + uint icon_width, icon_height; + + XGetGeometry(server.dsp, hints->icon_pixmap, &root, &icon_x, &icon_y, &icon_width, &icon_height, &border_width, &bpp); + + //printf(" get_pixmap\n"); + Imlib_Image img; + imlib_context_set_drawable(hints->icon_pixmap); + img = imlib_create_image_from_drawable(hints->icon_mask, 0, 0, icon_width, icon_height, 0); + imlib_context_set_image(img); + unsigned int *data = imlib_image_get_data(); + if (!data) { + return; + } + tsk->icon_width = imlib_image_get_width(); + tsk->icon_height = imlib_image_get_height(); + tsk->icon_data = malloc (tsk->icon_width * tsk->icon_height * sizeof (long)); + memcpy (tsk->icon_data, data, tsk->icon_width * tsk->icon_height * sizeof (long)); + imlib_free_image(); } XFree(hints); - } + } } } @@ -266,12 +284,12 @@ void draw_task_icon (Task *tsk, int text_width, int active) } -void draw_foreground_task (void *obj, cairo_t *c, int active) +void draw_task (void *obj, cairo_t *c, int active) { Task *tsk = obj; PangoLayout *layout; config_color *config_text; - int width, height; + int width=0, height; Panel *panel = (Panel*)tsk->area.panel; if (panel->g_task.text) { @@ -281,6 +299,7 @@ void draw_foreground_task (void *obj, cairo_t *c, int active) 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_ellipsize (layout, PANGO_ELLIPSIZE_END);