aboutsummaryrefslogtreecommitdiff
path: root/src/saffron_event_hooks.c
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-05-01 21:38:49 +1200
committerArslaan Pathan <[email protected]>2026-05-01 21:38:49 +1200
commit6ad244502d1c3c09a26012c5e7fad901c95cc38e (patch)
treeb0b8106fca78a49e47313f35d8245eeb6980d3ac /src/saffron_event_hooks.c
parentccb8f9316c9bc7aded2dd5d74d2e82445bf2f647 (diff)
downloadsaffron-6ad244502d1c3c09a26012c5e7fad901c95cc38e.tar.xz
saffron-6ad244502d1c3c09a26012c5e7fad901c95cc38e.zip
Fix the buttons and implement hooks for future webkit bindings to build on top of
Diffstat (limited to 'src/saffron_event_hooks.c')
-rw-r--r--src/saffron_event_hooks.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/saffron_event_hooks.c b/src/saffron_event_hooks.c
new file mode 100644
index 0000000..d3a2c43
--- /dev/null
+++ b/src/saffron_event_hooks.c
@@ -0,0 +1,19 @@
+#include "saffron_api.h"
+#include <SDL3/SDL.h>
+#include <saffron.h>
+#include <saffron_event_hooks.h>
+
+void saffron_hook_sdl_all_events(SaffronWindow* window, bool (*callback)(SDL_Event* event), int priority) {
+ window->hooks[window->hook_count].callback = callback;
+ window->hooks[window->hook_count].priority = priority;
+ window->hook_count++;
+ for (int i = 0; i < window->hook_count; i++) {
+ for (int j = i + 1; j < window->hook_count; j++) {
+ if (window->hooks[j].priority > window->hooks[i].priority) {
+ SfInternalEventHook tmp = window->hooks[i];
+ window->hooks[i] = window->hooks[j];
+ window->hooks[j] = tmp;
+ }
+ }
+ }
+}