From 00decaa9a1090321d910b0ee3afed0dea85b09e9 Mon Sep 17 00:00:00 2001 From: Scoopta Date: Sat, 18 Jul 2020 01:44:29 -0700 Subject: [PATCH] Fixed icon scaling on HiDPI displays --- modes/drun.c | 6 +++--- src/widget_builder.c | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modes/drun.c b/modes/drun.c index e541296..f3ae876 100644 --- a/modes/drun.c +++ b/modes/drun.c @@ -111,15 +111,15 @@ static bool populate_widget(char* file, char* action, struct widget_builder* bui GtkIconInfo* info = NULL; if(icon != NULL) { const gchar* const* icon_names = g_themed_icon_get_names(G_THEMED_ICON(icon)); - info = gtk_icon_theme_choose_icon(theme, (const gchar**) icon_names, wofi_get_image_size(), 0); + info = gtk_icon_theme_choose_icon_for_scale(theme, (const gchar**) icon_names, wofi_get_image_size(), wofi_get_window_scale(), 0); } if(info == NULL) { - info = gtk_icon_theme_lookup_icon(theme, "application-x-executable", wofi_get_image_size(), 0); + info = gtk_icon_theme_lookup_icon_for_scale(theme, "application-x-executable", wofi_get_image_size(), wofi_get_window_scale(), 0); } pixbuf = gtk_icon_info_load_icon(info, NULL); } - pixbuf = utils_g_resize_pixbuf(pixbuf, wofi_get_image_size(), GDK_INTERP_BILINEAR); + pixbuf = utils_g_resize_pixbuf(pixbuf, wofi_get_image_size() * wofi_get_window_scale(), GDK_INTERP_BILINEAR); wofi_widget_builder_insert_image(builder, pixbuf, "icon"); g_object_unref(pixbuf); diff --git a/src/widget_builder.c b/src/widget_builder.c index 6fc7b69..0da03fe 100644 --- a/src/widget_builder.c +++ b/src/widget_builder.c @@ -53,7 +53,10 @@ void wofi_widget_builder_insert_text(struct widget_builder* builder, const char* } void wofi_widget_builder_insert_image(struct widget_builder* builder, GdkPixbuf* pixbuf, char* css_name) { - GtkWidget* img = gtk_image_new_from_pixbuf(pixbuf); + GtkWidget* img = gtk_image_new(); + cairo_surface_t* surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, wofi_get_window_scale(), gtk_widget_get_window(img)); + gtk_image_set_from_surface(GTK_IMAGE(img), surface); + cairo_surface_destroy(surface); gtk_container_add(GTK_CONTAINER(builder->box), img); if(css_name != NULL) { char* tmp = utils_concat(3, builder->mode->name, "-", css_name);