]> git.mdlowis.com Git - proto/labwc.git/commitdiff
action: refactor action()
authorJohan Malm <jgm323@gmail.com>
Fri, 25 Sep 2020 18:37:51 +0000 (19:37 +0100)
committerJohan Malm <jgm323@gmail.com>
Fri, 25 Sep 2020 18:37:51 +0000 (19:37 +0100)
include/labwc.h
src/action.c
src/keyboard.c

index 94811474d28532391bf131715cb1a3fcd91dd2ba..87f8cfb5e84ee78434631a3747e354d852095cc4 100644 (file)
@@ -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);
index 1eff680dd15e77168d0222d574f639526eb68668..4ae7e7d21157728c11d798b6df8f4e19f26b44c0 100644 (file)
@@ -4,20 +4,20 @@
 
 #include <strings.h>
 
-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);
        }
 }
index 08e2372bb4b7513dbb33a7d1e52accf19fab44c7..ffd270af0f8e0d52873493361e32f39b0044b168 100644 (file)
@@ -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;
                        }
                }