From 214336492da0d184d5ad4ac64c31920954c5f7e7 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 7 Nov 2021 06:30:59 +0100 Subject: Implement text input --- include/mgl/window/event.h | 7 +++++++ include/mgl/window/window.h | 5 ++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/mgl/window/event.h b/include/mgl/window/event.h index c928d0e..0836098 100644 --- a/include/mgl/window/event.h +++ b/include/mgl/window/event.h @@ -3,6 +3,7 @@ #include "key.h" #include +#include typedef struct mgl_event mgl_event; @@ -11,6 +12,10 @@ typedef struct { int height; } mgl_size_event; +typedef struct { + uint32_t codepoint; +} mgl_text_event; + typedef struct { int code; /* mgl_key */ bool alt; @@ -43,6 +48,7 @@ typedef enum { MGL_EVENT_UNKNOWN, MGL_EVENT_CLOSED, /* Window closed */ MGL_EVENT_RESIZED, /* Window resized */ + MGL_EVENT_TEXT_ENTERED, MGL_EVENT_KEY_PRESSED, MGL_EVENT_KEY_RELEASED, MGL_EVENT_MOUSE_BUTTON_PRESSED, @@ -54,6 +60,7 @@ struct mgl_event { int type; /* mgl_event_type */ union { mgl_size_event size; + mgl_text_event text; mgl_key_event key; mgl_mouse_button_event mouse_button; mgl_mouse_move_event mouse_move; diff --git a/include/mgl/window/window.h b/include/mgl/window/window.h index cb8baf6..9d7086c 100644 --- a/include/mgl/window/window.h +++ b/include/mgl/window/window.h @@ -5,9 +5,8 @@ #include "../system/vec.h" #include -/* Vsync is automatically set for windows created, if supported by the system */ +/* Vsync is automatically set for created windows, if supported by the system */ -typedef struct __GLXcontextRec *GLXContext; typedef struct mgl_event mgl_event; /* x11 window handle. TODO: Add others when wayland, etc is added */ typedef unsigned long mgl_window_handle; @@ -21,7 +20,7 @@ typedef struct { struct mgl_window { mgl_window_handle window; - GLXContext glx_context; + void *context; mgl_vec2i size; /* relative to the top left of the window. only updates when the cursor is inside the window */ mgl_vec2i cursor_position; -- cgit v1.2.3