1
0
forked from vitrine/wmaker

Removed scaleDownIfNeeded function (dup code)

The function scaleDownIfNeeded's code is duplicated with the code of
wIconValidateIconSize(), then this function can be removed. The icon
size in the switchpanel should be ~48 pixels, to allow the frame around
the icon. Then, we always should resize the icon to this size. The standard
icon size is specified in WPreferences.icon_size (usually 64 pixels).
This commit is contained in:
Rodolfo García Peñas (kix)
2012-07-15 21:28:00 +02:00
committed by Carlos R. Mafra
parent 2e7b7b7e02
commit af41673dbf

View File

@@ -27,6 +27,7 @@
#include "WindowMaker.h"
#include "screen.h"
#include "framewin.h"
#include "icon.h"
#include "window.h"
#include "defaults.h"
#include "switchpanel.h"
@@ -148,18 +149,6 @@ static void changeImage(WSwitchPanel *panel, int idecks, int selected)
WMSetFrameRelief(icon, WRSimple);
}
static RImage *scaleDownIfNeeded(RImage *image)
{
if (image && ((image->width - ICON_SIZE) > 2 || (image->height - ICON_SIZE) > 2)) {
RImage *nimage;
nimage = RScaleImage(image, ICON_SIZE, (image->height * ICON_SIZE / image->width));
RReleaseImage(image);
image = nimage;
}
return image;
}
static void addIconForWindow(WSwitchPanel *panel, WMWidget *parent, WWindow *wwin, int x, int y)
{
WMFrame *icon = WMCreateFrame(parent);
@@ -176,7 +165,8 @@ static void addIconForWindow(WSwitchPanel *panel, WMWidget *parent, WWindow *wwi
if (!image)
image = wDefaultGetImage(panel->scr, wwin->wm_instance, wwin->wm_class, ICON_TILE_SIZE);
image = scaleDownIfNeeded(image);
/* We must resize the icon size (~64) to the switchpanel icon size (~48) */
image = wIconValidateIconSize(image, ICON_SIZE);
WMAddToArray(panel->images, image);
WMAddToArray(panel->icons, icon);