diff options
author | Mikhail Burakov <mburakov@mailbox.org> | 2023-04-02 12:09:20 +0200 |
---|---|---|
committer | Mikhail Burakov <mburakov@mailbox.org> | 2023-04-07 13:47:39 +0200 |
commit | eecbacdc1ab1b29fee71f3a689e01cabe12b3730 (patch) | |
tree | 0b6c924678a31ed2f46061f7767a99bb40b57737 /main.c | |
parent | 972e03b4a09b790d9ed9c8102cc897a75c9bb751 (diff) |
Major rewrite of window to support input events
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -31,11 +31,31 @@ static volatile sig_atomic_t g_signal; static void OnSignal(int status) { g_signal = status; } +static void OnWindowClose(void* user) { + (void)user; + g_signal = SIGINT; +} + +static void OnWindowKey(void* user, unsigned key, bool pressed) { + // TODO +} + +static void WindowDtor(struct Window** window) { + if (!*window) return; + WindowDestroy(*window); + *window = NULL; +} + int main(int argc, char* argv[]) { (void)argc; (void)argv; - struct AUTO(Window)* window = WindowCreate(); + static const struct WindowEventHandlers window_event_handlers = { + .OnClose = OnWindowClose, + .OnKey = OnWindowKey, + }; + struct Window __attribute__((cleanup(WindowDtor)))* window = + WindowCreate(&window_event_handlers, NULL); if (!window) { LOG("Failed to create window"); return EXIT_FAILURE; |