theme: use gtk_render_icon_suface to paint button icon
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Fri, 30 Mar 2018 20:13:41 +0000 (14:13 -0600)
committerSimon McVittie <smcv@debian.org>
Tue, 31 Jul 2018 14:35:03 +0000 (15:35 +0100)
This will properly take care of the icon transformations
and of the shadow.

Fixes #100

Bug: https://gitlab.gnome.org/GNOME/mutter/issues/100
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/mutter/+bug/1764558
Forwarded: yes, https://gitlab.gnome.org/GNOME/mutter/merge_requests/62

Gbp-Pq: Name theme-use-gtk_render_icon_suface-to-paint-button-icon.patch

src/ui/theme.c

index c0bb9b66ad543d029dae8e1b9b26651bf2e584f0..c88ae54070b3f58e08aca394eb5f78ab9c391d03 100644 (file)
@@ -890,21 +890,11 @@ meta_frame_layout_draw_with_style (MetaFrameLayout         *layout,
 
           if (surface)
             {
-              float width, height;
-              int x, y;
-
-              width = cairo_image_surface_get_width (surface) / scale;
-              height = cairo_image_surface_get_height (surface) / scale;
-              x = button_rect.x + (button_rect.width - layout->icon_size) / 2;
-              y = button_rect.y + (button_rect.height - layout->icon_size) / 2;
-
-              cairo_translate (cr, x, y);
-              cairo_scale (cr,
-                           layout->icon_size / width,
-                           layout->icon_size / height);
-              cairo_set_source_surface (cr, surface, 0, 0);
-              cairo_paint (cr);
+              double x, y;
+              x = button_rect.x + (button_rect.width - layout->icon_size) / 2.0;
+              y = button_rect.y + (button_rect.height - layout->icon_size) / 2.0;
 
+              gtk_render_icon_surface (style, cr, surface, x, y);
               cairo_surface_destroy (surface);
             }
         }