summaryrefslogtreecommitdiff
path: root/src/lib/ecore_win32
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2019-11-28 11:06:24 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-11-28 11:06:24 +0000
commit9acab812ee02f5a2f30544d0eeacc521200e7ac1 (patch)
tree0e3a0ed1538eda9af066fbbcfc216f97f5b0f3b6 /src/lib/ecore_win32
parent92d2cc7ae362275f2a7512778e1f0fa994cdc946 (diff)
ecore_win32: fix compose event field
Summary: compose event field was encoded in UTF-16 and not UTF-8. Also string event field was not correctly defined and was generating eina error messages Test Plan: running a test Reviewers: raster, cedric, zmike Reviewed By: raster Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10753
Diffstat (limited to 'src/lib/ecore_win32')
-rw-r--r--src/lib/ecore_win32/ecore_win32_event.c55
1 files changed, 42 insertions, 13 deletions
diff --git a/src/lib/ecore_win32/ecore_win32_event.c b/src/lib/ecore_win32/ecore_win32_event.c
index cf6b4492cc..293b16816b 100644
--- a/src/lib/ecore_win32/ecore_win32_event.c
+++ b/src/lib/ecore_win32/ecore_win32_event.c
@@ -42,6 +42,32 @@ static Ecore_Win32_Key_Mask _ecore_win32_key_mask = 0;
42static Eina_Bool _ecore_win32_ctrl_fake = EINA_FALSE; 42static Eina_Bool _ecore_win32_ctrl_fake = EINA_FALSE;
43static Eina_Bool _ecore_win32_clipboard_has_data = EINA_FALSE; 43static Eina_Bool _ecore_win32_clipboard_has_data = EINA_FALSE;
44 44
45static char *
46_ecore_win32_utf16_to_utf8(const wchar_t *text)
47{
48 char *res;
49 int size;
50
51 /* text is used as an array, hence never NULL */
52
53 size = WideCharToMultiByte(CP_UTF8, 0, text, -1, NULL, 0, NULL, NULL);
54 if (size == 0)
55 return NULL;
56
57 res = (char *)malloc(size * sizeof(char));
58 if (!res)
59 return NULL;
60
61 size = WideCharToMultiByte(CP_UTF8, 0, text, -1, res, size, NULL, NULL);
62 if (size == 0)
63 {
64 free(res);
65 return NULL;
66 }
67
68 return res;
69}
70
45static unsigned int 71static unsigned int
46_ecore_win32_modifiers_get(void) 72_ecore_win32_modifiers_get(void)
47{ 73{
@@ -1176,15 +1202,14 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
1176 if (res == -1) 1202 if (res == -1)
1177 { 1203 {
1178 /* dead key, but managed like normal key */ 1204 /* dead key, but managed like normal key */
1205 compose = _ecore_win32_utf16_to_utf8(buf);
1179 } 1206 }
1180 else if (res == 0) 1207 else if (res == 0)
1181 { 1208 {
1182 INF("No translatable character found, skipping"); 1209 INF("No translatable character found, skipping");
1183 if (msg->window_param >= 0x30 && msg->window_param <= 0x39) 1210 if (msg->window_param >= 0x30 && msg->window_param <= 0x39)
1184 { 1211 compose = _ecore_win32_utf16_to_utf8(buf);
1185 buf[0] = msg->window_param; 1212 /* otherwise, compose is NULL */
1186 }
1187 else return NULL;
1188 } 1213 }
1189 else if (res >= 2) 1214 else if (res >= 2)
1190 { 1215 {
@@ -1196,12 +1221,12 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
1196 res = ToUnicode(msg->window_param, 1221 res = ToUnicode(msg->window_param,
1197 MapVirtualKey(msg->window_param, MAPVK_VK_TO_CHAR), 1222 MapVirtualKey(msg->window_param, MAPVK_VK_TO_CHAR),
1198 kbd_state, buf, 4, 0); 1223 kbd_state, buf, 4, 0);
1199 if ((res != 1) && (res != -1)) 1224 if (!((res != 1) && (res != -1)))
1200 return NULL; 1225 compose = _ecore_win32_utf16_to_utf8(buf);
1226 /* otherwise, compose is NULL */
1201 } 1227 }
1202 1228 else /* res == 1 : 1 char written to buf */
1203 string[0] = (char)buf[0]; 1229 compose = _ecore_win32_utf16_to_utf8(buf);
1204 compose = string;
1205 1230
1206 /*** key field ***/ 1231 /*** key field ***/
1207 1232
@@ -1232,7 +1257,6 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
1232 { 1257 {
1233 buf[0] = msg->window_param; 1258 buf[0] = msg->window_param;
1234 } 1259 }
1235 else return NULL;
1236 } 1260 }
1237 else if (res >= 2) 1261 else if (res >= 2)
1238 { 1262 {
@@ -1303,7 +1327,7 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
1303 { 1327 {
1304 buf[0] = msg->window_param; 1328 buf[0] = msg->window_param;
1305 } 1329 }
1306 else return NULL; 1330 else buf[0] = 0;// return NULL;
1307 } 1331 }
1308 else if (res >= 2) 1332 else if (res >= 2)
1309 { 1333 {
@@ -1353,7 +1377,7 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
1353 e = (Ecore_Event_Key *)calloc(1, sizeof(Ecore_Event_Key) + 1377 e = (Ecore_Event_Key *)calloc(1, sizeof(Ecore_Event_Key) +
1354 strlen(keyname) + 1 + 1378 strlen(keyname) + 1 +
1355 strlen(key) + 1 + 1379 strlen(key) + 1 +
1356 (compose ? (strlen(compose) + 1) : 0)); 1380 (compose ? strlen(compose) : 0) + 1);
1357 if (!e) 1381 if (!e)
1358 return NULL; 1382 return NULL;
1359 1383
@@ -1366,7 +1390,12 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
1366 1390
1367 memcpy((char *)e->keyname, keyname, strlen(keyname)); 1391 memcpy((char *)e->keyname, keyname, strlen(keyname));
1368 memcpy((char *)e->key, key, strlen(key)); 1392 memcpy((char *)e->key, key, strlen(key));
1369 if (compose) memcpy((char *)e->compose, compose, strlen(compose)); 1393 if (compose)
1394 {
1395 memcpy((char *)e->compose, compose, strlen(compose));
1396 free(compose);
1397 }
1398
1370 1399
1371 return e; 1400 return e;
1372} 1401}