add default icon on task (/usr/share/tint2/default_icon.png needed)

git-svn-id: http://tint2.googlecode.com/svn/trunk@184 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
lorthiois@bbsoft.fr
2009-09-19 05:30:43 +00:00
parent 1bb885f840
commit 5528aa49e9
4 changed files with 46 additions and 28 deletions

View File

@@ -172,6 +172,8 @@ void get_icon (Task *tsk)
{
Panel *panel = tsk->area.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;
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;
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;
// 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);
}