X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Ftaskbar%2Ftask.c;h=2df02fc95113f2cd99bbb870c3f7b803871962b4;hb=9f562a2eb66278cad6796f8e8b417d7c8994f171;hp=06c85aba4129714573ee8f3d323af763a3a70afd;hpb=ee8eefd5400319f8ceafbe00c6ef9ae112306bb4;p=chaz%2Ftint2 diff --git a/src/taskbar/task.c b/src/taskbar/task.c index 06c85ab..2df02fc 100644 --- a/src/taskbar/task.c +++ b/src/taskbar/task.c @@ -30,6 +30,7 @@ #include "task.h" #include "server.h" #include "panel.h" +#include "tooltip.h" @@ -139,7 +140,7 @@ void get_title(Task *tsk) Panel *panel = tsk->area.panel; char *title, *name; - if (!panel->g_task.text) return; + if (!panel->g_task.text && !g_tooltip.enabled) return; name = server_get_property (tsk->win, server.atom._NET_WM_VISIBLE_NAME, server.atom.UTF8_STRING, 0); if (!name || !strlen(name)) { @@ -171,6 +172,8 @@ void get_icon (Task *tsk) { Panel *panel = tsk->area.panel; if (!panel->g_task.icon) return; + int num; + long *data; if (tsk->icon_data) { free (tsk->icon_data); @@ -179,8 +182,6 @@ 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 @@ -195,8 +196,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 @@ -204,39 +204,68 @@ void get_icon (Task *tsk) #endif } XFree (data); - } - 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; + } + else { + // get Pixmap icon + XWMHints *hints = XGetWMHints(server.dsp, tsk->win); + Imlib_Image img = NULL; + 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); + 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); - } + } + + // resize, opacity and HSB +/* + Imlib_Image icon; + Imlib_Color_Modifier cmod; + DATA8 red[256], green[256], blue[256], alpha[256]; + + icon = imlib_create_image_using_data (tsk->icon_width, tsk->icon_height, icon_data); + imlib_context_set_image (icon); + imlib_context_set_drawable (*pmap); + cmod = imlib_create_color_modifier (); + imlib_context_set_color_modifier (cmod); + imlib_image_set_has_alpha (1); + imlib_get_color_modifier_tables (red, green, blue, alpha); + + int i, opacity; + opacity = (active == 0) ? (255*panel->g_task.font.alpha) : (255*panel->g_task.font_active.alpha); + for (i = 127; i < 256; i++) alpha[i] = opacity; + + imlib_set_color_modifier_tables (red, green, blue, alpha); + + //imlib_render_image_on_drawable (pos_x, pos_y); + imlib_render_image_on_drawable_at_size (pos_x, panel->g_task.icon_posy, panel->g_task.icon_size1, panel->g_task.icon_size1); + + imlib_free_color_modifier (); + imlib_free_image (); + */ if (tsk->icon_data) { tsk->icon_data_active = malloc (tsk->icon_width * tsk->icon_height * sizeof (DATA32)); memcpy (tsk->icon_data_active, tsk->icon_data, tsk->icon_width * tsk->icon_height * sizeof (DATA32));