Bug 468203 - GTK3 window buttons are too big and blurry on Wayland with Breeze GTK
Summary: GTK3 window buttons are too big and blurry on Wayland with Breeze GTK
Status: RESOLVED FIXED
Alias: None
Product: Breeze
Classification: Plasma
Component: gtk theme (show other bugs)
Version: 5.27.4
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords: regression, wayland
Depends on:
Blocks:
 
Reported: 2023-04-06 11:34 UTC by priv.luk
Modified: 2023-05-27 11:28 UTC (History)
13 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.27.5


Attachments
big window buttons (11.10 KB, image/png)
2023-04-06 11:34 UTC, priv.luk
Details
correct window buttons (10.53 KB, image/png)
2023-04-06 11:46 UTC, priv.luk
Details
chromium f38 (922.09 KB, image/png)
2023-04-07 14:06 UTC, priv.luk
Details

Note You need to log in before you can comment on or make changes to this bug.
Description priv.luk 2023-04-06 11:34:40 UTC
Created attachment 157894 [details]
big window buttons

SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***
After upgrading to breeze-gtk-*-5.27.4, window buttons are suddenly much larger and blurry in certain applications

STEPS TO REPRODUCE
1. Upgrade to breeze-gtk-*-5.27.4
2. Launch Chrome or Tilix
3. Notice that window close/minimize/maximize buttons are very big

OBSERVED RESULT
Buttons are too big and blurry

EXPECTED RESULT
Buttons are nice and small

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Fedora 38
(available in About System)
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.104.0
Qt Version: 5.15.8

