summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Ashworth <bosrsf04@gmail.com>2018-09-23 15:17:36 -0400
committerBrian Ashworth <bosrsf04@gmail.com>2018-09-23 15:17:36 -0400
commit8598282170309732c98ac45ea8d8b5ea5aaa517c (patch)
treed5b0e6463025d1c40442f151926fe6d116c43135
parent835d246e5b561b99993c66e885cecafd38ff78f5 (diff)
downloadswaybg-8598282170309732c98ac45ea8d8b5ea5aaa517c.tar.gz
swaybg-8598282170309732c98ac45ea8d8b5ea5aaa517c.tar.bz2
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.
-rw-r--r--main.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/main.c b/main.c
index 5b0d045..742669e 100644
--- a/main.c
+++ b/main.c
@@ -73,6 +73,10 @@ static void render_frame(struct swaybg_state *state) {
return;
}
cairo_t *cairo = state->current_buffer->cairo;
+ cairo_save(cairo);
+ cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR);
+ cairo_paint(cairo);
+ cairo_restore(cairo);
if (state->args->mode == BACKGROUND_MODE_SOLID_COLOR) {
cairo_set_source_u32(cairo, state->context.color);
cairo_paint(cairo);