From 74409194525fb7b92dc94ca2d08a0fd59699556d Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Thu, 18 Jun 2020 20:18:01 +0100 Subject: [PATCH] Add action.c --- include/labwc.h | 4 ++++ src/action.c | 22 ++++++++++++++++++++++ src/config/keybind.c | 6 +++--- src/keyboard.c | 20 -------------------- src/main.c | 1 - src/meson.build | 1 + src/output.c | 1 - src/server.c | 1 - src/view.c | 1 - src/xdg.c | 1 - 10 files changed, 30 insertions(+), 28 deletions(-) create mode 100644 src/action.c diff --git a/include/labwc.h b/include/labwc.h index fcd9936c..8011cdd9 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -29,6 +29,8 @@ #include #include +#include "rcxml.h" + #define XCURSOR_DEFAULT "left_ptr" #define XCURSOR_SIZE 24 #define XCURSOR_MOVE "grabbing" @@ -176,6 +178,8 @@ 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 dbg_show_one_view(struct view *view); void dbg_show_views(struct server *server); diff --git a/src/action.c b/src/action.c new file mode 100644 index 00000000..4087f341 --- /dev/null +++ b/src/action.c @@ -0,0 +1,22 @@ +#include "labwc.h" + +#include + +void action(struct server *server, struct keybind *keybind) +{ + if (!keybind || !keybind->action) + return; + if (!strcasecmp(keybind->action, "Exit")) { + wl_display_terminate(server->wl_display); + } else if (!strcasecmp(keybind->action, "NextWindow")) { + server->cycle_view = next_toplevel(view_front_toplevel(server)); + } else if (!strcasecmp(keybind->action, "Execute")) { + if (!fork()) + execl("/bin/dmenu_run", "/bin/dmenu_run", (void *)NULL); + } else if (!strcasecmp(keybind->action, "debug-views")) { + dbg_show_views(server); + } else { + fprintf(stderr, "warn: action (%s) not supported\n", + keybind->action); + } +} diff --git a/src/config/keybind.c b/src/config/keybind.c index 3acf27f3..e6764dae 100644 --- a/src/config/keybind.c +++ b/src/config/keybind.c @@ -56,9 +56,9 @@ void keybind_add(struct wl_list *keybinds, const char *keybind, void keybind_init() { - keybind_add(&rc.keybinds, "A-Escape", "exit"); - keybind_add(&rc.keybinds, "A-Tab", "cycle"); - keybind_add(&rc.keybinds, "A-F3", "exec"); + keybind_add(&rc.keybinds, "A-Escape", "Exit"); + keybind_add(&rc.keybinds, "A-Tab", "NextWindow"); + keybind_add(&rc.keybinds, "A-F3", "Execute"); } void keybind_print() diff --git a/src/keyboard.c b/src/keyboard.c index fcaf06ea..94a2d1ea 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -1,5 +1,4 @@ #include "labwc.h" -#include "rcxml.h" static void keyboard_handle_modifiers(struct wl_listener *listener, void *data) { @@ -21,25 +20,6 @@ static void keyboard_handle_modifiers(struct wl_listener *listener, void *data) keyboard->server->seat, &keyboard->device->keyboard->modifiers); } -static void action(struct server *server, struct keybind *keybind) -{ - if (!keybind || !keybind->action) - return; - if (!strcmp(keybind->action, "exit")) { - wl_display_terminate(server->wl_display); - } else if (!strcmp(keybind->action, "cycle")) { - server->cycle_view = next_toplevel(view_front_toplevel(server)); - } else if (!strcmp(keybind->action, "exec")) { - if (!fork()) - execl("/bin/dmenu_run", "/bin/dmenu_run", (void *)NULL); - } else if (!strcmp(keybind->action, "debug-views")) { - dbg_show_views(server); - } else { - fprintf(stderr, "warn: action (%s) not supported\n", - keybind->action); - } -} - static bool handle_keybinding(struct server *server, uint32_t modifiers, xkb_keysym_t sym) { diff --git a/src/main.c b/src/main.c index de84e6b5..3541ab9d 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,4 @@ #include "labwc.h" -#include "rcxml.h" #include "theme.h" struct server server = { 0 }; diff --git a/src/meson.build b/src/meson.build index 5895d465..0678cd9f 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,4 +1,5 @@ labwc_sources = files( + 'action.c', 'cursor.c', 'deco.c', 'interactive.c', diff --git a/src/output.c b/src/output.c index 521497b4..dd62bc4e 100644 --- a/src/output.c +++ b/src/output.c @@ -1,5 +1,4 @@ #include "labwc.h" -#include "rcxml.h" #include "theme.h" struct draw_data { diff --git a/src/server.c b/src/server.c index e496a534..2af99ada 100644 --- a/src/server.c +++ b/src/server.c @@ -1,5 +1,4 @@ #include "labwc.h" -#include "rcxml.h" #include #include diff --git a/src/view.c b/src/view.c index 44a80cc7..e99df0b0 100644 --- a/src/view.c +++ b/src/view.c @@ -1,5 +1,4 @@ #include "labwc.h" -#include "rcxml.h" static bool is_toplevel(struct view *view) { diff --git a/src/xdg.c b/src/xdg.c index e8ea18a6..b208f309 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -1,5 +1,4 @@ #include "labwc.h" -#include "rcxml.h" struct xdg_deco { struct wlr_xdg_toplevel_decoration_v1 *wlr_decoration;