1
0
mirror of https://github.com/gryf/gryf-overlay.git synced 2025-12-25 07:32:30 +01:00

Added scale icon patch.

Added patch[1] by Robert Lillack, to gain ability to nicely fit icons in
miniwindows.

[1] https://github.com/roblillack/wmaker/pull/5
This commit is contained in:
2023-03-21 19:21:47 +01:00
parent 0e52fc0e1e
commit f93c8ecf33
3 changed files with 138 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
AUX wmaker-ignore-max-for-terminals.patch 1309 BLAKE2B 605136e83cbfa3acb05fcb7e2b0d82bd05007997e970d4ffe9bf302254193aa5806ba696a4fa226158194b7d0e69b0ba2e7eda6009c07d4015add016d878d4c5 SHA512 63a3ab78b688638562c3eb040e8df02254633d594a380b21777163fe8fa1a140d0f1ea6e419c53aa58c1624a3098d5a1873ebca57bda3b32954407acff1cd13f
AUX wmaker-scale-icons.patch 4936 BLAKE2B 867c86d1cf391995eda8f0d3abceb88a00d82165374784515f5a82889f19b9b6f5f756b562af59f7a803c869f05e745158b2ec4c913453e6ec786d76c8f017b0 SHA512 0c8b24224dea7a899bdca3f2286cd07cd4a144a47b0b932c7080233fea257a34e384b4c20d5caf098c2a2665ba0f6dd2c66b51786e65c9feac123120993a131a
AUX wmaker.desktop 206 BLAKE2B 62fe60afde032c1f37c5c818bc37a97d70605e041e539e922f18d56a7582fffd1689762f600fa3c69c5b62dd399867c8c1208d393060e734b38a84540143bf79 SHA512 d1dc99aa29047434e1265c8f93ce366b7c026f27eec8a166904fda1ab4144e0d6142807ac09ba6cbcb86480257893e5553046a0ba1a8e1d6315f23dd8468482b
DIST WindowMaker-extra-0.1.tar.gz 238018 BLAKE2B 865b12975d0cdefc1f05a76344b449fdcf8a2841d6a7adf1ab6435857d89cbc4fda22bb62432a1bbba921267380d00a0cded718bfbd344bbb5e6207e59b76096 SHA512 0fe9b3ffc093942db167d8a01e15c0f6741f3a40959d1434ea4f23e7b9d4a9c13935a61eabef9691e5fdfd4e407564caafce15c2d65d66499960a6764a874ab8
EBUILD windowmaker-8888.ebuild 3426 BLAKE2B 11995ec89ea63a5d2d49b4ce79ef56a245a81f18e08813c54a7bb97d6205d15324607d0beb70dca7434bce75104a85e6916dcedb11e4026c1c4cd221cb3acc71 SHA512 57d62fd5e79c076214a658138d132c8a99f4e702746b238ad8ed976fcc8f85c8372b41c023ae51e0950f4027a0efa3420a3407b46c6c84d33f69f39923ea6498
EBUILD windowmaker-8888.ebuild 3465 BLAKE2B 538fd2256658222c26499dff1914bbe058e8f19b9d919f151342bddfa2e441cd5742f5e4a44e06bee729806691d4d8f8cef3dd642db27840a6c3f3538f6355c5 SHA512 2c16b7363be99e7844cac892027725cdc5c49b6f7e60b444ca6789949836f59661b2f642412374e7978da1fe0a81e4664d04f1d109d16dd70a88df45d59b6a46

View File

