diff options
author | António Fernandes <antoniof@gnome.org> | 2022-03-16 17:00:53 +0000 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2022-03-17 09:34:07 +0000 |
commit | d5aeba0f2fb5c66b23fcc5ad308f32d46d53f8d8 (patch) | |
tree | f3c3a22351211ffd0c7cf9831614d554bc90dce4 | |
parent | eba4d167aaa0ad8458204dc23b7590e99d376efb (diff) | |
download | nautilus-d5aeba0f2fb5c66b23fcc5ad308f32d46d53f8d8.tar.gz |
list-view: Fix overgrown thumbnail frame in HiDPI
We draw thumbnail shadow and background which matches the thumbnail
shape using the thumbnail surface width and height for measurement.
This breaks for HiDPI where measurements should be passed in logical
pixels (a.k.a. device-space units in cairo docs), resulting in
excessively large thumbnail frames.
Divide pixel dimensions by device scale factor to get the logical
measures and fix this bug.
Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2191
-rw-r--r-- | src/nautilus-list-view.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c index bb7fbe3ee..9cfd50386 100644 --- a/src/nautilus-list-view.c +++ b/src/nautilus-list-view.c @@ -1666,6 +1666,7 @@ icon_cell_data_func (GtkTreeViewColumn *column, { cairo_surface_t *new_surface; cairo_t *cr; + double x_scale, y_scale; int w, h; /* The shadow extends 1px up, 3px down, and 2px left and right. For that @@ -1691,9 +1692,13 @@ icon_cell_data_func (GtkTreeViewColumn *column, * | | : : * +-----------------------+ : **** --> Blur shadow : * w + 4 '.......................' + * + * In HiDPI, our thumbnails are in data pixels, so we must divide by + * device scale factor to get the logical draw units. */ - w = cairo_image_surface_get_width (surface); - h = cairo_image_surface_get_height (surface); + cairo_surface_get_device_scale (surface, &x_scale, &y_scale); + w = cairo_image_surface_get_width (surface) / x_scale; + h = cairo_image_surface_get_height (surface) / y_scale; new_surface = cairo_surface_create_similar (surface, CAIRO_CONTENT_COLOR_ALPHA, |