Fixed icon scaling on HiDPI displays

This commit is contained in:
Scoopta 2020-07-18 01:44:29 -07:00
parent da98a2d240
commit 00decaa9a1
2 changed files with 7 additions and 4 deletions

View File

@ -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);

View File

@ -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);