aboutsummaryrefslogtreecommitdiff
path: root/swaybg
diff options
context:
space:
mode:
authorChristoph Gysin <christoph.gysin@gmail.com>2015-11-25 20:53:13 +0200
committerChristoph Gysin <christoph.gysin@gmail.com>2015-11-25 22:31:35 +0200
commit621062f18d3511a2b0fae0a18f168e07f1ff1b0d (patch)
treee0e3e1144716ed7536ec46a3201db98018581a8f /swaybg
parent81a87ec7a721b2f14c129f86b8403cce8c434435 (diff)
swaybg: implement scaling mode "center"
Diffstat (limited to 'swaybg')
-rw-r--r--swaybg/main.c8
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);
}