mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2025-12-25 15:20:11 +01:00
frontend: use weston_enum_map for scroll method
Use helpers instead of open-coding. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
parent
72d2b14e6a
commit
ead6c5b319
1 changed files with 11 additions and 9 deletions
|
|
@ -2223,9 +2223,16 @@ static void
|
||||||
configure_input_device_scroll(struct weston_config_section *s,
|
configure_input_device_scroll(struct weston_config_section *s,
|
||||||
struct libinput_device *device)
|
struct libinput_device *device)
|
||||||
{
|
{
|
||||||
|
static const struct weston_enum_map scroll_modes[] = {
|
||||||
|
{ "two-finger", LIBINPUT_CONFIG_SCROLL_2FG },
|
||||||
|
{ "edge", LIBINPUT_CONFIG_SCROLL_EDGE },
|
||||||
|
{ "button", LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN },
|
||||||
|
{ "none", LIBINPUT_CONFIG_SCROLL_NO_SCROLL },
|
||||||
|
};
|
||||||
bool natural;
|
bool natural;
|
||||||
char *method_string = NULL;
|
char *method_string = NULL;
|
||||||
uint32_t methods;
|
uint32_t methods;
|
||||||
|
const struct weston_enum_map *entry;
|
||||||
enum libinput_config_scroll_method method;
|
enum libinput_config_scroll_method method;
|
||||||
char *button_string = NULL;
|
char *button_string = NULL;
|
||||||
int button;
|
int button;
|
||||||
|
|
@ -2242,15 +2249,10 @@ configure_input_device_scroll(struct weston_config_section *s,
|
||||||
if (weston_config_section_get_string(s, "scroll-method",
|
if (weston_config_section_get_string(s, "scroll-method",
|
||||||
&method_string, NULL) != 0)
|
&method_string, NULL) != 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (strcmp(method_string, "two-finger") == 0)
|
entry = weston_enum_map_find_name(scroll_modes, method_string);
|
||||||
method = LIBINPUT_CONFIG_SCROLL_2FG;
|
if (entry) {
|
||||||
else if (strcmp(method_string, "edge") == 0)
|
method = entry->value;
|
||||||
method = LIBINPUT_CONFIG_SCROLL_EDGE;
|
} else {
|
||||||
else if (strcmp(method_string, "button") == 0)
|
|
||||||
method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
|
|
||||||
else if (strcmp(method_string, "none") == 0)
|
|
||||||
method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
|
|
||||||
else {
|
|
||||||
weston_log("warning: no such scroll-method: %s\n",
|
weston_log("warning: no such scroll-method: %s\n",
|
||||||
method_string);
|
method_string);
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue