summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorMikhail Burakov <mburakov@mailbox.org>2023-04-02 12:09:20 +0200
committerMikhail Burakov <mburakov@mailbox.org>2023-04-07 13:47:39 +0200
commiteecbacdc1ab1b29fee71f3a689e01cabe12b3730 (patch)
tree0b6c924678a31ed2f46061f7767a99bb40b57737 /main.c
parent972e03b4a09b790d9ed9c8102cc897a75c9bb751 (diff)
Major rewrite of window to support input events
Diffstat (limited to 'main.c')
-rw-r--r--main.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/main.c b/main.c
index 2a5e7ff..c650ea2 100644
--- a/main.c
+++ b/main.c
@@ -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;