summaryrefslogtreecommitdiff
path: root/src/lib/ecore_win32
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2020-02-25 09:23:48 -0500
committerMike Blumenkrantz <zmike@samsung.com>2020-02-25 09:23:48 -0500
commit0ff7469d91df09f859dffd5152dfc508759206e6 (patch)
treec83cb264a1b38db44dee980712521d4396fc3e94 /src/lib/ecore_win32
parent526b1e2c72560f80bcc7c435a924b2def3016215 (diff)
Evil: add evil_utf8_to_utf16() API ; use evil_utf16_to_utf8() in Ecore_Win32
Summary: use existing utf-16 to utf-8 conversion function in Ecore_Win32. Add API to convert utf-8 to utf-16 in Evil for copy'n paste on Windows Test Plan: compilation Reviewers: raster, zmike Reviewed By: zmike Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11406
Diffstat (limited to 'src/lib/ecore_win32')
-rw-r--r--src/lib/ecore_win32/ecore_win32_event.c35
1 files changed, 5 insertions, 30 deletions
diff --git a/src/lib/ecore_win32/ecore_win32_event.c b/src/lib/ecore_win32/ecore_win32_event.c
index 293b16816b..c2e9200580 100644
--- a/src/lib/ecore_win32/ecore_win32_event.c
+++ b/src/lib/ecore_win32/ecore_win32_event.c
@@ -9,6 +9,7 @@
9#undef WIN32_LEAN_AND_MEAN 9#undef WIN32_LEAN_AND_MEAN
10#include <windowsx.h> 10#include <windowsx.h>
11 11
12#include <evil_private.h> /* evil_utf16_to_utf8() */
12#include <Eina.h> 13#include <Eina.h>
13#include <Ecore.h> 14#include <Ecore.h>
14#include <Ecore_Input.h> 15#include <Ecore_Input.h>
@@ -42,32 +43,6 @@ static Ecore_Win32_Key_Mask _ecore_win32_key_mask = 0;
42static Eina_Bool _ecore_win32_ctrl_fake = EINA_FALSE; 43static Eina_Bool _ecore_win32_ctrl_fake = EINA_FALSE;
43static Eina_Bool _ecore_win32_clipboard_has_data = EINA_FALSE; 44static Eina_Bool _ecore_win32_clipboard_has_data = EINA_FALSE;
44 45
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
71static unsigned int 46static unsigned int
72_ecore_win32_modifiers_get(void) 47_ecore_win32_modifiers_get(void)
73{ 48{
@@ -1202,13 +1177,13 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
1202 if (res == -1) 1177 if (res == -1)
1203 { 1178 {
1204 /* dead key, but managed like normal key */ 1179 /* dead key, but managed like normal key */
1205 compose = _ecore_win32_utf16_to_utf8(buf); 1180 compose = evil_utf16_to_utf8(buf);
1206 } 1181 }
1207 else if (res == 0) 1182 else if (res == 0)
1208 { 1183 {
1209 INF("No translatable character found, skipping"); 1184 INF("No translatable character found, skipping");
1210 if (msg->window_param >= 0x30 && msg->window_param <= 0x39) 1185 if (msg->window_param >= 0x30 && msg->window_param <= 0x39)
1211 compose = _ecore_win32_utf16_to_utf8(buf); 1186 compose = evil_utf16_to_utf8(buf);
1212 /* otherwise, compose is NULL */ 1187 /* otherwise, compose is NULL */
1213 } 1188 }
1214 else if (res >= 2) 1189 else if (res >= 2)
@@ -1222,11 +1197,11 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
1222 MapVirtualKey(msg->window_param, MAPVK_VK_TO_CHAR), 1197 MapVirtualKey(msg->window_param, MAPVK_VK_TO_CHAR),
1223 kbd_state, buf, 4, 0); 1198 kbd_state, buf, 4, 0);
1224 if (!((res != 1) && (res != -1))) 1199 if (!((res != 1) && (res != -1)))
1225 compose = _ecore_win32_utf16_to_utf8(buf); 1200 compose = evil_utf16_to_utf8(buf);
1226 /* otherwise, compose is NULL */ 1201 /* otherwise, compose is NULL */
1227 } 1202 }
1228 else /* res == 1 : 1 char written to buf */ 1203 else /* res == 1 : 1 char written to buf */
1229 compose = _ecore_win32_utf16_to_utf8(buf); 1204 compose = evil_utf16_to_utf8(buf);
1230 1205
1231 /*** key field ***/ 1206 /*** key field ***/
1232 1207