From 745915c0baf716dd8c6361c810416e550d114d05 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Fri, 25 Sep 2020 19:37:51 +0100 Subject: [PATCH] action: refactor action() --- include/labwc.h | 2 +- src/action.c | 16 ++++++++-------- src/keyboard.c | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/labwc.h b/include/labwc.h index 94811474..87f8cfb5 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -240,7 +240,7 @@ struct wlr_box deco_max_extents(struct view *view); struct wlr_box deco_box(struct view *view, enum deco_part deco_part); enum deco_part deco_at(struct view *view, double lx, double ly); -void action(struct server *server, struct keybind *keybind); +void action(struct server *server, const char *action, const char *command); void dbg_show_one_view(struct view *view); void dbg_show_views(struct server *server); diff --git a/src/action.c b/src/action.c index 1eff680d..4ae7e7d2 100644 --- a/src/action.c +++ b/src/action.c @@ -4,20 +4,20 @@ #include -void action(struct server *server, struct keybind *keybind) +void action(struct server *server, const char *action, const char *command) { - if (!keybind || !keybind->action) + if (!action) return; - if (!strcasecmp(keybind->action, "Exit")) { + if (!strcasecmp(action, "Exit")) { wl_display_terminate(server->wl_display); - } else if (!strcasecmp(keybind->action, "NextWindow")) { + } else if (!strcasecmp(action, "NextWindow")) { server->cycle_view = desktop_next_view(server, server->cycle_view); - } else if (!strcasecmp(keybind->action, "Execute")) { - spawn_async_no_shell(keybind->command); - } else if (!strcasecmp(keybind->action, "debug-views")) { + } else if (!strcasecmp(action, "Execute")) { + spawn_async_no_shell(command); + } else if (!strcasecmp(action, "debug-views")) { dbg_show_views(server); } else { - warn("action (%s) not supported", keybind->action); + warn("action (%s) not supported", action); } } diff --git a/src/keyboard.c b/src/keyboard.c index 08e2372b..ffd270af 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -30,7 +30,7 @@ static bool handle_keybinding(struct server *server, uint32_t modifiers, continue; for (size_t i = 0; i < keybind->keysyms_len; i++) { if (sym == keybind->keysyms[i]) { - action(server, keybind); + action(server, keybind->action, keybind->command); return true; } }