mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-23 22:52:34 +01:00
Little simplification in makeIcon()
This commit is contained in:
committed by
Carlos R. Mafra
parent
f550333474
commit
9079b904d6
44
src/icon.c
44
src/icon.c
@@ -281,31 +281,29 @@ static Pixmap makeIcon(WScreen *scr, RImage *icon, int titled, int shadowed, int
|
|||||||
Pixmap pixmap;
|
Pixmap pixmap;
|
||||||
int x, y, sx, sy;
|
int x, y, sx, sy;
|
||||||
unsigned w, h;
|
unsigned w, h;
|
||||||
int theight = WMFontHeight(scr->icon_title_font);
|
int theight = 0;
|
||||||
|
|
||||||
if (tileType == TILE_NORMAL)
|
if (tileType == TILE_NORMAL) {
|
||||||
tile = RCloneImage(scr->icon_tile);
|
tile = RCloneImage(scr->icon_tile);
|
||||||
else {
|
} else {
|
||||||
assert(scr->clip_tile);
|
assert(scr->clip_tile);
|
||||||
tile = RCloneImage(scr->clip_tile);
|
tile = RCloneImage(scr->clip_tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icon) {
|
if (icon) {
|
||||||
w = (icon->width > wPreferences.icon_size)
|
w = (icon->width > wPreferences.icon_size)
|
||||||
? wPreferences.icon_size : icon->width;
|
? wPreferences.icon_size : icon->width;
|
||||||
x = (wPreferences.icon_size - w) / 2;
|
x = (wPreferences.icon_size - w) / 2;
|
||||||
sx = (icon->width - w) / 2;
|
sx = (icon->width - w) / 2;
|
||||||
|
|
||||||
if (!titled) {
|
if (titled)
|
||||||
h = (icon->height > wPreferences.icon_size)
|
theight = WMFontHeight(scr->icon_title_font);
|
||||||
? wPreferences.icon_size : icon->height;
|
|
||||||
y = (wPreferences.icon_size - h) / 2;
|
|
||||||
sy = (icon->height - h) / 2;
|
|
||||||
} else {
|
|
||||||
h = (icon->height + theight > wPreferences.icon_size
|
h = (icon->height + theight > wPreferences.icon_size
|
||||||
? wPreferences.icon_size - theight : icon->height);
|
? wPreferences.icon_size - theight : icon->height);
|
||||||
y = theight + ((int)wPreferences.icon_size - theight - h) / 2;
|
y = theight + (wPreferences.icon_size - theight - h) / 2;
|
||||||
sy = (icon->height - h) / 2;
|
sy = (icon->height - h) / 2;
|
||||||
}
|
|
||||||
RCombineArea(tile, icon, sx, sy, w, h, x, y);
|
RCombineArea(tile, icon, sx, sy, w, h, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,6 +316,7 @@ static Pixmap makeIcon(WScreen *scr, RImage *icon, int titled, int shadowed, int
|
|||||||
color.alpha = 150; /* about 60% */
|
color.alpha = 150; /* about 60% */
|
||||||
RClearImage(tile, &color);
|
RClearImage(tile, &color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highlighted) {
|
if (highlighted) {
|
||||||
RColor color;
|
RColor color;
|
||||||
|
|
||||||
@@ -326,9 +325,9 @@ static Pixmap makeIcon(WScreen *scr, RImage *icon, int titled, int shadowed, int
|
|||||||
RLightImage(tile, &color);
|
RLightImage(tile, &color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!RConvertImage(scr->rcontext, tile, &pixmap)) {
|
if (!RConvertImage(scr->rcontext, tile, &pixmap))
|
||||||
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
|
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
|
||||||
}
|
|
||||||
RReleaseImage(tile);
|
RReleaseImage(tile);
|
||||||
|
|
||||||
if (titled)
|
if (titled)
|
||||||
@@ -611,12 +610,11 @@ void wIconUpdate(WIcon * icon)
|
|||||||
icon->pixmap = pixmap;
|
icon->pixmap = pixmap;
|
||||||
|
|
||||||
if (XGetWindowAttributes(dpy, icon->icon_win, &attr)) {
|
if (XGetWindowAttributes(dpy, icon->icon_win, &attr)) {
|
||||||
if (attr.all_event_masks & ButtonPressMask) {
|
if (attr.all_event_masks & ButtonPressMask)
|
||||||
wHackedGrabButton(Button1, MOD_MASK, icon->core->window, True,
|
wHackedGrabButton(Button1, MOD_MASK, icon->core->window, True,
|
||||||
ButtonPressMask, GrabModeSync, GrabModeAsync,
|
ButtonPressMask, GrabModeSync, GrabModeAsync,
|
||||||
None, wCursor[WCUR_ARROW]);
|
None, wCursor[WCUR_ARROW]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if (wwin && wwin->net_icon_image) {
|
} else if (wwin && wwin->net_icon_image) {
|
||||||
/* Use _NET_WM_ICON icon */
|
/* Use _NET_WM_ICON icon */
|
||||||
icon->pixmap = makeIcon(scr, wwin->net_icon_image, icon->show_title,
|
icon->pixmap = makeIcon(scr, wwin->net_icon_image, icon->show_title,
|
||||||
@@ -677,13 +675,11 @@ void wIconUpdate(WIcon * icon)
|
|||||||
icon->pixmap = pixmap;
|
icon->pixmap = pixmap;
|
||||||
} else {
|
} else {
|
||||||
user_icon:
|
user_icon:
|
||||||
|
|
||||||
if (icon->file_image) {
|
if (icon->file_image) {
|
||||||
icon->pixmap = makeIcon(scr, icon->file_image, icon->show_title,
|
icon->pixmap = makeIcon(scr, icon->file_image, icon->show_title,
|
||||||
icon->shadowed, icon->tile_type, icon->highlighted);
|
icon->shadowed, icon->tile_type, icon->highlighted);
|
||||||
} else {
|
} else {
|
||||||
/* make default icons */
|
/* make default icons */
|
||||||
|
|
||||||
if (!scr->def_icon_pixmap) {
|
if (!scr->def_icon_pixmap) {
|
||||||
RImage *image = NULL;
|
RImage *image = NULL;
|
||||||
char *path;
|
char *path;
|
||||||
@@ -698,10 +694,9 @@ void wIconUpdate(WIcon * icon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
image = RLoadImage(scr->rcontext, path, 0);
|
image = RLoadImage(scr->rcontext, path, 0);
|
||||||
if (!image) {
|
if (!image)
|
||||||
wwarning(_("could not load default icon \"%s\":%s"),
|
wwarning(_("could not load default icon \"%s\":%s"),
|
||||||
file, RMessageForError(RErrorCode));
|
file, RMessageForError(RErrorCode));
|
||||||
}
|
|
||||||
wfree(path);
|
wfree(path);
|
||||||
}
|
}
|
||||||
make_icons:
|
make_icons:
|
||||||
@@ -713,19 +708,18 @@ void wIconUpdate(WIcon * icon)
|
|||||||
RReleaseImage(image);
|
RReleaseImage(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icon->show_title) {
|
if (icon->show_title)
|
||||||
XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->def_ticon_pixmap);
|
XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->def_ticon_pixmap);
|
||||||
} else {
|
else
|
||||||
XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->def_icon_pixmap);
|
XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->def_icon_pixmap);
|
||||||
}
|
|
||||||
icon->pixmap = None;
|
icon->pixmap = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (icon->pixmap != None) {
|
if (icon->pixmap != None)
|
||||||
XSetWindowBackgroundPixmap(dpy, icon->core->window, icon->pixmap);
|
XSetWindowBackgroundPixmap(dpy, icon->core->window, icon->pixmap);
|
||||||
}
|
|
||||||
XClearWindow(dpy, icon->core->window);
|
|
||||||
|
|
||||||
|
XClearWindow(dpy, icon->core->window);
|
||||||
wIconPaint(icon);
|
wIconPaint(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user