diff options
Diffstat (limited to 'swaybg')
-rw-r--r-- | swaybg/main.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/swaybg/main.c b/swaybg/main.c index a85c56bd..481fdf9a 100644 --- a/swaybg/main.c +++ b/swaybg/main.c @@ -15,6 +15,7 @@ struct registry *registry; enum scaling_mode_t { SCALING_MODE_STRETCH, SCALING_MODE_FILL, + SCALING_MODE_CENTER, }; void sway_terminate(void) { @@ -64,6 +65,8 @@ int main(int argc, const char **argv) { scaling_mode = SCALING_MODE_STRETCH; } else if (strcmp(scaling_mode_str, "fill") == 0) { scaling_mode = SCALING_MODE_FILL; + } else if (strcmp(scaling_mode_str, "center") == 0) { + scaling_mode = SCALING_MODE_CENTER; } else { sway_abort("Unsupported scaling mode: %s", scaling_mode_str); } @@ -99,6 +102,11 @@ int main(int argc, const char **argv) { } } 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; default: sway_abort("Scaling mode '%s' not implemented yet!", scaling_mode_str); } |