aboutsummaryrefslogtreecommitdiffstats
path: root/common/background-image.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-09-23 15:17:36 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-09-23 15:17:36 -0400
commit9ea99a5d367c2f98bfd4c70cb00481c029c7b878 (patch)
treedcea2c0275a68f8eef6d94bfabcbec7c1f4ad46e /common/background-image.c
parentMerge pull request #2696 from RyanDwyer/fix-gtkmenubar (diff)
downloadsway-9ea99a5d367c2f98bfd4c70cb00481c029c7b878.tar.gz
sway-9ea99a5d367c2f98bfd4c70cb00481c029c7b878.tar.zst
sway-9ea99a5d367c2f98bfd4c70cb00481c029c7b878.zip
swaybg: fix increasingly smaller bg on hotplug
render_background_image alters the scale that cairo uses. Depending on the image mode, resolution, and image size, this may cause the surface to be rendered increasingly smaller. By calling cairo_save and cairo_restore, any changes to the cairo settings by the function are not kept as a side effect. The surface that swaybg uses is also now cleared before rendering a frame. This is needed to avoid artifacts on resolution or scale changes with certain combinations of image modes, resolutions, and image sizes. This was also part of the increasingly smaller background visual since it made it so it was not obvious the region being rendered to was smaller and caused an increasing number of smaller images to be appear for each hotplug.
Diffstat (limited to 'common/background-image.c')
-rw-r--r--common/background-image.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/common/background-image.c b/common/background-image.c
index f3d2551e..5ede55e3 100644
--- a/common/background-image.c
+++ b/common/background-image.c
@@ -58,6 +58,7 @@ void render_background_image(cairo_t *cairo, cairo_surface_t *image,
58 double width = cairo_image_surface_get_width(image); 58 double width = cairo_image_surface_get_width(image);
59 double height = cairo_image_surface_get_height(image); 59 double height = cairo_image_surface_get_height(image);
60 60
61 cairo_save(cairo);
61 switch (mode) { 62 switch (mode) {
62 case BACKGROUND_MODE_STRETCH: 63 case BACKGROUND_MODE_STRETCH:
63 cairo_scale(cairo, 64 cairo_scale(cairo,
@@ -116,4 +117,5 @@ void render_background_image(cairo_t *cairo, cairo_surface_t *image,
116 break; 117 break;
117 } 118 }
118 cairo_paint(cairo); 119 cairo_paint(cairo);
120 cairo_restore(cairo);
119} 121}