diff --git a/thunar/thunar-gdk-extensions.c b/thunar/thunar-gdk-extensions.c index 279382cb960eed16d907200f4aa0e9e60ec8eb5f..8f59bf2edf574d47051cf7143cb11ab79113f4b9 100644 --- a/thunar/thunar-gdk-extensions.c +++ b/thunar/thunar-gdk-extensions.c @@ -44,7 +44,8 @@ static const cairo_user_data_key_t cairo_key; static cairo_surface_t * -thunar_gdk_cairo_create_surface (const GdkPixbuf *pixbuf) +thunar_gdk_cairo_create_surface (const GdkPixbuf *pixbuf, + gint scale_factor) { gint width; gint height; @@ -141,6 +142,8 @@ thunar_gdk_cairo_create_surface (const GdkPixbuf *pixbuf) #undef MULT } + cairo_surface_set_device_scale (surface, scale_factor, scale_factor); + return surface; } @@ -224,10 +227,11 @@ thunar_gdk_screen_open (const gchar *display_name, /** * thunar_gdk_cairo_set_source_pixbuf: - * cr : a Cairo context - * pixbuf : a GdkPixbuf - * pixbuf_x : X coordinate of location to place upper left corner of pixbuf - * pixbuf_y : Y coordinate of location to place upper left corner of pixbuf + * cr : a Cairo context + * pixbuf : a GdkPixbuf + * pixbuf_x : X coordinate of location to place upper left corner of pixbuf + * pixbuf_y : Y coordinate of location to place upper left corner of pixbuf + * scale_factor : UI scaling factor * * Works like gdk_cairo_set_source_pixbuf but we try to cache the surface * on the pixbuf, which is efficient within Thunar because we also share @@ -237,7 +241,8 @@ void thunar_gdk_cairo_set_source_pixbuf (cairo_t *cr, GdkPixbuf *pixbuf, gdouble pixbuf_x, - gdouble pixbuf_y) + gdouble pixbuf_y, + gint scale_factor) { cairo_surface_t *surface; static GQuark surface_quark = 0; @@ -250,7 +255,7 @@ thunar_gdk_cairo_set_source_pixbuf (cairo_t *cr, if (surface == NULL) { /* create a new surface */ - surface = thunar_gdk_cairo_create_surface (pixbuf); + surface = thunar_gdk_cairo_create_surface (pixbuf, scale_factor); /* store the pixbuf on the pixbuf */ g_object_set_qdata_full (G_OBJECT (pixbuf), surface_quark, diff --git a/thunar/thunar-gdk-extensions.h b/thunar/thunar-gdk-extensions.h index 11b8e760ea8c23d0717756d666e015adecf7597f..c14f4d7358ccc57b7f12252d61bf16d531da0c61 100644 --- a/thunar/thunar-gdk-extensions.h +++ b/thunar/thunar-gdk-extensions.h @@ -31,7 +31,8 @@ GdkScreen *thunar_gdk_screen_open (const gchar *display_name, void thunar_gdk_cairo_set_source_pixbuf (cairo_t *cr, GdkPixbuf *pixbuf, gdouble pixbuf_x, - gdouble pixbuf_y); + gdouble pixbuf_y, + gint scale_factor); G_END_DECLS; diff --git a/thunar/thunar-icon-renderer.c b/thunar/thunar-icon-renderer.c index 94f519542d9b96802e54db5863e66b3a040764f6..a68b8a5dc6ee4dfd47033f7c174916a4464aec2b 100644 --- a/thunar/thunar-icon-renderer.c +++ b/thunar/thunar-icon-renderer.c @@ -459,6 +459,7 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer, GdkPixbuf *temp; GList *emblems; GList *lp; + gint scale_factor; gint max_emblems; gint position; gdouble alpha; @@ -488,7 +489,8 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer, /* load the main icon */ icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget)); icon_factory = thunar_icon_factory_get_for_icon_theme (icon_theme); - icon = thunar_icon_factory_load_file_icon (icon_factory, icon_renderer->file, icon_state, icon_renderer->size); + scale_factor = gtk_widget_get_scale_factor (widget); + icon = thunar_icon_factory_load_file_icon (icon_factory, icon_renderer->file, icon_state, icon_renderer->size * scale_factor); if (G_UNLIKELY (icon == NULL)) { g_object_unref (G_OBJECT (icon_factory)); @@ -500,20 +502,20 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer, flags |= GTK_CELL_RENDERER_PRELIT; /* determine the real icon size */ - icon_area.width = gdk_pixbuf_get_width (icon); - icon_area.height = gdk_pixbuf_get_height (icon); + icon_area.width = gdk_pixbuf_get_width (icon) / scale_factor; + icon_area.height = gdk_pixbuf_get_height (icon) / scale_factor; /* scale down the icon on-demand */ if (G_UNLIKELY (icon_area.width > cell_area->width || icon_area.height > cell_area->height)) { /* scale down to fit */ - temp = exo_gdk_pixbuf_scale_down (icon, TRUE, MAX (1, cell_area->width), MAX (1, cell_area->height)); + temp = exo_gdk_pixbuf_scale_down (icon, TRUE, MAX (1, cell_area->width * scale_factor), MAX (1, cell_area->height * scale_factor)); g_object_unref (G_OBJECT (icon)); icon = temp; /* determine the icon dimensions again */ - icon_area.width = gdk_pixbuf_get_width (icon); - icon_area.height = gdk_pixbuf_get_height (icon); + icon_area.width = gdk_pixbuf_get_width (icon) / scale_factor; + icon_area.height = gdk_pixbuf_get_height (icon) / scale_factor; } icon_area.x = cell_area->x + (cell_area->width - icon_area.width) / 2; @@ -545,7 +547,7 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer, g_object_unref (G_OBJECT (clipboard)); /* render the invalid parts of the icon */ - thunar_gdk_cairo_set_source_pixbuf (cr, icon, icon_area.x, icon_area.y); + thunar_gdk_cairo_set_source_pixbuf (cr, icon, icon_area.x, icon_area.y, scale_factor); cairo_paint_with_alpha (cr, alpha); /* check if we should render an insensitive icon */ @@ -581,25 +583,25 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer, emblem_size = MIN ((2 * icon_renderer->size) / 3, 32); /* check if we have the emblem in the icon theme */ - emblem = thunar_icon_factory_load_icon (icon_factory, lp->data, emblem_size, FALSE); + emblem = thunar_icon_factory_load_icon (icon_factory, lp->data, emblem_size * scale_factor, FALSE); if (G_UNLIKELY (emblem == NULL)) continue; /* determine the dimensions of the emblem */ - emblem_area.width = gdk_pixbuf_get_width (emblem); - emblem_area.height = gdk_pixbuf_get_height (emblem); + emblem_area.width = gdk_pixbuf_get_width (emblem) / scale_factor; + emblem_area.height = gdk_pixbuf_get_height (emblem) / scale_factor; /* shrink insane emblems */ if (G_UNLIKELY (MAX (emblem_area.width, emblem_area.height) > emblem_size)) { /* scale down the emblem */ - temp = exo_gdk_pixbuf_scale_ratio (emblem, emblem_size); + temp = exo_gdk_pixbuf_scale_ratio (emblem, emblem_size * scale_factor); g_object_unref (G_OBJECT (emblem)); emblem = temp; /* determine the size again */ - emblem_area.width = gdk_pixbuf_get_width (emblem); - emblem_area.height = gdk_pixbuf_get_height (emblem); + emblem_area.width = gdk_pixbuf_get_width (emblem) / scale_factor; + emblem_area.height = gdk_pixbuf_get_height (emblem) / scale_factor; } /* determine a good position for the emblem, depending on the position index */ @@ -641,7 +643,7 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer, if (gdk_rectangle_intersect (&clip_area, &emblem_area, NULL)) { /* render the invalid parts of the icon */ - thunar_gdk_cairo_set_source_pixbuf (cr, emblem, emblem_area.x, emblem_area.y); + thunar_gdk_cairo_set_source_pixbuf (cr, emblem, emblem_area.x, emblem_area.y, scale_factor); cairo_paint (cr); /* paint the lighten mask */ diff --git a/thunar/thunar-path-entry.c b/thunar/thunar-path-entry.c index b4813efd4a4ad0f51a21e7e23b22cf72e13ae6d9..534e65d44b6956f766d7d40701c15288031a8d82 100644 --- a/thunar/thunar-path-entry.c +++ b/thunar/thunar-path-entry.c @@ -81,6 +81,9 @@ static void thunar_path_entry_icon_release_event (GtkEntry GtkEntryIconPosition icon_pos, GdkEventButton *event, gpointer user_data); +static void thunar_path_entry_scale_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data); static gboolean thunar_path_entry_motion_notify_event (GtkWidget *widget, GdkEventMotion *event); static gboolean thunar_path_entry_key_press_event (GtkWidget *widget, @@ -275,6 +278,7 @@ thunar_path_entry_init (ThunarPathEntry *path_entry) /* connect the icon signals */ g_signal_connect (G_OBJECT (path_entry), "icon-press", G_CALLBACK (thunar_path_entry_icon_press_event), NULL); g_signal_connect (G_OBJECT (path_entry), "icon-release", G_CALLBACK (thunar_path_entry_icon_release_event), NULL); + g_signal_connect (G_OBJECT (path_entry), "notify::scale-factor", G_CALLBACK (thunar_path_entry_scale_changed), NULL); /* disabled initially */ path_entry->search_mode = FALSE; @@ -424,6 +428,16 @@ thunar_path_entry_icon_release_event (GtkEntry *entry, +static void +thunar_path_entry_scale_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data) +{ + gtk_widget_queue_draw (GTK_WIDGET (object)); +} + + + static gboolean thunar_path_entry_motion_notify_event (GtkWidget *widget, GdkEventMotion *event) diff --git a/thunar/thunar-shortcuts-icon-renderer.c b/thunar/thunar-shortcuts-icon-renderer.c index 879e292b9537b6eb71ed2947a75fa1e19e634b80..60488fefde6d3dd2333e2874fc4c2711782b6677 100644 --- a/thunar/thunar-shortcuts-icon-renderer.c +++ b/thunar/thunar-shortcuts-icon-renderer.c @@ -219,6 +219,7 @@ thunar_shortcuts_icon_renderer_render (GtkCellRenderer *renderer, GdkPixbuf *temp; GIcon *gicon; gdouble alpha; + gint scale_factor; if (!gdk_cairo_get_clip_rectangle (cr, &clip_area)) return; @@ -236,7 +237,8 @@ thunar_shortcuts_icon_renderer_render (GtkCellRenderer *renderer, else gicon = thunar_device_get_icon (shortcuts_icon_renderer->device); - icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme, gicon, cell_area->width, + scale_factor = gtk_widget_get_scale_factor (widget); + icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme, gicon, cell_area->width * scale_factor, GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_FORCE_SIZE); g_object_unref (gicon); @@ -252,20 +254,20 @@ thunar_shortcuts_icon_renderer_render (GtkCellRenderer *renderer, if (G_LIKELY (icon != NULL)) { /* determine the real icon size */ - icon_area.width = gdk_pixbuf_get_width (icon); - icon_area.height = gdk_pixbuf_get_height (icon); + icon_area.width = gdk_pixbuf_get_width (icon) / scale_factor; + icon_area.height = gdk_pixbuf_get_height (icon) / scale_factor; /* scale down the icon on-demand */ if (G_UNLIKELY (icon_area.width > cell_area->width || icon_area.height > cell_area->height)) { /* scale down to fit */ - temp = exo_gdk_pixbuf_scale_down (icon, TRUE, MAX (1, cell_area->width), MAX (1, cell_area->height)); + temp = exo_gdk_pixbuf_scale_down (icon, TRUE, MAX (1, cell_area->width * scale_factor), MAX (1, cell_area->height * scale_factor)); g_object_unref (G_OBJECT (icon)); icon = temp; /* determine the icon dimensions again */ - icon_area.width = gdk_pixbuf_get_width (icon); - icon_area.height = gdk_pixbuf_get_height (icon); + icon_area.width = gdk_pixbuf_get_width (icon) / scale_factor; + icon_area.height = gdk_pixbuf_get_height (icon) / scale_factor; } /* 50% translucent for unmounted volumes */ @@ -282,7 +284,7 @@ thunar_shortcuts_icon_renderer_render (GtkCellRenderer *renderer, if (gdk_rectangle_intersect (&clip_area, &icon_area, NULL)) { /* render the invalid parts of the icon */ - thunar_gdk_cairo_set_source_pixbuf (cr, icon, icon_area.x, icon_area.y); + thunar_gdk_cairo_set_source_pixbuf (cr, icon, icon_area.x, icon_area.y, scale_factor); cairo_paint_with_alpha (cr, alpha); } diff --git a/thunar/thunar-shortcuts-view.c b/thunar/thunar-shortcuts-view.c index 197074e02282b4d25909297af42c91cd3e3bbf17..2069b616cd9f69a8625b89fc6c743cdf8b7a2abf 100644 --- a/thunar/thunar-shortcuts-view.c +++ b/thunar/thunar-shortcuts-view.c @@ -78,6 +78,9 @@ static void thunar_shortcuts_view_set_property (GObjec guint prop_id, const GValue *value, GParamSpec *pspec); +static void thunar_shortcuts_view_scale_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data); static ThunarFile* thunar_shortcuts_view_get_current_directory (ThunarNavigator *navigator); static void thunar_shortcuts_view_set_current_directory (ThunarNavigator *navigator, ThunarFile *current_directory); @@ -344,6 +347,7 @@ thunar_shortcuts_view_init (ThunarShortcutsView *view) "device", THUNAR_SHORTCUTS_MODEL_COLUMN_DEVICE, "visible", THUNAR_SHORTCUTS_MODEL_COLUMN_IS_ITEM, NULL); + g_signal_connect (G_OBJECT (view), "notify::scale-factor", G_CALLBACK (thunar_shortcuts_view_scale_changed), NULL); /* sync the "emblems" property of the icon renderer with the "shortcuts-icon-emblems" preference * and the "size" property of the renderer with the "shortcuts-icon-size" preference. @@ -482,6 +486,16 @@ thunar_shortcuts_view_set_property (GObject *object, +static void +thunar_shortcuts_view_scale_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data) +{ + gtk_widget_queue_draw (GTK_WIDGET (object)); +} + + + static ThunarFile* thunar_shortcuts_view_get_current_directory (ThunarNavigator *navigator) { diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c index a9034b44b4085d5a29ee55d2aafbdddfb8b65a84..312501a793735a202f010c53f5f4a0077405954d 100644 --- a/thunar/thunar-standard-view.c +++ b/thunar/thunar-standard-view.c @@ -120,6 +120,9 @@ static void thunar_standard_view_set_property (GOb guint prop_id, const GValue *value, GParamSpec *pspec); +static void thunar_standard_view_scale_factor_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data); static void thunar_standard_view_realize (GtkWidget *widget); static void thunar_standard_view_unrealize (GtkWidget *widget); static void thunar_standard_view_grab_focus (GtkWidget *widget); @@ -840,6 +843,7 @@ thunar_standard_view_init (ThunarStandardView *standard_view) g_object_bind_property (G_OBJECT (standard_view), "zoom-level", G_OBJECT (standard_view->icon_renderer), "size", G_BINDING_SYNC_CREATE); g_object_bind_property (G_OBJECT (standard_view->icon_renderer), "size", G_OBJECT (standard_view->priv->thumbnailer), "thumbnail-size", G_BINDING_SYNC_CREATE); g_object_bind_property (G_OBJECT (standard_view->preferences), "misc-highlighting-enabled", G_OBJECT (standard_view->icon_renderer), "highlighting-enabled", G_BINDING_SYNC_CREATE); + g_signal_connect (G_OBJECT (standard_view), "notify::scale-factor", G_CALLBACK (thunar_standard_view_scale_factor_changed), NULL); /* setup the name renderer */ standard_view->name_renderer = thunar_text_renderer_new (); @@ -1246,6 +1250,16 @@ thunar_standard_view_set_property (GObject *object, +static void +thunar_standard_view_scale_factor_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data) +{ + gtk_widget_queue_draw (GTK_WIDGET (object)); +} + + + static void thunar_standard_view_realize (GtkWidget *widget) { diff --git a/thunar/thunar-tree-view.c b/thunar/thunar-tree-view.c index 42bd61e28c9bc519a4c591e87b3fdb5334f25f4e..5020502ea3284ef8caf20d17b20aa9e6f9357e24 100644 --- a/thunar/thunar-tree-view.c +++ b/thunar/thunar-tree-view.c @@ -89,6 +89,9 @@ static void thunar_tree_view_set_property (G guint prop_id, const GValue *value, GParamSpec *pspec); +static void thunar_tree_view_scale_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data); static ThunarFile *thunar_tree_view_get_current_directory (ThunarNavigator *navigator); static void thunar_tree_view_set_current_directory (ThunarNavigator *navigator, ThunarFile *current_directory); @@ -381,6 +384,7 @@ thunar_tree_view_init (ThunarTreeView *view) "file", THUNAR_TREE_MODEL_COLUMN_FILE, "device", THUNAR_TREE_MODEL_COLUMN_DEVICE, NULL); + g_signal_connect (G_OBJECT (view), "notify::scale-factor", G_CALLBACK (thunar_tree_view_scale_changed), NULL); /* sync the "emblems" property of the icon renderer with the "tree-icon-emblems" preference * and the "size" property of the renderer with the "tree-icon-size" preference. @@ -513,6 +517,16 @@ thunar_tree_view_set_property (GObject *object, +static void +thunar_tree_view_scale_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data) +{ + gtk_widget_queue_draw (GTK_WIDGET (object)); +} + + + static ThunarFile* thunar_tree_view_get_current_directory (ThunarNavigator *navigator) {