ADDITIONAL INFORMATION
Reverting this change https://invent.kde.org/plasma/breeze-gtk/-/commit/59448164f7df462ae4a2c1119f6be59146d60399 fixes it.
Comment 1 priv.luk 2023-04-06 11:46:49 UTC
Created attachment 157895 [details]
correct window buttons
Comment 2 Nate Graham 2023-04-06 15:44:29 UTC
Weird, I saw that in an earlier version of the work before it was merged, but it had been fixed by the time I approved it. Fushan, would you mind investigating?
Comment 3 Fushan Wen 2023-04-07 06:39:13 UTC
What screen scale are you using?
Comment 4 priv.luk 2023-04-07 07:27:01 UTC
(In reply to Fushan Wen from comment #3)
> What screen scale are you using?

1080p; 100% scalling.
Comment 5 Fushan Wen 2023-04-07 07:32:11 UTC
Are you using Wayland?
Comment 6 priv.luk 2023-04-07 07:32:40 UTC
(In reply to Fushan Wen from comment #5)
> Are you using Wayland?

X11
Comment 7 Yannick 2023-04-07 09:32:28 UTC
Same issue here with breeze-gtk 5.27.4 on Wayland, GTK CSD window buttons are big and blurry.
Comment 8 Fushan Wen 2023-04-07 09:41:39 UTC
I can only reproduce on Wayland. This seems also related to the font settings
Comment 9 Fushan Wen 2023-04-07 13:39:01 UTC
Unable to reproduce on X11
Comment 10 priv.luk 2023-04-07 14:06:17 UTC
(In reply to Fushan Wen from comment #9)
> Unable to reproduce on X11

I can reproduce this issue on clean up to date F38 install with Chromium theme set to GTK.
Comment 11 priv.luk 2023-04-07 14:06:29 UTC
Created attachment 157924 [details]
chromium f38
Comment 12 Fushan Wen 2023-04-07 14:11:08 UTC
I can't reproduce with Tilix on X11.
Comment 13 Fushan Wen 2023-04-07 14:12:15 UTC
Git commit bfe2ce620d395c943bb13a646295948b5bffbcc3 by Fushan Wen.
Committed on 07/04/2023 at 14:10.
Pushed by fusionfuture into branch 'master'.

gtk3: restore old icon size for titlebutton

`background-size` results in different sizes on X11 and Wayland.
FIXED-IN: 5.27.5

M  +3    -3    src/gtk3/widgets/_window_decorations.scss

https://invent.kde.org/plasma/breeze-gtk/commit/bfe2ce620d395c943bb13a646295948b5bffbcc3
Comment 14 Fushan Wen 2023-04-07 14:12:48 UTC
Git commit c5e757a198321208c6b1e99313652577c263ecc0 by Fushan Wen.
Committed on 07/04/2023 at 14:12.
Pushed by fusionfuture into branch 'Plasma/5.27'.

gtk3: restore old icon size for titlebutton

`background-size` results in different sizes on X11 and Wayland.
FIXED-IN: 5.27.5


(cherry picked from commit bfe2ce620d395c943bb13a646295948b5bffbcc3)

M  +3    -3    src/gtk3/widgets/_window_decorations.scss

https://invent.kde.org/plasma/breeze-gtk/commit/c5e757a198321208c6b1e99313652577c263ecc0
Comment 15 Fushan Wen 2023-04-07 16:34:55 UTC
Git commit e9384150d8e41dd9c869f5f502e02c70a5c6f002 by Fushan Wen.
Committed on 07/04/2023 at 16:33.
Pushed by fusionfuture into branch 'Plasma/5.27'.

kcm: notify changes in kcmfonts when global scale changes

Otherwise kde-gtk-config will use the old font DPI value.

M  +2    -2    kcm/kcm.cpp

https://invent.kde.org/plasma/kscreen/commit/e9384150d8e41dd9c869f5f502e02c70a5c6f002
Comment 16 Fushan Wen 2023-04-07 16:35:28 UTC
Git commit 52eb9d01b94eeece64044c5159d965eec7f39079 by Fushan Wen.
Committed on 07/04/2023 at 16:30.
Pushed by fusionfuture into branch 'Plasma/5.27'.

kded: don't update text scale on kdeglobals change events

setTextScale() will be called in onKCMFontsSettingsChange

M  +1    -1    kded/gtkconfig.cpp

https://invent.kde.org/plasma/kde-gtk-config/commit/52eb9d01b94eeece64044c5159d965eec7f39079
Comment 17 Bug Janitor Service 2023-04-07 16:36:59 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kscreen/-/merge_requests/201
Comment 18 Fushan Wen 2023-04-07 16:37:24 UTC
Git commit 533e397b2dc331d475db0b2c22c085dea70e93d7 by Fushan Wen.
Committed on 07/04/2023 at 16:37.
Pushed by fusionfuture into branch 'master'.

kded: don't update text scale on kdeglobals change events

setTextScale() will be called in onKCMFontsSettingsChange


(cherry picked from commit 52eb9d01b94eeece64044c5159d965eec7f39079)

M  +1    -1    kded/gtkconfig.cpp

https://invent.kde.org/plasma/kde-gtk-config/commit/533e397b2dc331d475db0b2c22c085dea70e93d7
Comment 19 Fushan Wen 2023-04-07 16:39:54 UTC
Git commit f9f88c5336063ba853190f790a5c8347afa49afb by Fushan Wen.
Committed on 07/04/2023 at 16:36.
Pushed by fusionfuture into branch 'master'.

kcm: notify changes in kcmfonts when global scale changes

Otherwise kde-gtk-config will use the old font DPI value.


(cherry picked from commit e9384150d8e41dd9c869f5f502e02c70a5c6f002)

M  +2    -2    kcm/kcm.cpp

https://invent.kde.org/plasma/kscreen/commit/f9f88c5336063ba853190f790a5c8347afa49afb
Comment 20 Synthetic451 2023-04-07 17:06:38 UTC
I can reproduce this issue on X11 as well on 100% scaling. Both Firefox and Pamac show this issue, except on Firefox it actually looks blurry whereas in Pamac (which I believe is a native GTK app) does proper scaling. Does screen size matter in this case for reproducibility? I have a 4k screen.

Arch Linux
Plasma 5.27.4
Frameworks 5.104.0
Qt 5.15.8
Nvidia 3090 w/ 530.41.03 drivers
Comment 21 Fushan Wen 2023-04-07 17:26:04 UTC
For anyone interested, I think this is still a bug in GTK3(Wayland only) and GTK4. See `gtk_css_image_surface_draw` for example, image_width and image_height are hardcoded values (For GTK3 it's 18 on Wayland, 50 on X11), which means when the size of a background image exceeds 18x18 on Wayland, it will be blurry.


```
static void
gtk_css_image_surface_draw (GtkCssImage *image,
                            cairo_t     *cr,
                            double       width,
                            double       height)
{
  GtkCssImageSurface *surface = GTK_CSS_IMAGE_SURFACE (image);
  int image_width, image_height;

  image_width = cairo_image_surface_get_width (surface->surface);
  image_height = cairo_image_surface_get_height (surface->surface);

  if (image_width == 0 || image_height == 0 || width <= 0 || height <= 0)
    return;

  /* Update cache image if size is different */
  if (surface->cache == NULL   ||
      ABS (width - surface->width) > 0.001 ||
      ABS (height - surface->height) > 0.001)
    {
      double xscale, yscale;
      cairo_t *cache;

      /* We need the device scale (HiDPI mode) to calculate the proper size in
       * pixels for the image surface and set the cache device scale
       */
      cairo_surface_get_device_scale (cairo_get_target (cr), &xscale, &yscale);

      /* Save original size to preserve precision */
      surface->width = width;
      surface->height = height;

      /* Destroy old cache if any */
      g_clear_pointer (&surface->cache, cairo_surface_destroy);

      /* Image big enough to contain scaled image with subpixel precision */
      surface->cache = cairo_surface_create_similar_image (surface->surface,
                                                           CAIRO_FORMAT_ARGB32,
                                                           ceil (width*xscale),
                                                           ceil (height*yscale));
      cairo_surface_set_device_scale (surface->cache, xscale, yscale);
      cache = cairo_create (surface->cache);
      cairo_rectangle (cache, 0, 0, width, height);
      cairo_scale (cache, width / image_width, height / image_height);
      cairo_set_source_surface (cache, surface->surface, 0, 0);
      cairo_fill (cache);

      cairo_destroy (cache);
    }

  cairo_rectangle (cr, 0, 0, width, height);
  cairo_set_source_surface (cr, surface->cache ? surface->cache : surface->surface, 0, 0);
  cairo_fill (cr);
}
```
Comment 22 Bug Janitor Service 2023-04-07 19:07:41 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/breeze-gtk/-/merge_requests/81
Comment 23 Fushan Wen 2023-04-10 16:51:19 UTC
Git commit a0bdf9e161b57943c5438e81a251a39792d6747c by Fushan Wen.
Committed on 08/04/2023 at 09:01.
Pushed by fusionfuture into branch 'master'.

assets: resize viewports of titlebutton SVGs

GTK reads SVG to pixmap and creates a cairo surface for an image, and
the size of an image surface used by cairo depends
on the size of SVG viewport but not the size from `background-size`
property. When drawing background images, GTK will scale the pixmap by
width in `background-size` / viewport width, so when the viewport is
smaller than `background-size`, the background image will look blurry.

By making the viewports larger, titlebuttons in GTK
apps (especially in GTK3 Wayland and GTK4) will look much sharper.

M  +13   -3    src/assets/breeze-close-active-symbolic.svg
M  +20   -4    src/assets/breeze-close-hover-symbolic.svg
M  +13   -3    src/assets/breeze-close-symbolic.svg
M  +13   -3    src/assets/breeze-maximize-active-symbolic.svg
M  +12   -3    src/assets/breeze-maximize-hover-symbolic.svg
M  +18   -3    src/assets/breeze-maximize-symbolic.svg
M  +13   -3    src/assets/breeze-maximized-active-symbolic.svg
M  +12   -3    src/assets/breeze-maximized-hover-symbolic.svg
M  +18   -3    src/assets/breeze-maximized-symbolic.svg
M  +13   -3    src/assets/breeze-minimize-active-symbolic.svg
M  +12   -3    src/assets/breeze-minimize-hover-symbolic.svg
M  +18   -3    src/assets/breeze-minimize-symbolic.svg

https://invent.kde.org/plasma/breeze-gtk/commit/a0bdf9e161b57943c5438e81a251a39792d6747c
Comment 24 Fushan Wen 2023-04-10 16:52:49 UTC
Git commit 56216f86f3e15231a303b3abad70c46ed14535ad by Fushan Wen.
Committed on 10/04/2023 at 16:52.
Pushed by fusionfuture into branch 'Plasma/5.27'.

assets: resize viewports of titlebutton SVGs

GTK reads SVG to pixmap and creates a cairo surface for an image, and
the size of an image surface used by cairo depends
on the size of SVG viewport but not the size from `background-size`
property. When drawing background images, GTK will scale the pixmap by
width in `background-size` / viewport width, so when the viewport is
smaller than `background-size`, the background image will look blurry.

By making the viewports larger, titlebuttons in GTK
apps (especially in GTK3 Wayland and GTK4) will look much sharper.


(cherry picked from commit a0bdf9e161b57943c5438e81a251a39792d6747c)

M  +13   -3    src/assets/breeze-close-active-symbolic.svg
M  +20   -4    src/assets/breeze-close-hover-symbolic.svg
M  +13   -3    src/assets/breeze-close-symbolic.svg
M  +13   -3    src/assets/breeze-maximize-active-symbolic.svg
M  +12   -3    src/assets/breeze-maximize-hover-symbolic.svg
M  +18   -3    src/assets/breeze-maximize-symbolic.svg
M  +13   -3    src/assets/breeze-maximized-active-symbolic.svg
M  +12   -3    src/assets/breeze-maximized-hover-symbolic.svg
M  +18   -3    src/assets/breeze-maximized-symbolic.svg
M  +13   -3    src/assets/breeze-minimize-active-symbolic.svg
M  +12   -3    src/assets/breeze-minimize-hover-symbolic.svg
M  +18   -3    src/assets/breeze-minimize-symbolic.svg

https://invent.kde.org/plasma/breeze-gtk/commit/56216f86f3e15231a303b3abad70c46ed14535ad
Comment 25 popov895 2023-04-12 22:04:59 UTC
Not fully fixed: the spacing between the buttons is still huge.
Comment 26 Fushan Wen 2023-04-12 23:52:18 UTC
Not related to this bugreport, please open a new one.
Comment 27 Fushan Wen 2023-04-13 01:10:33 UTC
Git commit 177ba74a2d9ca7d6d64c55c1975cb545e68cfac2 by Fushan Wen.
Committed on 13/04/2023 at 01:10.
Pushed by fusionfuture into branch 'Plasma/5.27'.

🍒gtk3/titlebutton: reduce right margin of {max/minimize} button

(cherry picked from commit 14f810c5ab5a17daa31b77acb28d302a8edc60d1)

M  +10   -0    src/gtk3/widgets/_window_decorations.scss

https://invent.kde.org/plasma/breeze-gtk/commit/177ba74a2d9ca7d6d64c55c1975cb545e68cfac2
Comment 28 Fushan Wen 2023-04-13 01:10:59 UTC
After nth thought, it's not worth a new bugreport as the fix is quite small.
Comment 29 kocelfc 2023-04-22 08:01:12 UTC
I have applied all of the supposedly commits that should've fixed the issue, but the buttons on Firefox for example are still messed up - blurry and the minimize and maximize buttons are cut off at the right.