From 6ad244502d1c3c09a26012c5e7fad901c95cc38e Mon Sep 17 00:00:00 2001 From: Arslaan Pathan Date: Fri, 1 May 2026 21:38:49 +1200 Subject: Fix the buttons and implement hooks for future webkit bindings to build on top of --- src/saffron_event_hooks.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/saffron_event_hooks.c (limited to 'src/saffron_event_hooks.c') 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 +#include +#include + +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; + } + } + } +} -- cgit v1.2.3