output/background: parse background mode into enum

This simplifies the logic in `output_cmd_background` by avoiding
strdup() calls (and their error handling paths) for the background mode.

It also fixes a mismatch between the "background" subcommand (which
accepts mode names case-insensitively) and swaybg (which does not,
requiring lowercase).
This commit is contained in:
Manuel Stoeckl 2025-02-09 09:33:45 -05:00
parent f4aba22582
commit 35108b9d35
3 changed files with 42 additions and 35 deletions

View file

@ -267,6 +267,17 @@ enum render_bit_depth {
RENDER_BIT_DEPTH_10,
};
enum background_mode {
BACKGROUND_MODE_UNSET, // there is no default
BACKGROUND_MODE_SOLID_COLOR,
BACKGROUND_MODE_STRETCH,
BACKGROUND_MODE_CENTER,
BACKGROUND_MODE_FILL,
BACKGROUND_MODE_FIT,
BACKGROUND_MODE_TILE,
};
extern const char *const background_mode_names[];
/**
* Size and position configuration for a particular output.
*
@ -294,7 +305,7 @@ struct output_config {
int hdr;
char *background;
char *background_option;
enum background_mode background_option;
char *background_fallback;
};