forked from enlightenment/efl
ecore_cocoa: fix handling of some keys
The ascii circumflex (^) can be typed by pressing twice the ^ key on a mac keyboard. A single press allows composition (e.g. ^+e = ê). Pressing ^ twice though, led to a segmentation fault in elementary, because the result character of the operation (^) appeared in the raw characters stack, and not in the filtered one. This is a bit weird, as backtick (`) appears in the filtered keys stack. @fix
This commit is contained in:
parent
5c366cab26
commit
5e149977e7
|
@ -115,6 +115,7 @@ _ecore_cocoa_event_key(NSEvent *event,
|
||||||
static Eina_Bool compose = EINA_FALSE;
|
static Eina_Bool compose = EINA_FALSE;
|
||||||
static NSText *edit;
|
static NSText *edit;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
int kchar = -1;
|
||||||
|
|
||||||
Ecore_Event_Key *ev;
|
Ecore_Event_Key *ev;
|
||||||
|
|
||||||
|
@ -143,22 +144,33 @@ _ecore_cocoa_event_key(NSEvent *event,
|
||||||
ev->window = (Ecore_Window)window.ecore_window_data;
|
ev->window = (Ecore_Window)window.ecore_window_data;
|
||||||
ev->event_window = ev->window;
|
ev->event_window = ev->window;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to look for the keychar data if available.
|
||||||
|
* If not, try the raw keychar.
|
||||||
|
*/
|
||||||
if ([keychar length] > 0)
|
if ([keychar length] > 0)
|
||||||
|
kchar = [keychar characterAtIndex: 0];
|
||||||
|
if ((kchar < 0) && ([keycharRaw length] > 0))
|
||||||
|
kchar = [keycharRaw characterAtIndex: 0];
|
||||||
|
|
||||||
|
if (kchar >= 0)
|
||||||
{
|
{
|
||||||
for (i = 0; i < EINA_C_ARRAY_LENGTH(keystable); ++i)
|
for (i = 0; i < EINA_C_ARRAY_LENGTH(keystable); ++i)
|
||||||
{
|
{
|
||||||
if (keystable[i].code == [keychar characterAtIndex:0])
|
if (keystable[i].code == kchar)
|
||||||
{
|
{
|
||||||
ev->keyname = keystable[i].name;
|
ev->keyname = keystable[i].name;
|
||||||
ev->key = ev->keyname;
|
ev->key = ev->keyname;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev->keyname == NULL)
|
}
|
||||||
{
|
|
||||||
ev->keyname = "";
|
/* Fallback */
|
||||||
ev->key = "";
|
if (!ev->keyname)
|
||||||
}
|
{
|
||||||
|
ev->keyname = "";
|
||||||
|
ev->key = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (([keycharRaw length] == 0) && (keyType == NSEventTypeKeyDown))
|
if (([keycharRaw length] == 0) && (keyType == NSEventTypeKeyDown))
|
||||||
|
|
Loading…
Reference in New Issue