[nautilus/2191-botched-thumbnails-on-hidpi-in-tree-view-in-42] list-view: Fix overgrown thumbnail frame in HiDPI
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/2191-botched-thumbnails-on-hidpi-in-tree-view-in-42] list-view: Fix overgrown thumbnail frame in HiDPI
- Date: Wed, 16 Mar 2022 17:15:19 +0000 (UTC)
commit a198c0657e49526f5f733fc969f85316465072c7
Author: António Fernandes <antoniof gnome org>
Date: Wed Mar 16 17:00:53 2022 +0000
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
src/nautilus-list-view.c | 9 +++++++--
1 file 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]