diff --git a/src/actions.c b/src/actions.c index aba2d14d..2c61cd56 100644 --- a/src/actions.c +++ b/src/actions.c @@ -132,8 +132,10 @@ void wSetFocusTo(WScreen *scr, WWindow *wwin) XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, CurrentTime); if (old_focused) wWindowUnfocus(old_focused); - if (oapp) + if (oapp) { wAppMenuUnmap(oapp->menu); + wApplicationDeactivate(oapp); + } WMPostNotificationName(WMNChangedFocus, NULL, (void *)True); return; @@ -194,8 +196,10 @@ void wSetFocusTo(WScreen *scr, WWindow *wwin) wwin->next = NULL; scr->focused_window = wwin; - if (oapp && oapp != napp) + if (oapp && oapp != napp) { wAppMenuUnmap(oapp->menu); + wApplicationDeactivate(oapp); + } } wWindowFocus(wwin, focused); @@ -207,6 +211,7 @@ void wSetFocusTo(WScreen *scr, WWindow *wwin) if (wwin->flags.mapped) wAppMenuMap(napp->menu, wwin); + wApplicationActivate(napp); } XFlush(dpy); diff --git a/src/application.c b/src/application.c index 19fcb520..21155c79 100644 --- a/src/application.c +++ b/src/application.c @@ -434,6 +434,8 @@ void wApplicationDestroy(WApplication * wapp) XDeleteContext(dpy, wapp->main_window, wAppWinContext); wAppMenuDestroy(wapp->menu); + wApplicationDeactivate(wapp); + 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 b7c1e095..111491d3 100644 --- a/src/application.h +++ b/src/application.h @@ -62,5 +62,23 @@ void wApplicationExtractDirPackIcon(WScreen *scr,char *path, char *wm_instance, char *wm_class); void wAppBounce(WApplication *); -#endif +#ifdef NEWAPPICON +#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) +#else +#define wApplicationActivate(wapp) do { } while (0) +#define wApplicationDeactivate(wapp) do { } while (0) +#endif /* NEWAPPICON */ + +#endif diff --git a/src/icon.c b/src/icon.c index c7815421..fb989064 100644 --- a/src/icon.c +++ b/src/icon.c @@ -279,7 +279,7 @@ static void drawIconTitle(WScreen * scr, Pixmap pixmap, int height) wPreferences.icon_size - 1, 0, wPreferences.icon_size - 1, height + 1); } -static Pixmap makeIcon(WScreen * scr, RImage * icon, int titled, int shadowed, int tileType) +static Pixmap makeIcon(WScreen *scr, RImage *icon, int titled, int shadowed, int tileType, int highlighted) { RImage *tile; Pixmap pixmap; @@ -322,6 +322,13 @@ static Pixmap makeIcon(WScreen * scr, RImage * icon, int titled, int shadowed, i 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)); @@ -520,6 +527,18 @@ static void cycleColor(void *data) icon->handlerID = WMAddTimerHandler(COLOR_CYCLE_DELAY, cycleColor, icon); } +#ifdef NEWAPPICON +void wIconSetHighlited(WIcon *icon, Bool flag) +{ + if (icon->highlighted == flag) + return; + + icon->highlighted = flag; + icon->force_paint = True; + wIconPaint(icon); +} +#endif + void wIconSelect(WIcon * icon) { WScreen *scr = icon->core->screen_ptr; @@ -669,7 +688,7 @@ void 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 */ @@ -696,8 +715,8 @@ void wIconUpdate(WIcon * icon) make_icons: image = wIconValidateIconSize(scr, image); - scr->def_icon_pixmap = makeIcon(scr, image, False, False, icon->tile_type); - scr->def_ticon_pixmap = makeIcon(scr, image, True, False, icon->tile_type); + scr->def_icon_pixmap = makeIcon(scr, image, False, False, icon->tile_type, icon->highlighted); + scr->def_ticon_pixmap = makeIcon(scr, image, True, False, icon->tile_type, icon->highlighted); if (image) RReleaseImage(image); } diff --git a/wrlib/libwraster.map b/wrlib/libwraster.map index 895a7b1d..9d05f2df 100644 --- a/wrlib/libwraster.map +++ b/wrlib/libwraster.map @@ -50,6 +50,7 @@ LIBWRASTER3 RGetSubImage; RGetXImage; RHSVtoRGB; + RLightImage; RLoadImage; RMakeCenteredImage; RMakeTiledImage; diff --git a/wrlib/misc.c b/wrlib/misc.c index 7904215b..7117d817 100644 --- a/wrlib/misc.c +++ b/wrlib/misc.c @@ -140,7 +140,7 @@ void 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; @@ -148,16 +148,49 @@ void RClearImage(RImage * image, RColor * color) b = color->blue * alpha; nalpha = 255 - alpha; - for (i = 0; i < bytes; i++) { - *d = (((int)*d * nalpha) + r) / 256; - d++; - *d = (((int)*d * nalpha) + g) / 256; - d++; - *d = (((int)*d * nalpha) + b) / 256; - d++; - if (image->format == RRGBAFormat) { - d++; - } + s = (image->format == RRGBAFormat) ? 4 : 3; + + for (i = 0; i < bytes; i++, d += s) { + d[0] = (((int)d[0] * nalpha) + r)/256; + d[1] = (((int)d[1] * nalpha) + g)/256; + d[2] = (((int)d[2] * nalpha) + b)/256; + } + } +} + +static __inline__ unsigned char clip(int c) +{ + if (c > 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 < dd; d += s) { + d[0] = clip(((int)d[0] * alpha)/128); + d[1] = clip(((int)d[1] * alpha)/128); + d[2] = clip(((int)d[2] * alpha)/128); + } + } else { + for (; d < dd; d += s) { + d[0] = clip((((int)d[0] * alpha) + r)/128); + d[1] = clip((((int)d[1] * alpha) + g)/128); + d[2] = clip((((int)d[2] * alpha) + b)/128); } } } diff --git a/wrlib/wraster.h b/wrlib/wraster.h index 73611d44..78bfc168 100644 --- a/wrlib/wraster.h +++ b/wrlib/wraster.h @@ -411,6 +411,8 @@ void RHSVtoRGB(RHSVColor *hsv, RColor *rgb); */ void RClearImage(RImage *image, RColor *color); +void RLightImage(RImage *image, RColor *color); + void RFillImage(RImage *image, RColor *color); void RBevelImage(RImage *image, int bevel_type);