From 16b0ce3748f1b3ea788bbaf4caaeb342a8f58d6f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 7 Nov 2021 08:24:55 +0100 Subject: Use char array for text entered str, reset text fields on deinit --- src/window/window.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/window') diff --git a/src/window/window.c b/src/window/window.c index b53c4a1..05cd5f5 100644 --- a/src/window/window.c +++ b/src/window/window.c @@ -8,6 +8,8 @@ #include #include +/* TODO: Handle XIM better. Set XIM position to text position on screen (for text input) and reset input when selecting a new text input, etc */ + /* Should be in range [2,] */ #define MAX_STACKED_EVENTS 32 @@ -353,7 +355,7 @@ static void mgl_window_handle_text_event(mgl_window *self, XEvent *xev) { text_event.type = MGL_EVENT_TEXT_ENTERED; text_event.text.codepoint = codepoint; text_event.text.size = clen; - memcpy(text_event.text.str, (const unsigned char*)&buf[i], clen); + memcpy(text_event.text.str, &buf[i], clen); text_event.text.str[clen] = '\0'; if(!x11_context_append_event(x11_context, &text_event)) break; @@ -367,14 +369,12 @@ static void mgl_window_on_receive_event(mgl_window *self, XEvent *xev, mgl_event /* TODO: Handle wm_delete_window event */ switch(xev->type) { case KeyPress: { - /* TODO: Fill with correct data */ event->type = MGL_EVENT_KEY_PRESSED; mgl_window_handle_key_event(self, &xev->xkey, event, context); mgl_window_handle_text_event(self, xev); return; } case KeyRelease: { - /* TODO: Fill with correct data */ event->type = MGL_EVENT_KEY_RELEASED; mgl_window_handle_key_event(self, &xev->xkey, event, context); return; -- cgit v1.2.3