From 478b24cae0a1a67e6db3426938a93bdc8f3b1b59 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Mon, 1 Aug 2022 17:03:03 +0300 Subject: [PATCH] desktops-shell: Re-use helper for modifier retrieval As we now have a helper to retrieve the binding modifier, use it in desktop-shell as well. Signed-off-by: Marius Vlad --- desktop-shell/shell.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index d1a2035d9..0e746b055 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -442,24 +442,6 @@ shell_touch_grab_end(struct shell_touch_grab *grab) weston_touch_end_grab(grab->touch); } -static enum weston_keyboard_modifier -get_modifier(char *modifier) -{ - if (!modifier) - return MODIFIER_SUPER; - - if (!strcmp("ctrl", modifier)) - return MODIFIER_CTRL; - else if (!strcmp("alt", modifier)) - return MODIFIER_ALT; - else if (!strcmp("super", modifier)) - return MODIFIER_SUPER; - else if (!strcmp("none", modifier)) - return 0; - else - return MODIFIER_SUPER; -} - static enum animation_type get_animation_type(char *animation) { @@ -480,11 +462,12 @@ static void shell_configuration(struct desktop_shell *shell) { struct weston_config_section *section; + struct weston_config *config; char *s, *client; bool allow_zap; - section = weston_config_get_section(wet_get_config(shell->compositor), - "shell", NULL, NULL); + config = wet_get_config(shell->compositor); + section = weston_config_get_section(config, "shell", NULL, NULL); client = wet_get_libexec_path(WESTON_SHELL_CLIENT); weston_config_section_get_string(section, "client", &s, client); free(client); @@ -494,10 +477,7 @@ shell_configuration(struct desktop_shell *shell) "allow-zap", &allow_zap, true); shell->allow_zap = allow_zap; - weston_config_section_get_string(section, - "binding-modifier", &s, "super"); - shell->binding_modifier = get_modifier(s); - free(s); + shell->binding_modifier = weston_shell_get_binding_modifier(config, MODIFIER_SUPER); weston_config_section_get_string(section, "animation", &s, "none"); shell->win_animation_type = get_animation_type(s);