]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Move keyboard functions into input/keyboard.h
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 3 Sep 2023 17:15:50 +0000 (19:15 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 30 Oct 2023 21:14:04 +0000 (21:14 +0000)
include/input/keyboard.h [new file with mode: 0644]
include/labwc.h
src/input/keyboard.c
src/interactive.c
src/regions.c
src/seat.c
src/workspaces.c

diff --git a/include/input/keyboard.h b/include/input/keyboard.h
new file mode 100644 (file)
index 0000000..a1604f6
--- /dev/null
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef LABWC_KEYBOARD_H
+#define LABWC_KEYBOARD_H
+
+#include <stdbool.h>
+
+struct seat;
+struct keyboard;
+struct wlr_keyboard;
+
+void keyboard_init(struct seat *seat);
+void keyboard_finish(struct seat *seat);
+
+void keyboard_setup_handlers(struct keyboard *keyboard);
+void keyboard_set_numlock(struct wlr_keyboard *keyboard);
+void keyboard_cancel_keybind_repeat(struct keyboard *keyboard);
+bool keyboard_any_modifiers_pressed(struct wlr_keyboard *keyboard);
+
+#endif /* LABWC_KEYBOARD_H */
index 14299f1fd80bc9faf9723cb0187c8de3d9070bac..7ac4ad181c1e4e356b54de613656e03f3bdaecc4 100644 (file)
@@ -410,14 +410,6 @@ struct view *desktop_cycle_view(struct server *server, struct view *start_view,
  */
 void desktop_focus_topmost_view(struct server *server);
 
-void keyboard_cancel_keybind_repeat(struct keyboard *keyboard);
-void keyboard_key_notify(struct wl_listener *listener, void *data);
-void keyboard_modifiers_notify(struct wl_listener *listener, void *data);
-void keyboard_set_numlock(struct wlr_keyboard *keyboard);
-void keyboard_init(struct seat *seat);
-bool keyboard_any_modifiers_pressed(struct wlr_keyboard *keyboard);
-void keyboard_finish(struct seat *seat);
-
 void seat_init(struct server *server);
 void seat_finish(struct server *server);
 void seat_reconfigure(struct server *server);
index ab4f5ac55d4985d6700b339b093e1d7a54a36b5b..87b41b56179cc88fd4cc7f6cbf10cadced624dd6 100644 (file)
@@ -5,6 +5,7 @@
 #include <wlr/interfaces/wlr_keyboard.h>
 #include "action.h"
 #include "idle.h"
+#include "input/keyboard.h"
 #include "input/key-state.h"
 #include "labwc.h"
 #include "menu/menu.h"
@@ -52,7 +53,7 @@ end_cycling(struct server *server)
        should_cancel_cycling_on_next_key_release = false;
 }
 
-void
+static void
 keyboard_modifiers_notify(struct wl_listener *listener, void *data)
 {
        struct keyboard *keyboard = wl_container_of(listener, keyboard, modifier);
@@ -476,7 +477,7 @@ keyboard_cancel_keybind_repeat(struct keyboard *keyboard)
        }
 }
 
-void
+static void
 keyboard_key_notify(struct wl_listener *listener, void *data)
 {
        /* This event is raised when a key is pressed or released. */
@@ -550,6 +551,17 @@ keyboard_init(struct seat *seat)
        keybind_update_keycodes(seat->server);
 }
 
+void
+keyboard_setup_handlers(struct keyboard *keyboard)
+{
+       struct wlr_keyboard *wlr_kb = keyboard->wlr_keyboard;
+
+       keyboard->key.notify = keyboard_key_notify;
+       wl_signal_add(&wlr_kb->events.key, &keyboard->key);
+       keyboard->modifier.notify = keyboard_modifiers_notify;
+       wl_signal_add(&wlr_kb->events.modifiers, &keyboard->modifier);
+}
+
 void
 keyboard_finish(struct seat *seat)
 {
index 0476f5fb650060d2702d249db1657997f865a574..d863f5698b108ff5dafa03532d0da378429b6ef9 100644 (file)
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
+#include "input/keyboard.h"
 #include "labwc.h"
 #include "regions.h"
 #include "resize_indicator.h"
index ad05cf2e93af26b3c96d19d4716d0fcbbedc31f7..f6eb6174da5dcbff9cbb3fd86cacec2fc19f1dc5 100644 (file)
@@ -12,6 +12,7 @@
 #include "common/graphic-helpers.h"
 #include "common/list.h"
 #include "common/mem.h"
+#include "input/keyboard.h"
 #include "labwc.h"
 #include "regions.h"
 #include "view.h"
index 778729ac367e4035e30fa5bef45bc9105f8e5fed..32ca58c89d85e8e4f60a83ecc5142c356fa9b6b9 100644 (file)
@@ -9,6 +9,7 @@
 #include <wlr/types/wlr_touch.h>
 #include <wlr/util/log.h>
 #include "common/mem.h"
+#include "input/keyboard.h"
 #include "input/key-state.h"
 #include "labwc.h"
 #include "view.h"
@@ -223,10 +224,7 @@ new_keyboard(struct seat *seat, struct wlr_input_device *device, bool virtual)
                wlr_keyboard_group_add_keyboard(seat->keyboard_group, kb);
        }
 
-       keyboard->key.notify = keyboard_key_notify;
-       wl_signal_add(&kb->events.key, &keyboard->key);
-       keyboard->modifier.notify = keyboard_modifiers_notify;
-       wl_signal_add(&kb->events.modifiers, &keyboard->modifier);
+       keyboard_setup_handlers(keyboard);
 
        wlr_seat_set_keyboard(seat->seat, kb);
 
index 89bf030b3e2b8c049bef7654445ca8ace0fd0528..602133cfd47406bd4bc585370a75542dcdce5786 100644 (file)
@@ -12,6 +12,7 @@
 #include "common/graphic-helpers.h"
 #include "common/list.h"
 #include "common/mem.h"
+#include "input/keyboard.h"
 #include "labwc.h"
 #include "view.h"
 #include "workspaces.h"