+ Panel *panel = tsk->area.panel;
+ if (!panel->g_task.icon) return;
+ int i;
+ Imlib_Image img = NULL;
+ XWMHints *hints = 0;
+ long *data = 0;
+
+ int k;
+ for (k=0; k<TASK_STATE_COUNT; ++k) {
+ if (tsk->icon[k]) {
+ imlib_context_set_image(tsk->icon[k]);
+ imlib_free_image();
+ tsk->icon[k] = 0;
+ }
+ }
+
+ data = server_get_property (tsk->win, server.atom._NET_WM_ICON, XA_CARDINAL, &i);
+ if (data) {
+ // get ARGB icon
+ int w, h;
+ long *tmp_data;
+
+ tmp_data = get_best_icon (data, get_icon_count (data, i), i, &w, &h, panel->g_task.icon_size1);
+
+#ifdef __x86_64__
+ DATA32 icon_data[w * h];
+ int length = w * h;
+ for (i = 0; i < length; ++i)
+ icon_data[i] = tmp_data[i];
+ img = imlib_create_image_using_copied_data (w, h, icon_data);
+#else
+ img = imlib_create_image_using_data (w, h, (DATA32*)tmp_data);
+#endif
+ }
+ else {
+ // get Pixmap icon
+ hints = XGetWMHints(server.dsp, tsk->win);
+ if (hints) {
+ 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 w, h;
+
+ //printf(" get pixmap\n");
+ XGetGeometry(server.dsp, hints->icon_pixmap, &root, &icon_x, &icon_y, &w, &h, &border_width, &bpp);
+ imlib_context_set_drawable(hints->icon_pixmap);
+ img = imlib_create_image_from_drawable(hints->icon_mask, 0, 0, w, h, 0);
+ }
+ }
+ }
+ if (img == NULL) {
+ imlib_context_set_image(default_icon);
+ img = imlib_clone_image();
+ }
+
+ // transform icons
+ imlib_context_set_image(img);
+ imlib_image_set_has_alpha(1);
+ int w, h;
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
+ Imlib_Image orig_image = imlib_create_cropped_scaled_image(0, 0, w, h, panel->g_task.icon_size1, panel->g_task.icon_size1);
+ imlib_free_image();
+
+ imlib_context_set_image(orig_image);
+ tsk->icon_width = imlib_image_get_width();
+ tsk->icon_height = imlib_image_get_height();
+ for (k=0; k<TASK_STATE_COUNT; ++k) {
+ imlib_context_set_image(orig_image);
+ tsk->icon[k] = imlib_clone_image();
+ imlib_context_set_image(tsk->icon[k]);
+ DATA32 *data32;
+ if (panel->g_task.alpha[k] != 100 || panel->g_task.saturation[k] != 0 || panel->g_task.brightness[k] != 0) {
+ data32 = imlib_image_get_data();
+ adjust_asb(data32, tsk->icon_width, tsk->icon_height, panel->g_task.alpha[k], (float)panel->g_task.saturation[k]/100, (float)panel->g_task.brightness[k]/100);
+ imlib_image_put_back_data(data32);
+ }
+ }
+ imlib_context_set_image(orig_image);
+ imlib_free_image();
+
+ if (hints)
+ XFree(hints);
+ if (data)
+ XFree (data);
+
+ GPtrArray* task_group = task_get_tasks(tsk->win);
+ if (task_group) {
+ for (i=0; i<task_group->len; ++i) {
+ Task* tsk2 = g_ptr_array_index(task_group, i);
+ tsk2->icon_width = tsk->icon_width;
+ tsk2->icon_height = tsk->icon_height;
+ int k;
+ for (k=0; k<TASK_STATE_COUNT; ++k)
+ tsk2->icon[k] = tsk->icon[k];
+ set_task_redraw(tsk2);
+ }
+ }
+ set_task_redraw(tsk);
+}
+
+
+void draw_task_icon (Task *tsk, int text_width)
+{
+ if (tsk->icon[tsk->current_state] == 0) return;
+
+ // Find pos
+ int pos_x;
+ Panel *panel = (Panel*)tsk->area.panel;
+ if (panel->g_task.centered) {
+ if (panel->g_task.text)
+ pos_x = (tsk->area.width - text_width - panel->g_task.icon_size1) / 2;
+ else
+ pos_x = (tsk->area.width - panel->g_task.icon_size1) / 2;
+ }
+ else pos_x = panel->g_task.area.paddingxlr + tsk->area.bg->border.width;
+
+ // Render
+ imlib_context_set_image (tsk->icon[tsk->current_state]);
+ 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 {
+ imlib_context_set_drawable(tsk->area.pix);
+ imlib_render_image_on_drawable (pos_x, panel->g_task.icon_posy);
+ }