all repos — tint2 @ 68d3799c476d20248f29b7d8777558856dd449a7

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Mouse effects: tint icons
o9000 mrovi9000@gmail.com
commit

68d3799c476d20248f29b7d8777558856dd449a7

parent

1b554ebc1edbc26cf81d77f1c65332e5e3030919

M src/launcher/launcher.csrc/launcher/launcher.c

@@ -153,6 +153,8 @@ for (l = launcher->list_icons; l ; l = l->next) {

LauncherIcon *launcherIcon = (LauncherIcon*)l->data; if (launcherIcon) { free_icon(launcherIcon->image); + free_icon(launcherIcon->image_hover); + free_icon(launcherIcon->image_pressed); free(launcherIcon->icon_name); free(launcherIcon->icon_path); free(launcherIcon->cmd);

@@ -197,12 +199,16 @@ char *new_icon_path = get_icon_path(launcher->list_themes, launcherIcon->icon_name, launcherIcon->icon_size);

if (!new_icon_path) { // Draw a blank icon free_icon(launcherIcon->image); + free_icon(launcherIcon->image_hover); + free_icon(launcherIcon->image_pressed); launcherIcon->image = NULL; continue; } // Free the old files free_icon(launcherIcon->image); + free_icon(launcherIcon->image_hover); + free_icon(launcherIcon->image_pressed); // Load the new file launcherIcon->image = load_image(new_icon_path, 1); // On loading error, fallback to default

@@ -225,6 +231,11 @@ free(launcherIcon->icon_path);

launcherIcon->icon_path = new_icon_path; fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, launcherIcon->icon_path); } + } + + if (panel_config.mouse_effects) { + launcherIcon->image_hover = adjust_icon(launcherIcon->image, 100, 0, 10); + launcherIcon->image_pressed = adjust_icon(launcherIcon->image, 100, 0, -10); } }

@@ -322,8 +333,19 @@ void draw_launcher_icon(void *obj, cairo_t *c)

{ LauncherIcon *launcherIcon = (LauncherIcon*)obj; + Imlib_Image image; // Render - imlib_context_set_image(launcherIcon->image); + if (panel_config.mouse_effects) { + if (launcherIcon->area.mouse_state == MOUSE_OVER) + image = launcherIcon->image_hover ? launcherIcon->image_hover : launcherIcon->image; + else if (launcherIcon->area.mouse_state == MOUSE_DOWN) + image = launcherIcon->image_pressed ? launcherIcon->image_pressed : launcherIcon->image; + else + image = launcherIcon->image; + } else { + image = launcherIcon->image; + } + imlib_context_set_image(image); render_image(launcherIcon->area.pix, 0, 0); }
M src/launcher/launcher.hsrc/launcher/launcher.h

@@ -24,6 +24,8 @@ typedef struct LauncherIcon {

// always start with area Area area; Imlib_Image image; + Imlib_Image image_hover; + Imlib_Image image_pressed; char *cmd; char *icon_name; char *icon_path;
M src/taskbar/task.csrc/taskbar/task.c

@@ -111,6 +111,8 @@ if (panel1[monitor].g_task.tooltip_enabled)

new_tsk2->area._get_tooltip_text = task_get_tooltip; for (k=0; k<TASK_STATE_COUNT; ++k) { new_tsk2->icon[k] = new_tsk.icon[k]; + new_tsk2->icon_hover[k] = new_tsk.icon_hover[k]; + new_tsk2->icon_press[k] = new_tsk.icon_press[k]; new_tsk2->state_pix[k] = 0; } new_tsk2->icon_width = new_tsk.icon_width;

@@ -162,8 +164,18 @@ if (tsk->icon[k]) {

imlib_context_set_image(tsk->icon[k]); imlib_free_image(); tsk->icon[k] = 0; - if (tsk->state_pix[k]) XFreePixmap(server.dsp, tsk->state_pix[k]); + } + if (tsk->icon_hover[k]) { + imlib_context_set_image(tsk->icon_hover[k]); + imlib_free_image(); + tsk->icon_hover[k] = 0; } + if (tsk->icon_press[k]) { + imlib_context_set_image(tsk->icon_press[k]); + imlib_free_image(); + tsk->icon_press[k] = 0; + } + if (tsk->state_pix[k]) XFreePixmap(server.dsp, tsk->state_pix[k]); } int i;

@@ -310,6 +322,10 @@ 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); } + if (panel_config.mouse_effects) { + tsk->icon_hover[k] = adjust_icon(tsk->icon[k], 100, 0, 10); + tsk->icon_press[k] = adjust_icon(tsk->icon[k], 100, 0, -10); + } } imlib_context_set_image(orig_image); imlib_free_image();

@@ -326,8 +342,11 @@ 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) + for (k=0; k<TASK_STATE_COUNT; ++k) { tsk2->icon[k] = tsk->icon[k]; + tsk2->icon_hover[k] = tsk->icon_hover[k]; + tsk2->icon_press[k] = tsk->icon_press[k]; + } set_task_redraw(tsk2); } }

@@ -350,7 +369,21 @@ }

else pos_x = panel->g_task.area.paddingxlr + tsk->area.bg->border.width; // Render - imlib_context_set_image (tsk->icon[tsk->current_state]); + + Imlib_Image image; + // Render + if (panel_config.mouse_effects) { + if (tsk->area.mouse_state == MOUSE_OVER) + image = tsk->icon_hover[tsk->current_state]; + else if (tsk->area.mouse_state == MOUSE_DOWN) + image = tsk->icon_press[tsk->current_state]; + else + image = tsk->icon[tsk->current_state]; + } else { + image = tsk->icon[tsk->current_state]; + } + + imlib_context_set_image(image); render_image(tsk->area.pix, pos_x, panel->g_task.icon_posy); }
M src/taskbar/task.hsrc/taskbar/task.h

@@ -57,6 +57,8 @@ Window win;

int desktop; int current_state; Imlib_Image icon[TASK_STATE_COUNT]; + Imlib_Image icon_hover[TASK_STATE_COUNT]; + Imlib_Image icon_press[TASK_STATE_COUNT]; Pixmap state_pix[TASK_STATE_COUNT]; unsigned int icon_width; unsigned int icon_height;
M src/util/common.csrc/util/common.c

@@ -508,3 +508,19 @@ }

} return image; } + +Imlib_Image adjust_icon(Imlib_Image original, int alpha, int saturation, int brightness) +{ + if (!original) + return NULL; + + imlib_context_set_image(original); + Imlib_Image copy = imlib_clone_image(); + + imlib_context_set_image(copy); + imlib_image_set_has_alpha(1); + DATA32* data = imlib_image_get_data(); + adjust_asb(data, imlib_image_get_width(), imlib_image_get_height(), alpha, (float)saturation/100, (float)brightness/100); + imlib_image_put_back_data(data); + return copy; +}
M src/util/common.hsrc/util/common.h

@@ -75,5 +75,8 @@

void draw_text(PangoLayout *layout, cairo_t *c, int posx, int posy, Color *color, int font_shadow); Imlib_Image load_image(const char *path, int cached); + +Imlib_Image adjust_icon(Imlib_Image original, int alpha, int saturation, int brightness); + #endif