From 8ae318e599f644ca96b09ed2e249ec7881742467 Mon Sep 17 00:00:00 2001 From: Thierry Lorthiois Date: Sat, 19 Sep 2009 05:30:43 +0000 Subject: [PATCH] add default icon on task (/usr/share/tint2/default_icon.png needed) --- default_icon.png | Bin 0 -> 1528 bytes src/panel.c | 17 ++++++++++++++ src/panel.h | 2 ++ src/taskbar/task.c | 57 ++++++++++++++++++++++----------------------- 4 files changed, 47 insertions(+), 29 deletions(-) create mode 100644 default_icon.png diff --git a/default_icon.png b/default_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..70d1f07462d2f2a27b7cdd08ee550bc486ff9fdd GIT binary patch literal 1528 zcmV7MDHuAW^xICdmP8hdusGhMIh)vM|r;Q!-d4{;Z- zz5CfRfZhvY_hkFt-9Z50&G$b43L@tMKtw?Dncv|KW6WeSDL&Y~clT*-y?^`8?TvTd ze(M&Fj*D}39lgKqlEF3ofoQ_+FXZ_8+n@0B<{z&BC;^nHh#xkeU}tymT)A-CxZHes z8OD340x&ftqomWhm?WI@FvxTOh6E);mSvYZdkKN@5O@(FAQ?KH{Bi@3L%P6{bvt?v91aeUkN(1{VjWL2F=tqCnkuagI0lOGCyy!>3;iu>1I*5J0cn!E!%GQ4}`*4IZ$xsgt&L^G|oAU)SN@HM* zDPJa{#8qNIf%6#+sV8=gfRgZD)I^D*e{GCO1280LOl?e*hn$^^gz8NfjMA%;q!6od zE^urWi7*0W*%Qsu9ZHhvm8~je0+eN5kPvA|bF>y<#au(v4uFjTJ{L8SuWw6Z%2*yH zp)^&#aE`jrmIH=_F@)}4%jJs2)cE1@QKv@*TJ&ldO&5G7TrQPBv;}pi|qj z&bc{72^PbAAm@yLqkA(O*zgkxKXZ|g|H>(%uu$mJn=04mQX!g$;iVdp-f`24^xtr$cs>$WV)P4jgX{gVfinOd$S9fp~ts67c?VCD9M`W zE>x*x2&EZ4YIC;Kfk1^6EhZ%{a*XRlYoW3YU*(o&%i&TWp;9w@A<~3>yM%9NP$iYP zgwmm^OMPuhJc(XN%MU{ntg)2{Fzj}yyhV}4)IdTZ*G;V7xCxOgvF}Puwze>x94!Lq=Ky-eXumi*e2Pcg_tVQdLlj5H*xUML zuHELdepa21MtHLGpt-3ReBc-lhnODi8vqMA01STnZtw4xHa_0pne^_I@3A?&SGRZn8(&-*c)*TOi|NfD~b{)VK080S+_UyG*pNsgi1Y`h;a(^1f01g3+ za{EKceFNFaarea.panel; if (!panel->g_task.icon) return; + unsigned int w, h, num; + long *data; if (tsk->icon_data) { free (tsk->icon_data); @@ -180,12 +182,9 @@ void get_icon (Task *tsk) } tsk->area.redraw = 1; - long *data; - int num; data = server_get_property (tsk->win, server.atom._NET_WM_ICON, XA_CARDINAL, &num); if (data) { // 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); @@ -196,8 +195,7 @@ void get_icon (Task *tsk) if (tsk->icon_data) { #ifdef __x86_64__ - int length = tsk->icon_width * tsk->icon_height; - int i; + int i, length = w * h; for (i = 0; i < length; ++i) tsk->icon_data[i] = tmp_data[i]; #else @@ -209,32 +207,33 @@ void get_icon (Task *tsk) else { // get Pixmap icon XWMHints *hints = XGetWMHints(server.dsp, tsk->win); - if (!hints) return; - 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; + Imlib_Image img; + 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; + + // 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); + imlib_context_set_image(img); } - 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 (DATA32)); - if (tsk->icon_data) - memcpy (tsk->icon_data, data, tsk->icon_width * tsk->icon_height * sizeof (DATA32)); - imlib_free_image(); + else + imlib_context_set_image(default_icon); } + else + imlib_context_set_image(default_icon); + data = imlib_image_get_data(); + 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 (DATA32)); + if (tsk->icon_data) + memcpy (tsk->icon_data, data, tsk->icon_width * tsk->icon_height * sizeof (DATA32)); + if (imlib_context_get_image() == img) + imlib_free_image(); XFree(hints); } -- 2.44.0