1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

Highlite current window's appicon

This patch highlites appicon of a currently focused window.

Original-patch-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Alexey I. Froloff <raorn@altlinux.org>
This commit is contained in:
Alexey I. Froloff
2010-09-10 20:51:07 +04:00
committed by Carlos R. Mafra
parent a257e16593
commit 392ab2607d
7 changed files with 98 additions and 18 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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

View File

@@ -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);
}

View File

@@ -50,6 +50,7 @@ LIBWRASTER3
RGetSubImage;
RGetXImage;
RHSVtoRGB;
RLightImage;
RLoadImage;
RMakeCenteredImage;
RMakeTiledImage;

View File

@@ -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,18 +148,51 @@ 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);
}
}
}
const char *RMessageForError(int errorCode)

View File

@@ -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);