mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 04:20:27 +01:00
Don't shrink icons in switchpanel.
Icons in the switchpanel are constrained to the value of the IconSize preference but the grid in which they are arranged is fixed at 64 pixels. If IconSize is less than 64x64 the panel will show smaller icons with a wide spacing, which looks pretty stupid. Fix it by forcing the switchpanel to attempt to load images at the size it's going to use. The icon it actually gets may of course still be smaller.
This commit is contained in:
committed by
Carlos R. Mafra
parent
854ae58305
commit
07a0639c93
@@ -966,7 +966,7 @@ void wDefaultsCheckDomains(void* arg)
|
|||||||
/* Update the panel image if changed */
|
/* Update the panel image if changed */
|
||||||
/* Don't worry. If the image is the same these
|
/* Don't worry. If the image is the same these
|
||||||
* functions will have no performance impact. */
|
* functions will have no performance impact. */
|
||||||
image = wDefaultGetImage(scr, "Logo", "WMPanel");
|
image = wDefaultGetImage(scr, "Logo", "WMPanel", wPreferences.icon_size);
|
||||||
|
|
||||||
if (!image) {
|
if (!image) {
|
||||||
wwarning(_("could not load logo image for panels: %s"),
|
wwarning(_("could not load logo image for panels: %s"),
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ void wSaveDefaults(WScreen *scr);
|
|||||||
char *wDefaultGetIconFile(WScreen *scr, char *instance, char *class,
|
char *wDefaultGetIconFile(WScreen *scr, char *instance, char *class,
|
||||||
Bool noDefault);
|
Bool noDefault);
|
||||||
|
|
||||||
RImage *wDefaultGetImage(WScreen *scr, char *winstance, char *wclass);
|
RImage *wDefaultGetImage(WScreen *scr, char *winstance, char *wclass, int max_size);
|
||||||
|
|
||||||
void wDefaultFillAttributes(WScreen *scr, char *instance, char *class,
|
void wDefaultFillAttributes(WScreen *scr, char *instance, char *class,
|
||||||
WWindowAttributes *attr, WWindowAttributes *mask,
|
WWindowAttributes *attr, WWindowAttributes *mask,
|
||||||
|
|||||||
16
src/icon.c
16
src/icon.c
@@ -154,7 +154,7 @@ WIcon *wIconCreate(WWindow * wwin)
|
|||||||
#else
|
#else
|
||||||
icon->show_title = 1;
|
icon->show_title = 1;
|
||||||
#endif
|
#endif
|
||||||
icon->file_image = wDefaultGetImage(scr, wwin->wm_instance, wwin->wm_class);
|
icon->file_image = wDefaultGetImage(scr, wwin->wm_instance, wwin->wm_class, wPreferences.icon_size);
|
||||||
|
|
||||||
file = wDefaultGetIconFile(scr, wwin->wm_instance, wwin->wm_class, False);
|
file = wDefaultGetIconFile(scr, wwin->wm_instance, wwin->wm_class, False);
|
||||||
if (file) {
|
if (file) {
|
||||||
@@ -215,7 +215,7 @@ WIcon *wIconCreateWithIconFile(WScreen * scr, char *iconfile, int tile)
|
|||||||
wwarning(_("error loading image file \"%s\": %s"), iconfile, RMessageForError(RErrorCode));
|
wwarning(_("error loading image file \"%s\": %s"), iconfile, RMessageForError(RErrorCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
icon->file_image = wIconValidateIconSize(scr, icon->file_image);
|
icon->file_image = wIconValidateIconSize(scr, icon->file_image, wPreferences.icon_size);
|
||||||
|
|
||||||
icon->file = wstrdup(iconfile);
|
icon->file = wstrdup(iconfile);
|
||||||
}
|
}
|
||||||
@@ -354,7 +354,7 @@ void wIconChangeTitle(WIcon * icon, char *new_title)
|
|||||||
wIconPaint(icon);
|
wIconPaint(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
RImage *wIconValidateIconSize(WScreen * scr, RImage * icon)
|
RImage *wIconValidateIconSize(WScreen * scr, RImage * icon, int max_size)
|
||||||
{
|
{
|
||||||
RImage *tmp;
|
RImage *tmp;
|
||||||
int w, h;
|
int w, h;
|
||||||
@@ -362,9 +362,9 @@ RImage *wIconValidateIconSize(WScreen * scr, RImage * icon)
|
|||||||
if (!icon)
|
if (!icon)
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifndef DONT_SCALE_ICONS
|
#ifndef DONT_SCALE_ICONS
|
||||||
if (wPreferences.icon_size != 64) {
|
if (max_size != 64) {
|
||||||
w = wPreferences.icon_size * icon->width / 64;
|
w = max_size * icon->width / 64;
|
||||||
h = wPreferences.icon_size * icon->height / 64;
|
h = max_size * icon->height / 64;
|
||||||
|
|
||||||
tmp = RScaleImage(icon, w, h);
|
tmp = RScaleImage(icon, w, h);
|
||||||
RReleaseImage(icon);
|
RReleaseImage(icon);
|
||||||
@@ -394,7 +394,7 @@ Bool wIconChangeImageFile(WIcon * icon, char *file)
|
|||||||
path = FindImage(wPreferences.icon_path, file);
|
path = FindImage(wPreferences.icon_path, file);
|
||||||
|
|
||||||
if (path && (image = RLoadImage(scr->rcontext, path, 0))) {
|
if (path && (image = RLoadImage(scr->rcontext, path, 0))) {
|
||||||
icon->file_image = wIconValidateIconSize(icon->core->screen_ptr, image);
|
icon->file_image = wIconValidateIconSize(icon->core->screen_ptr, image, wPreferences.icon_size);
|
||||||
wIconUpdate(icon);
|
wIconUpdate(icon);
|
||||||
} else {
|
} else {
|
||||||
error = 1;
|
error = 1;
|
||||||
@@ -706,7 +706,7 @@ void wIconUpdate(WIcon * icon)
|
|||||||
}
|
}
|
||||||
make_icons:
|
make_icons:
|
||||||
|
|
||||||
image = wIconValidateIconSize(scr, image);
|
image = wIconValidateIconSize(scr, image, wPreferences.icon_size);
|
||||||
scr->def_icon_pixmap = makeIcon(scr, image, False, False, icon->tile_type, icon->highlighted);
|
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);
|
scr->def_ticon_pixmap = makeIcon(scr, image, True, False, icon->tile_type, icon->highlighted);
|
||||||
if (image)
|
if (image)
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ void wIconChangeTitle(WIcon *icon, char *new_title);
|
|||||||
Bool wIconChangeImageFile(WIcon *icon, char *file);
|
Bool wIconChangeImageFile(WIcon *icon, char *file);
|
||||||
void wIconSelect(WIcon *icon);
|
void wIconSelect(WIcon *icon);
|
||||||
|
|
||||||
RImage *wIconValidateIconSize(WScreen *scr, RImage *icon);
|
RImage *wIconValidateIconSize(WScreen *scr, RImage *icon, int max_size);
|
||||||
|
|
||||||
char *wIconStore(WIcon *icon);
|
char *wIconStore(WIcon *icon);
|
||||||
|
|
||||||
|
|||||||
@@ -402,7 +402,7 @@ static void createPixmaps(WScreen * scr)
|
|||||||
pix->shared = 1;
|
pix->shared = 1;
|
||||||
scr->menu_shade_indicator = pix;
|
scr->menu_shade_indicator = pix;
|
||||||
|
|
||||||
image = wDefaultGetImage(scr, "Logo", "WMPanel");
|
image = wDefaultGetImage(scr, "Logo", "WMPanel", wPreferences.icon_size);
|
||||||
|
|
||||||
if (!image) {
|
if (!image) {
|
||||||
wwarning(_("could not load logo image for panels: %s"), RMessageForError(RErrorCode));
|
wwarning(_("could not load logo image for panels: %s"), RMessageForError(RErrorCode));
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ static void addIconForWindow(WSwitchPanel * panel, WMWidget * parent, WWindow *
|
|||||||
// it's very likely that most of them are instances of the same thing,
|
// it's very likely that most of them are instances of the same thing,
|
||||||
// so caching them should get performance acceptable in these cases.
|
// so caching them should get performance acceptable in these cases.
|
||||||
if (!image)
|
if (!image)
|
||||||
image = wDefaultGetImage(panel->scr, wwin->wm_instance, wwin->wm_class);
|
image = wDefaultGetImage(panel->scr, wwin->wm_instance, wwin->wm_class, ICON_TILE_SIZE);
|
||||||
|
|
||||||
if (!image && !panel->defIcon) {
|
if (!image && !panel->defIcon) {
|
||||||
char *file = wDefaultGetIconFile(panel->scr, NULL, NULL, False);
|
char *file = wDefaultGetIconFile(panel->scr, NULL, NULL, False);
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ char *wDefaultGetIconFile(WScreen * scr, char *instance, char *class, Bool noDef
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
RImage *wDefaultGetImage(WScreen * scr, char *winstance, char *wclass)
|
RImage *wDefaultGetImage(WScreen * scr, char *winstance, char *wclass, int max_size)
|
||||||
{
|
{
|
||||||
char *file_name;
|
char *file_name;
|
||||||
char *path;
|
char *path;
|
||||||
@@ -422,7 +422,7 @@ RImage *wDefaultGetImage(WScreen * scr, char *winstance, char *wclass)
|
|||||||
}
|
}
|
||||||
wfree(path);
|
wfree(path);
|
||||||
|
|
||||||
image = wIconValidateIconSize(scr, image);
|
image = wIconValidateIconSize(scr, image, max_size);
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user