#include <stdlib.h>
#include <string.h>
#include <glib.h>
-#include <Imlib2.h>
#include "window.h"
#include "task.h"
#include "server.h"
#include "panel.h"
+#include "tooltip.h"
// even with task_on_all_desktop and with task_on_all_panel
new_tsk.title = 0;
new_tsk.icon_data = 0;
+ new_tsk.icon_data_active = 0;
get_title(&new_tsk);
get_icon(&new_tsk);
new_tsk2->desktop = new_tsk.desktop;
new_tsk2->title = new_tsk.title;
new_tsk2->icon_data = new_tsk.icon_data;
+ new_tsk2->icon_data_active = new_tsk.icon_data_active;
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);
//printf("remove_task %s %d\n", tsk->title, tsk->desktop);
if (tsk->title)
free (tsk->title);
- if (tsk->icon_data)
+ if (tsk->icon_data) {
free (tsk->icon_data);
+ free (tsk->icon_data_active);
+ }
int i, j;
Task *tsk2;
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)) {
{
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);
- tsk->icon_data = 0;
+ free (tsk->icon_data_active);
+ tsk->icon_data = tsk->icon_data_active = 0;
}
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);
// DATA32 is provided by imlib2
tsk->icon_data = malloc (w * h * sizeof (DATA32));
+ if (tsk->icon_data) {
#ifdef __x86_64__
- int length = tsk->icon_width * tsk->icon_height;
- int i;
- for (i = 0; i < length; ++i)
- tsk->icon_data[i] = tmp_data[i];
+ int i, length = w * h;
+ for (i = 0; i < length; ++i)
+ tsk->icon_data[i] = tmp_data[i];
#else
- memcpy (tsk->icon_data, tmp_data, w * h * sizeof (DATA32));
+ memcpy (tsk->icon_data, tmp_data, w * h * sizeof (DATA32));
#endif
-
+ }
XFree (data);
- }
- else {
- // get Pixmap icon
- XWMHints *hints = XGetWMHints(server.dsp, tsk->win);
- if (hints) {
- if (hints->flags & IconPixmapHint && hints->icon_pixmap != 0) {
- // get width, height and depth for the pixmap
+ }
+ else {
+ // get Pixmap icon
+ XWMHints *hints = XGetWMHints(server.dsp, tsk->win);
+ 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;
- 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;
+ // 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, icon_width, icon_height, 0);
+ img = imlib_create_image_from_drawable(hints->icon_mask, 0, 0, w, h, 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 (DATA32));
- memcpy (tsk->icon_data, data, tsk->icon_width * tsk->icon_height * sizeof (DATA32));
- imlib_free_image();
}
- XFree(hints);
+ 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);
+ }
+
+ 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));
+
+ if (panel->g_task.hue != 0 || panel->g_task.saturation != 0 || panel->g_task.brightness != 0) {
+ adjust_hsb(tsk->icon_data, tsk->icon_width, tsk->icon_height, (float)panel->g_task.hue/100, (float)panel->g_task.saturation/100, (float)panel->g_task.brightness/100);
+ }
+ if (panel->g_task.hue_active != 0 || panel->g_task.saturation_active != 0 || panel->g_task.brightness_active != 0) {
+ adjust_hsb(tsk->icon_data_active, tsk->icon_width, tsk->icon_height, (float)panel->g_task.hue_active/100, (float)panel->g_task.saturation_active/100, (float)panel->g_task.brightness_active/100);
+ }
+ }
}
void draw_task_icon (Task *tsk, int text_width, int active)
{
- if (tsk->icon_data == 0) return;
+ if (tsk->icon_data == 0 || tsk->icon_data_active == 0) return;
Pixmap *pmap = (active == 0) ? (&tsk->area.pix.pmap) : (&tsk->area.pix_active.pmap);
+ unsigned int *icon_data = (active == 0) ? (tsk->icon_data) : (tsk->icon_data_active);
- /* Find pos */
+ // Find pos
int pos_x;
Panel *panel = (Panel*)tsk->area.panel;
if (panel->g_task.centered) {
}
else pos_x = panel->g_task.area.paddingxlr + panel->g_task.area.pix.border.width;
- /* Render */
+ // Render
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, tsk->icon_data);
+ icon = imlib_create_image_using_data (tsk->icon_width, tsk->icon_height, icon_data);
imlib_context_set_image (icon);
imlib_context_set_drawable (*pmap);
}
}
+