diff options
author | emersion <contact@emersion.fr> | 2018-04-03 16:56:12 -0400 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-04-03 16:56:12 -0400 |
commit | 6929124cef2af533b15e93babb98fcd2fc3df471 (patch) | |
tree | 3d43aa04e4c9d89c92477621dc0fba19dc3c9f55 /swaybg/main.c | |
parent | 9b4f8637a93258157245700a4fd4f7e0eefc86a3 (diff) |
swaybg: rename w{width,height} to buffer_{width,height}
Diffstat (limited to 'swaybg/main.c')
-rw-r--r-- | swaybg/main.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/swaybg/main.c b/swaybg/main.c index 053225bd..25a1d73a 100644 --- a/swaybg/main.c +++ b/swaybg/main.c @@ -75,52 +75,53 @@ static void render_image(struct swaybg_state *state) { cairo_surface_t *image = state->context.image; double width = cairo_image_surface_get_width(image); double height = cairo_image_surface_get_height(image); - int wwidth = state->width * state->scale; - int wheight = state->height * state->scale; + int buffer_width = state->width * state->scale; + int buffer_height = state->height * state->scale; switch (state->args->mode) { case BACKGROUND_MODE_STRETCH: - cairo_scale(cairo, (double)wwidth / width, (double)wheight / height); + cairo_scale(cairo, (double)buffer_width / width, + (double)buffer_height / height); cairo_set_source_surface(cairo, image, 0, 0); break; case BACKGROUND_MODE_FILL: { - double window_ratio = (double)wwidth / wheight; + double window_ratio = (double)buffer_width / buffer_height; double bg_ratio = width / height; if (window_ratio > bg_ratio) { - double scale = (double)wwidth / width; + double scale = (double)buffer_width / width; cairo_scale(cairo, scale, scale); cairo_set_source_surface(cairo, image, - 0, (double)wheight / 2 / scale - height / 2); + 0, (double)buffer_height / 2 / scale - height / 2); } else { - double scale = (double)wheight / height; + double scale = (double)buffer_height / height; cairo_scale(cairo, scale, scale); cairo_set_source_surface(cairo, image, - (double)wwidth / 2 / scale - width / 2, 0); + (double)buffer_width / 2 / scale - width / 2, 0); } break; } case BACKGROUND_MODE_FIT: { - double window_ratio = (double)wwidth / wheight; + double window_ratio = (double)buffer_width / buffer_height; double bg_ratio = width / height; if (window_ratio > bg_ratio) { - double scale = (double)wheight / height; + double scale = (double)buffer_height / height; cairo_scale(cairo, scale, scale); cairo_set_source_surface(cairo, image, - (double)wwidth / 2 / scale - width / 2, 0); + (double)buffer_width / 2 / scale - width / 2, 0); } else { - double scale = (double)wwidth / width; + double scale = (double)buffer_width / width; cairo_scale(cairo, scale, scale); cairo_set_source_surface(cairo, image, - 0, (double)wheight / 2 / scale - height / 2); + 0, (double)buffer_height / 2 / scale - height / 2); } break; } case BACKGROUND_MODE_CENTER: cairo_set_source_surface(cairo, image, - (double)wwidth / 2 - width / 2, - (double)wheight / 2 - height / 2); + (double)buffer_width / 2 - width / 2, + (double)buffer_height / 2 - height / 2); break; case BACKGROUND_MODE_TILE: { cairo_pattern_t *pattern = cairo_pattern_create_for_surface(image); |