@@ -0,0 +1,135 @@
diff --git a/src/defaults.c b/src/defaults.c
index 2f68539c..d5f82428 100644
--- a/src/defaults.c
+++ b/src/defaults.c
@@ -365,7 +365,7 @@ WDefaultEntry optionList[] = {
&wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL},
{"IconificationStyle", "Zoom", seIconificationStyles,
&wPreferences.iconification_style, getEnum, NULL, NULL, NULL},
- {"EnforceIconMargin", "NO", NULL,
+ {"EnforceIconMargin", "YES", NULL,
&wPreferences.enforce_icon_margin, getBool, NULL, NULL, NULL},
{"DisableWSMouseActions", "NO", NULL,
&wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL},
diff --git a/src/icon.c b/src/icon.c
index 6f5f02e9..39aa3224 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -336,22 +336,39 @@ void wIconChangeTitle(WIcon *icon, WWindow *wwin)
icon->icon_name = wNETWMGetWindowName(wwin->client_win);
}
-RImage *wIconValidateIconSize(RImage *icon, int max_size)
+RImage *wIconValidateIconSize(RImage *icon, int max_size, Bool scale_down)
{
RImage *nimage;
if (!icon)
return NULL;
- /* We should hold "ICON_BORDER" (~2) pixels to include the icon border */
- if (((max_size + ICON_BORDER) < icon->width) ||
- ((max_size + ICON_BORDER) < icon->height)) {
+ int wanted = max_size;
+
+ if (scale_down) {
+ /* For some image sources, we want to ensure that the icon is fitting */
+
+ if (wPreferences.enforce_icon_margin) {
+ /* better use only 75% of icon_size. For 64x64 this means 48x48
+ * This leaves room around the icon for the miniwindow title and
+ * results in better overall aesthetics -Dan */
+ wanted = (int)((double)wPreferences.icon_size * 0.75 + 0.5);
+
+ /* the size should be a multiple of 4 */
+ wanted = (wanted >> 2) << 2;
+ } else {
+
+ /* This is the "old" approach, which just adds a 3px border */
+ wanted = (max_size - ICON_BORDER);
+ }
+ }
+
+ if (icon->width > wanted || icon->height > wanted) {
if (icon->width > icon->height)
- nimage = RScaleImage(icon, max_size - ICON_BORDER,
- (icon->height * (max_size - ICON_BORDER) / icon->width));
+ nimage = RScaleImage(icon, wanted, icon->height * wanted / icon->width);
else
- nimage = RScaleImage(icon, (icon->width * (max_size - ICON_BORDER) / icon->height),
- max_size - ICON_BORDER);
+ nimage = RScaleImage(icon, icon->width * wanted / icon->height, wanted);
+
RReleaseImage(icon);
icon = nimage;
}
@@ -794,7 +811,7 @@ RImage *get_rimage_icon_from_wm_hints(WIcon *icon)
return NULL;
/* Resize the icon to the wPreferences.icon_size size */
- image = wIconValidateIconSize(image, wPreferences.icon_size);
+ image = wIconValidateIconSize(image, wPreferences.icon_size, True);
return image;
}
diff --git a/src/icon.h b/src/icon.h
index cccd7a86..49054a5d 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -70,7 +70,7 @@ void update_icon_pixmap(WIcon *icon);
int wIconChangeImageFile(WIcon *icon, const char *file);
-RImage *wIconValidateIconSize(RImage *icon, int max_size);
+RImage *wIconValidateIconSize(RImage *icon, int max_size, Bool scale_down);
RImage *get_rimage_icon_from_wm_hints(WIcon *icon);
char *wIconStore(WIcon *icon);
diff --git a/src/switchpanel.c b/src/switchpanel.c
index 5bf84da8..e113f36d 100644
--- a/src/switchpanel.c
+++ b/src/switchpanel.c
@@ -199,7 +199,7 @@ static void addIconForWindow(WSwitchPanel *panel, WMWidget *parent, WWindow *wwi
image = get_icon_image(panel->scr, wwin->wm_instance, wwin->wm_class, icon_tile_size);
/* We must resize the icon size (~64) to the switch panel icon size (~48) */
- image = wIconValidateIconSize(image, icon_size);
+ image = wIconValidateIconSize(image, icon_size, False);
WMAddToArray(panel->images, image);
WMAddToArray(panel->icons, icon);
diff --git a/src/wdefaults.c b/src/wdefaults.c
index 7aad3db5..0bb476b9 100644
--- a/src/wdefaults.c
+++ b/src/wdefaults.c
@@ -435,7 +435,7 @@ RImage *get_rimage_from_file(WScreen *scr, const char *file_name, int max_size)
wwarning(_("error loading image file \"%s\": %s"), file_name,
RMessageForError(RErrorCode));
- image = wIconValidateIconSize(image, max_size);
+ image = wIconValidateIconSize(image, max_size, False);
return image;
}
@@ -472,7 +472,7 @@ RImage *get_default_image(WScreen *scr)
/* Resize the icon to the wPreferences.icon_size size
* usually this function will return early, because size is right */
- image = wIconValidateIconSize(image, wPreferences.icon_size);
+ image = wIconValidateIconSize(image, wPreferences.icon_size, False);
return image;
}
diff --git a/src/wmspec.c b/src/wmspec.c
index 64eaa05c..af29d5d8 100644
--- a/src/wmspec.c
+++ b/src/wmspec.c
@@ -536,7 +536,7 @@ RImage *get_window_image_from_x11(Window window)
return NULL;
/* Resize the image to the correct value */
- image = wIconValidateIconSize(image, wPreferences.icon_size);
+ image = wIconValidateIconSize(image, wPreferences.icon_size, False);
return image;
}

View File

@@ -44,7 +44,7 @@ src_unpack() {
git-r3_src_unpack
}
PATCHES=( )
PATCHES=( "${FILESDIR}/wmaker-scale-icons.patch" )
src_prepare() {
# Add info about commit in About window