diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-11-27 08:59:21 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-11-27 08:59:21 -0500 |
commit | d1012c497bab10d55797ea4649c0c7a002167864 (patch) | |
tree | 77b95ac68c60cb573415f7c3b8b370f1715fccc9 /swaybg | |
parent | f8f0bcd4d3d607c476a8a0ce301232b72a301ef3 (diff) |
Style enforcement
Diffstat (limited to 'swaybg')
-rw-r--r-- | swaybg/main.c | 117 |
1 files changed, 58 insertions, 59 deletions
diff --git a/swaybg/main.c b/swaybg/main.c index feb9002e..3b344079 100644 --- a/swaybg/main.c +++ b/swaybg/main.c @@ -80,68 +80,67 @@ int main(int argc, const char **argv) { for (i = 0; i < surfaces->length; ++i) { struct window *window = surfaces->items[i]; if (window_prerender(window) && window->cairo) { - switch (scaling_mode) { - case SCALING_MODE_STRETCH: - cairo_scale(window->cairo, - (double) window->width / width, - (double) window->height / height); - cairo_set_source_surface(window->cairo, image, 0, 0); - break; - case SCALING_MODE_FILL: - { - double window_ratio = (double) window->width / window->height; - double bg_ratio = width / height; - - if (window_ratio > bg_ratio) { - double scale = (double) window->width / width; - cairo_scale(window->cairo, scale, scale); - cairo_set_source_surface(window->cairo, image, - 0, - (double) window->height/2 / scale - height/2); - } else { - double scale = (double) window->height / height; - cairo_scale(window->cairo, scale, scale); - cairo_set_source_surface(window->cairo, image, - (double) window->width/2 / scale - width/2, - 0); - } - } - break; - case SCALING_MODE_FIT: - { - double window_ratio = (double) window->width / window->height; - double bg_ratio = width / height; - - if (window_ratio > bg_ratio) { - double scale = (double) window->height / height; - cairo_scale(window->cairo, scale, scale); - cairo_set_source_surface(window->cairo, image, - (double) window->width/2 / scale - width/2, - 0); - } else { - double scale = (double) window->width / width; - cairo_scale(window->cairo, scale, scale); - cairo_set_source_surface(window->cairo, image, - 0, - (double) window->height/2 / scale - height/2); - } + case SCALING_MODE_STRETCH: + cairo_scale(window->cairo, + (double) window->width / width, + (double) window->height / height); + cairo_set_source_surface(window->cairo, image, 0, 0); + break; + case SCALING_MODE_FILL: + { + double window_ratio = (double) window->width / window->height; + double bg_ratio = width / height; + + if (window_ratio > bg_ratio) { + double scale = (double) window->width / width; + cairo_scale(window->cairo, scale, scale); + cairo_set_source_surface(window->cairo, image, + 0, + (double) window->height/2 / scale - height/2); + } else { + double scale = (double) window->height / height; + cairo_scale(window->cairo, scale, scale); + cairo_set_source_surface(window->cairo, image, + (double) window->width/2 / scale - width/2, + 0); } - break; - case SCALING_MODE_CENTER: - cairo_set_source_surface(window->cairo, image, - (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; + case SCALING_MODE_FIT: + { + double window_ratio = (double) window->width / window->height; + double bg_ratio = width / height; + + if (window_ratio > bg_ratio) { + double scale = (double) window->height / height; + cairo_scale(window->cairo, scale, scale); + cairo_set_source_surface(window->cairo, image, + (double) window->width/2 / scale - width/2, + 0); + } else { + double scale = (double) window->width / width; + cairo_scale(window->cairo, scale, scale); + cairo_set_source_surface(window->cairo, image, + 0, + (double) window->height/2 / scale - height/2); } - break; - default: - sway_abort("Scaling mode '%s' not implemented yet!", scaling_mode_str); + } + break; + case SCALING_MODE_CENTER: + cairo_set_source_surface(window->cairo, image, + (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); } cairo_paint(window->cairo); |