diff options
author | Marius Vlad <marius.vlad@collabora.com> | 2022-11-22 13:48:13 +0200 |
---|---|---|
committer | Daniel Stone <daniels@collabora.com> | 2023-01-09 22:13:07 +0000 |
commit | 6293ab1f90fdaf59d7f7ff394343ca1f3101338c (patch) | |
tree | 1829bacc928118b6bd90b9832f61715c0f0781bc /shared | |
parent | 58c3e263a05880e7cbc97a70a63ab3cfe563a8d5 (diff) | |
download | weston-6293ab1f90fdaf59d7f7ff394343ca1f3101338c.tar.gz |
libweston, shared: Move out weston_shell_get_binding_modifier
This doesn't really belong into shell-utils, so better move it out to
shared/config-parser. Renamed to weston_config_get_binding_modifier
to maintain the same namespace.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Diffstat (limited to 'shared')
-rw-r--r-- | shared/config-parser.c | 32 | ||||
-rw-r--r-- | shared/meson.build | 2 |
2 files changed, 33 insertions, 1 deletions
diff --git a/shared/config-parser.c b/shared/config-parser.c index 30779ae4..cf4adddf 100644 --- a/shared/config-parser.c +++ b/shared/config-parser.c @@ -41,6 +41,7 @@ #include <wayland-util.h> #include <libweston/zalloc.h> #include <libweston/config-parser.h> +#include <libweston/libweston.h> #include "helpers.h" #include "string-helpers.h" @@ -541,3 +542,34 @@ weston_config_destroy(struct weston_config *config) free(config); } + +WL_EXPORT uint32_t +weston_config_get_binding_modifier(struct weston_config *config, + uint32_t default_mod) +{ + struct weston_config_section *shell_section = NULL; + char *mod_string = NULL; + uint32_t mod = default_mod; + + if (config) + shell_section = weston_config_get_section(config, "shell", NULL, NULL); + + if (shell_section) + weston_config_section_get_string(shell_section, + "binding-modifier", &mod_string, "super"); + + if (!mod_string || !strcmp(mod_string, "none")) + mod = default_mod; + else if (!strcmp(mod_string, "super")) + mod = MODIFIER_SUPER; + else if (!strcmp(mod_string, "alt")) + mod = MODIFIER_ALT; + else if (!strcmp(mod_string, "ctrl")) + mod = MODIFIER_CTRL; + else if (!strcmp(mod_string, "shift")) + mod = MODIFIER_SHIFT; + + free(mod_string); + + return mod; +} diff --git a/shared/meson.build b/shared/meson.build index 8b71fb87..8ed3c0a0 100644 --- a/shared/meson.build +++ b/shared/meson.build @@ -6,7 +6,7 @@ srcs_libshared = [ 'os-compatibility.c', 'process-util.c', ] -deps_libshared = [dep_wayland_client, dep_wayland_server] +deps_libshared = [dep_wayland_client, dep_wayland_server, dep_pixman] lib_libshared = static_library( 'shared', |