src/appicon.c | 2 +- src/application.c | 3 +++ src/application.h | 24 +++++++++++++++--------- src/icon.c | 16 ++++++++++++---- wrlib/misc.c | 52 ++++++++++++++++++++++++++++++++++++++++++++-------- wrlib/wraster.h | 2 ++ 6 files changed, 77 insertions(+), 22 deletions(-) diff --git a/src/appicon.c b/src/appicon.c index 22f2693..21e1403 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -222,7 +222,7 @@ wAppIconDestroy(WAppIcon *aicon) -#ifdef NEWAPPICON +#if 0 static void drawCorner(WIcon *icon, WWindow *wwin, int active) { diff --git a/src/application.c b/src/application.c index ad5d388..5676f25 100644 --- a/src/application.c +++ b/src/application.c @@ -465,6 +465,9 @@ wApplicationDestroy(WApplication *wapp) XDeleteContext(dpy, wapp->main_window, wAppWinContext); wAppMenuDestroy(wapp->menu); +#ifdef NEWAPPICON + wApplicationDeactivate(wapp); +#endif if (wapp->app_icon) { if (wapp->app_icon->docked && !wapp->app_icon->attracted) { wapp->app_icon->running = 0; diff --git a/src/application.h b/src/application.h index 57a1b5c..c0165ce 100644 --- a/src/application.h +++ b/src/application.h @@ -60,15 +60,21 @@ void wApplicationExtractDirPackIcon(WScreen *scr,char *path, char *wm_instance, #ifdef NEWAPPICON -# define wApplicationActivate(wapp) {\ - wapp->main_window_desc->flags.focused=1; \ - wAppIconPaint(wapp->app_icon);\ - } -#define wApplicationDeactivate(wapp) {\ - wapp->main_window_desc->flags.focused=0;\ - wAppIconPaint(wapp->app_icon);\ - } -#endif +#define wApplicationActivate(wapp) do { \ + if (wapp->app_icon) { \ + wIconSetHighlited(wapp->app_icon->icon, True); \ + wAppIconPaint(wapp->app_icon);\ + } \ + } while (0) + +#define wApplicationDeactivate(wapp) do { \ + if (wapp->app_icon) { \ + wIconSetHighlited(wapp->app_icon->icon, False); \ + wAppIconPaint(wapp->app_icon);\ + } \ + } while (0) + #endif +#endif diff --git a/src/icon.c b/src/icon.c index e87d2f1..c235193 100644 --- a/src/icon.c +++ b/src/icon.c @@ -312,7 +312,7 @@ drawIconTitle(WScreen *scr, Pixmap pixmap, int height) static Pixmap -makeIcon(WScreen *scr, RImage *icon, int titled, int shadowed, int tileType) +makeIcon(WScreen *scr, RImage *icon, int titled, int shadowed, int tileType, int highlighted) { RImage *tile; Pixmap pixmap; @@ -355,6 +355,13 @@ makeIcon(WScreen *scr, RImage *icon, int titled, int shadowed, int tileType) color.alpha = 150; /* about 60% */ RClearImage(tile, &color); } + if (highlighted) { + RColor color; + + color.red = color.green = color.blue = 0; + color.alpha = 160; + RLightImage(tile, &color); + } if (!RConvertImage(scr->rcontext, tile, &pixmap)) { wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); @@ -597,6 +604,7 @@ wIconSetHighlited(WIcon *icon, Bool flag) } icon->highlighted = flag; + icon->force_paint = True; wIconPaint(icon); } @@ -766,7 +774,7 @@ wIconUpdate(WIcon *icon) if (icon->image) { icon->pixmap = makeIcon(scr, icon->image, icon->show_title, - icon->shadowed, icon->tile_type); + icon->shadowed, icon->tile_type, icon->highlighted); } else { /* make default icons */ @@ -794,9 +802,9 @@ wIconUpdate(WIcon *icon) image = wIconValidateIconSize(scr, image); scr->def_icon_pixmap = makeIcon(scr, image, False, False, - icon->tile_type); + icon->tile_type, icon->highlighted); scr->def_ticon_pixmap = makeIcon(scr, image, True, False, - icon->tile_type); + icon->tile_type, icon->highlighted); if (image) RReleaseImage(image); } diff --git a/wrlib/misc.c b/wrlib/misc.c index 3da6adf..dded195 100644 --- a/wrlib/misc.c +++ b/wrlib/misc.c @@ -152,7 +152,7 @@ RClearImage(RImage *image, RColor *color) } } else { int bytes = image->width*image->height; - int alpha, nalpha, r, g, b; + int alpha, nalpha, r, g, b, s; alpha = color->alpha; r = color->red * alpha; @@ -160,17 +160,53 @@ RClearImage(RImage *image, RColor *color) b = color->blue * alpha; nalpha = 255 - alpha; - for (i=0; iformat == RRGBAFormat) { - d++; - } + s = (image->format == RRGBAFormat) ? 4 : 3; + + for (i=0; i 255) c=255; + return (unsigned char)c; +} + +void +RLightImage(RImage *image, RColor *color) +{ + unsigned char *d = image->data; + unsigned char *dd; + int alpha, r, g, b, s; + + s = (image->format == RRGBAFormat) ? 4 : 3; + dd = d + s*image->width*image->height; + + r = color->red; + g = color->green; + b = color->blue; + + alpha = color->alpha; + + if (r == 0 && g == 0 && b == 0) { + for (; d