From 8630bc37524434096165acff5493eff399387df2 Mon Sep 17 00:00:00 2001 From: Christoph Gysin Date: Wed, 25 Nov 2015 21:07:34 +0200 Subject: [PATCH] swaybg: implement scaling mode "tile" --- swaybg/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/swaybg/main.c b/swaybg/main.c index 481fdf9a..7cfe1320 100644 --- a/swaybg/main.c +++ b/swaybg/main.c @@ -16,6 +16,7 @@ enum scaling_mode_t { SCALING_MODE_STRETCH, SCALING_MODE_FILL, SCALING_MODE_CENTER, + SCALING_MODE_TILE, }; void sway_terminate(void) { @@ -67,6 +68,8 @@ int main(int argc, const char **argv) { scaling_mode = SCALING_MODE_FILL; } else if (strcmp(scaling_mode_str, "center") == 0) { scaling_mode = SCALING_MODE_CENTER; + } else if (strcmp(scaling_mode_str, "tile") == 0) { + scaling_mode = SCALING_MODE_TILE; } else { sway_abort("Unsupported scaling mode: %s", scaling_mode_str); } @@ -107,6 +110,13 @@ int main(int argc, const char **argv) { (double) window->width/2 - width/2, (double) window->height/2 - height/2); break; + case SCALING_MODE_TILE: + { + cairo_pattern_t *pattern = cairo_pattern_create_for_surface(image); + cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT); + cairo_set_source(window->cairo, pattern); + } + break; default: sway_abort("Scaling mode '%s' not implemented yet!", scaling_mode_str); }