aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-11-07 06:46:42 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-07 06:46:42 +0100
commitb3b9e8c2b8068ce2566a9be2a813b2f04088f3ce (patch)
tree82b8c03d3e9fa25c0b50fe5ef2f59b713432ac21 /src
parent214336492da0d184d5ad4ac64c31920954c5f7e7 (diff)
Include utf8 string in text entered event
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;
}
}