forked from enlightenment/efl
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
This commit is contained in:
parent
92d2cc7ae3
commit
9acab812ee
|
@ -42,6 +42,32 @@ static Ecore_Win32_Key_Mask _ecore_win32_key_mask = 0;
|
||||||
static Eina_Bool _ecore_win32_ctrl_fake = EINA_FALSE;
|
static Eina_Bool _ecore_win32_ctrl_fake = EINA_FALSE;
|
||||||
static Eina_Bool _ecore_win32_clipboard_has_data = EINA_FALSE;
|
static Eina_Bool _ecore_win32_clipboard_has_data = EINA_FALSE;
|
||||||
|
|
||||||
|
static char *
|
||||||
|
_ecore_win32_utf16_to_utf8(const wchar_t *text)
|
||||||
|
{
|
||||||
|
char *res;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
/* text is used as an array, hence never NULL */
|
||||||
|
|
||||||
|
size = WideCharToMultiByte(CP_UTF8, 0, text, -1, NULL, 0, NULL, NULL);
|
||||||
|
if (size == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
res = (char *)malloc(size * sizeof(char));
|
||||||
|
if (!res)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
size = WideCharToMultiByte(CP_UTF8, 0, text, -1, res, size, NULL, NULL);
|
||||||
|
if (size == 0)
|
||||||
|
{
|
||||||
|
free(res);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
_ecore_win32_modifiers_get(void)
|
_ecore_win32_modifiers_get(void)
|
||||||
{
|
{
|
||||||
|
@ -1176,15 +1202,14 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
{
|
{
|
||||||
/* dead key, but managed like normal key */
|
/* dead key, but managed like normal key */
|
||||||
|
compose = _ecore_win32_utf16_to_utf8(buf);
|
||||||
}
|
}
|
||||||
else if (res == 0)
|
else if (res == 0)
|
||||||
{
|
{
|
||||||
INF("No translatable character found, skipping");
|
INF("No translatable character found, skipping");
|
||||||
if (msg->window_param >= 0x30 && msg->window_param <= 0x39)
|
if (msg->window_param >= 0x30 && msg->window_param <= 0x39)
|
||||||
{
|
compose = _ecore_win32_utf16_to_utf8(buf);
|
||||||
buf[0] = msg->window_param;
|
/* otherwise, compose is NULL */
|
||||||
}
|
|
||||||
else return NULL;
|
|
||||||
}
|
}
|
||||||
else if (res >= 2)
|
else if (res >= 2)
|
||||||
{
|
{
|
||||||
|
@ -1196,12 +1221,12 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
|
||||||
res = ToUnicode(msg->window_param,
|
res = ToUnicode(msg->window_param,
|
||||||
MapVirtualKey(msg->window_param, MAPVK_VK_TO_CHAR),
|
MapVirtualKey(msg->window_param, MAPVK_VK_TO_CHAR),
|
||||||
kbd_state, buf, 4, 0);
|
kbd_state, buf, 4, 0);
|
||||||
if ((res != 1) && (res != -1))
|
if (!((res != 1) && (res != -1)))
|
||||||
return NULL;
|
compose = _ecore_win32_utf16_to_utf8(buf);
|
||||||
|
/* otherwise, compose is NULL */
|
||||||
}
|
}
|
||||||
|
else /* res == 1 : 1 char written to buf */
|
||||||
string[0] = (char)buf[0];
|
compose = _ecore_win32_utf16_to_utf8(buf);
|
||||||
compose = string;
|
|
||||||
|
|
||||||
/*** key field ***/
|
/*** key field ***/
|
||||||
|
|
||||||
|
@ -1232,7 +1257,6 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
|
||||||
{
|
{
|
||||||
buf[0] = msg->window_param;
|
buf[0] = msg->window_param;
|
||||||
}
|
}
|
||||||
else return NULL;
|
|
||||||
}
|
}
|
||||||
else if (res >= 2)
|
else if (res >= 2)
|
||||||
{
|
{
|
||||||
|
@ -1303,7 +1327,7 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
|
||||||
{
|
{
|
||||||
buf[0] = msg->window_param;
|
buf[0] = msg->window_param;
|
||||||
}
|
}
|
||||||
else return NULL;
|
else buf[0] = 0;// return NULL;
|
||||||
}
|
}
|
||||||
else if (res >= 2)
|
else if (res >= 2)
|
||||||
{
|
{
|
||||||
|
@ -1353,7 +1377,7 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
|
||||||
e = (Ecore_Event_Key *)calloc(1, sizeof(Ecore_Event_Key) +
|
e = (Ecore_Event_Key *)calloc(1, sizeof(Ecore_Event_Key) +
|
||||||
strlen(keyname) + 1 +
|
strlen(keyname) + 1 +
|
||||||
strlen(key) + 1 +
|
strlen(key) + 1 +
|
||||||
(compose ? (strlen(compose) + 1) : 0));
|
(compose ? strlen(compose) : 0) + 1);
|
||||||
if (!e)
|
if (!e)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -1366,7 +1390,12 @@ _ecore_win32_event_keystroke_get(Ecore_Win32_Callback_Data *msg,
|
||||||
|
|
||||||
memcpy((char *)e->keyname, keyname, strlen(keyname));
|
memcpy((char *)e->keyname, keyname, strlen(keyname));
|
||||||
memcpy((char *)e->key, key, strlen(key));
|
memcpy((char *)e->key, key, strlen(key));
|
||||||
if (compose) memcpy((char *)e->compose, compose, strlen(compose));
|
if (compose)
|
||||||
|
{
|
||||||
|
memcpy((char *)e->compose, compose, strlen(compose));
|
||||||
|
free(compose);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue