summaryrefslogtreecommitdiffstats
path: root/swaybg
diff options
context:
space:
mode:
authorLibravatar Christoph Gysin <christoph.gysin@gmail.com>2015-11-25 20:53:13 +0200
committerLibravatar Christoph Gysin <christoph.gysin@gmail.com>2015-11-25 22:31:35 +0200
commit621062f18d3511a2b0fae0a18f168e07f1ff1b0d (patch)
treee0e3e1144716ed7536ec46a3201db98018581a8f /swaybg
parentswaybg: implement scaling mode "fill" (diff)
downloadsway-621062f18d3511a2b0fae0a18f168e07f1ff1b0d.tar.gz
sway-621062f18d3511a2b0fae0a18f168e07f1ff1b0d.tar.zst
sway-621062f18d3511a2b0fae0a18f168e07f1ff1b0d.zip
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;
15enum scaling_mode_t { 15enum scaling_mode_t {
16 SCALING_MODE_STRETCH, 16 SCALING_MODE_STRETCH,
17 SCALING_MODE_FILL, 17 SCALING_MODE_FILL,
18 SCALING_MODE_CENTER,
18}; 19};
19 20
20void sway_terminate(void) { 21void sway_terminate(void) {
@@ -64,6 +65,8 @@ int main(int argc, const char **argv) {
64 scaling_mode = SCALING_MODE_STRETCH; 65 scaling_mode = SCALING_MODE_STRETCH;
65 } else if (strcmp(scaling_mode_str, "fill") == 0) { 66 } else if (strcmp(scaling_mode_str, "fill") == 0) {
66 scaling_mode = SCALING_MODE_FILL; 67 scaling_mode = SCALING_MODE_FILL;
68 } else if (strcmp(scaling_mode_str, "center") == 0) {
69 scaling_mode = SCALING_MODE_CENTER;
67 } else { 70 } else {
68 sway_abort("Unsupported scaling mode: %s", scaling_mode_str); 71 sway_abort("Unsupported scaling mode: %s", scaling_mode_str);
69 } 72 }
@@ -99,6 +102,11 @@ int main(int argc, const char **argv) {
99 } 102 }
100 } 103 }
101 break; 104 break;
105 case SCALING_MODE_CENTER:
106 cairo_set_source_surface(window->cairo, image,
107 (double) window->width/2 - width/2,
108 (double) window->height/2 - height/2);
109 break;
102 default: 110 default:
103 sway_abort("Scaling mode '%s' not implemented yet!", scaling_mode_str); 111 sway_abort("Scaling mode '%s' not implemented yet!", scaling_mode_str);
104 } 112 }