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>
This commit is contained in:
Marius Vlad 2022-11-22 13:48:13 +02:00 committed by Daniel Stone
parent 58c3e263a0
commit 6293ab1f90
7 changed files with 38 additions and 40 deletions

View file

@ -476,7 +476,7 @@ shell_configuration(struct desktop_shell *shell)
"allow-zap", &allow_zap, true);
shell->allow_zap = allow_zap;
shell->binding_modifier = weston_shell_get_binding_modifier(config, MODIFIER_SUPER);
shell->binding_modifier = weston_config_get_binding_modifier(config, MODIFIER_SUPER);
weston_config_section_get_string(section, "animation", &s, "none");
shell->win_animation_type = get_animation_type(s);

View file

@ -104,6 +104,9 @@ int weston_config_next_section(struct weston_config *config,
struct weston_config_section **section,
const char **name);
uint32_t
weston_config_get_binding_modifier(struct weston_config *config, uint32_t default_mod);
#ifdef __cplusplus
}
#endif

View file

@ -27,9 +27,6 @@
#include "shared/helpers.h"
#include <libweston/libweston.h>
#include <libweston/config-parser.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -75,9 +72,6 @@ weston_shell_utils_curtain_create(struct weston_compositor *compositor,
void
weston_shell_utils_curtain_destroy(struct weston_curtain *curtain);
uint32_t
weston_shell_get_binding_modifier(struct weston_config *config, uint32_t default_mod);
#ifdef __cplusplus
}
#endif

View file

@ -1068,7 +1068,7 @@ kiosk_shell_add_bindings(struct kiosk_shell *shell)
{
uint32_t mod = 0;
mod = weston_shell_get_binding_modifier(shell->config, MODIFIER_SUPER);
mod = weston_config_get_binding_modifier(shell->config, MODIFIER_SUPER);
weston_compositor_add_button_binding(shell->compositor, BTN_LEFT, 0,
kiosk_shell_click_to_activate_binding,

View file

@ -216,34 +216,3 @@ weston_shell_utils_curtain_destroy(struct weston_curtain *curtain)
weston_buffer_destroy_solid(curtain->buffer_ref);
free(curtain);
}
WL_EXPORT uint32_t
weston_shell_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;
}

View file

@ -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;
}

View file

@ -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',