summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean@guyomarch.bzh>2016-10-30 16:35:56 +0100
committerJean Guyomarc'h <jean@guyomarch.bzh>2016-10-30 17:00:52 +0100
commit336fb418a96d67c52e4dea3f31e05d65af266d0c (patch)
tree077874b347b28d9e6c61912c355cd03831af3bcc
parenta7f491bafa035de527c3602bcfbed2d096f750d3 (diff)
downloadefl-336fb418a96d67c52e4dea3f31e05d65af266d0c.tar.gz
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
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa.m24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/lib/ecore_cocoa/ecore_cocoa.m b/src/lib/ecore_cocoa/ecore_cocoa.m
index 854a125e85..936739a08d 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa.m
@@ -115,6 +115,7 @@ _ecore_cocoa_event_key(NSEvent *event,
static Eina_Bool compose = EINA_FALSE;
static NSText *edit;
unsigned int i;
+ int kchar = -1;
Ecore_Event_Key *ev;
@@ -143,22 +144,33 @@ _ecore_cocoa_event_key(NSEvent *event,
ev->window = (Ecore_Window)window.ecore_window_data;
ev->event_window = ev->window;
+ /*
+ * Try to look for the keychar data if available.
+ * If not, try the raw keychar.
+ */
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 < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i)
{
- if (keystable[i].code == [keychar characterAtIndex:0])
+ if (keystable[i].code == kchar)
{
ev->keyname = keystable[i].name;
ev->key = ev->keyname;
break;
}
}
- if (ev->keyname == NULL)
- {
- ev->keyname = "";
- ev->key = "";
- }
+ }
+
+ /* Fallback */
+ if (!ev->keyname)
+ {
+ ev->keyname = "";
+ ev->key = "";
}
if (([keycharRaw length] == 0) && (keyType == NSEventTypeKeyDown))