aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/window/window.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/window/window.c b/src/window/window.c
index cec6417..b53c4a1 100644
--- a/src/window/window.c
+++ b/src/window/window.c
@@ -4,6 +4,7 @@
#include "../../include/mgl/system/utf8.h"
#include <X11/Xutil.h>
#include <stdlib.h>
+#include <string.h>
#include <errno.h>
#include <stdio.h>
@@ -347,13 +348,17 @@ static void mgl_window_handle_text_event(mgl_window *self, XEvent *xev) {
for(size_t i = 0; i < input_str_len;) {
uint32_t codepoint = 0;
const size_t clen = mgl_utf8_decode((const unsigned char*)&buf[i], &codepoint);
- i += clen;
mgl_event text_event;
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);
+ text_event.text.str[clen] = '\0';
if(!x11_context_append_event(x11_context, &text_event))
break;
+
+ i += clen;
}
}