mirror of
https://github.com/gwenhael-le-moine/sway-patched-tray-menu.git
synced 2024-12-27 21:58:16 +01:00
swaybg: implement scaling mode "center"
This commit is contained in:
parent
81a87ec7a7
commit
621062f18d
1 changed files with 8 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue