summary refs log tree commit diff stats
path: root/src/fe-gtk/pixmaps.c
diff options
context:
space:
mode:
authorSoniEx2 <endermoneymod@gmail.com>2021-05-27 20:39:07 -0300
committerSoniEx2 <endermoneymod@gmail.com>2021-05-27 20:39:07 -0300
commit5571d277b93b62c73568b78c652c85b2e8e95183 (patch)
tree0d97d65058e31ccdeab4006384442a8e378d5f06 /src/fe-gtk/pixmaps.c
parentf58165fd33919951e2ca594c6f19a785420fc4f9 (diff)
parent7f8b0a19cff46f7d27451fb9942eea5018f0c5b5 (diff)
Merge upstream changes
Diffstat (limited to 'src/fe-gtk/pixmaps.c')
-rw-r--r--src/fe-gtk/pixmaps.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/fe-gtk/pixmaps.c b/src/fe-gtk/pixmaps.c
index 6c6cfaeb..9bdf46fc 100644
--- a/src/fe-gtk/pixmaps.c
+++ b/src/fe-gtk/pixmaps.c
@@ -89,7 +89,9 @@ pixmap_load_from_file (char *filename)
 static GdkPixbuf *
 load_pixmap (const char *filename)
 {
-	GdkPixbuf *pixbuf;
+	GdkPixbuf *pixbuf, *scaledpixbuf;
+	const char *scale;
+	int iscale;
 
 	gchar *path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "icons" G_DIR_SEPARATOR_S "%s.png", get_xdir (), filename);
 	pixbuf = gdk_pixbuf_new_from_file (path, 0);
@@ -102,6 +104,24 @@ load_pixmap (const char *filename)
 		g_free (path);
 	}
 
+	// Hack to avoid unbearably tiny icons on HiDPI screens.
+	scale = g_getenv ("GDK_SCALE");
+	if (scale)
+	{
+		iscale = atoi (scale);
+		if (iscale > 0)
+		{
+			scaledpixbuf = gdk_pixbuf_scale_simple (pixbuf, gdk_pixbuf_get_width (pixbuf) * iscale,
+				gdk_pixbuf_get_height (pixbuf) * iscale, GDK_INTERP_BILINEAR);
+
+			if (scaledpixbuf)
+			{
+				g_object_unref (pixbuf);
+				pixbuf = scaledpixbuf;
+			}
+		}
+	}
+
 	g_warn_if_fail (pixbuf != NULL);
 
 	return pixbuf;