desktop-shell: Reject invalid focus types in configuration

Just refuse to start up if someone passes an incorrect focus type.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone 2023-08-08 13:45:02 +01:00 committed by Marius Vlad
parent fca71ff4bb
commit 72a52454ad

View file

@ -565,7 +565,7 @@ get_animation_type(char *animation)
return ANIMATION_NONE; return ANIMATION_NONE;
} }
static void static bool
shell_configuration(struct desktop_shell *shell) shell_configuration(struct desktop_shell *shell)
{ {
struct weston_config_section *section; struct weston_config_section *section;
@ -592,15 +592,22 @@ shell_configuration(struct desktop_shell *shell)
weston_config_section_get_string(section, "close-animation", &s, "fade"); weston_config_section_get_string(section, "close-animation", &s, "fade");
shell->win_close_animation_type = get_animation_type(s); shell->win_close_animation_type = get_animation_type(s);
free(s); free(s);
weston_config_section_get_string(section, weston_config_section_get_string(section,
"startup-animation", &s, "fade"); "startup-animation", &s, "fade");
shell->startup_animation_type = get_animation_type(s); shell->startup_animation_type = get_animation_type(s);
if (shell->startup_animation_type == ANIMATION_ZOOM) {
weston_log("invalid startup animation type %s\n", s);
free(s); free(s);
if (shell->startup_animation_type == ANIMATION_ZOOM) return false;
shell->startup_animation_type = ANIMATION_NONE; }
free(s);
weston_config_section_get_string(section, "focus-animation", &s, "none"); weston_config_section_get_string(section, "focus-animation", &s, "none");
shell->focus_animation_type = get_animation_type(s); shell->focus_animation_type = get_animation_type(s);
free(s); free(s);
return true;
} }
static int static int
@ -5017,7 +5024,8 @@ wet_shell_init(struct weston_compositor *ec,
shell->text_backend = text_backend_init(ec); shell->text_backend = text_backend_init(ec);
shell_configuration(shell); if (!shell_configuration(shell))
return -1;
workspace_create(shell); workspace_create(shell);