summaryrefslogtreecommitdiff
path: root/src/lib/ecore_cocoa
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 16:46:30 +0100
commit5e149977e749eac878e8bcb01ce77f45f91c47ea (patch)
tree7a975b22a9bfcd3cf61904e131a5ab755b36f831 /src/lib/ecore_cocoa
parent5c366cab268a8e6b1d11b84794277c725040d3e6 (diff)
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
Diffstat (limited to 'src/lib/ecore_cocoa')
-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 7204f89417..8fa9e09c36 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,
115 static Eina_Bool compose = EINA_FALSE; 115 static Eina_Bool compose = EINA_FALSE;
116 static NSText *edit; 116 static NSText *edit;
117 unsigned int i; 117 unsigned int i;
118 int kchar = -1;
118 119
119 Ecore_Event_Key *ev; 120 Ecore_Event_Key *ev;
120 121
@@ -143,22 +144,33 @@ _ecore_cocoa_event_key(NSEvent *event,
143 ev->window = (Ecore_Window)window.ecore_window_data; 144 ev->window = (Ecore_Window)window.ecore_window_data;
144 ev->event_window = ev->window; 145 ev->event_window = ev->window;
145 146
147 /*
148 * Try to look for the keychar data if available.
149 * If not, try the raw keychar.
150 */
146 if ([keychar length] > 0) 151 if ([keychar length] > 0)
152 kchar = [keychar characterAtIndex: 0];
153 if ((kchar < 0) && ([keycharRaw length] > 0))
154 kchar = [keycharRaw characterAtIndex: 0];
155
156 if (kchar >= 0)
147 { 157 {
148 for (i = 0; i < EINA_C_ARRAY_LENGTH(keystable); ++i) 158 for (i = 0; i < EINA_C_ARRAY_LENGTH(keystable); ++i)
149 { 159 {
150 if (keystable[i].code == [keychar characterAtIndex:0]) 160 if (keystable[i].code == kchar)
151 { 161 {
152 ev->keyname = keystable[i].name; 162 ev->keyname = keystable[i].name;
153 ev->key = ev->keyname; 163 ev->key = ev->keyname;
154 break; 164 break;
155 } 165 }
156 } 166 }
157 if (ev->keyname == NULL) 167 }
158 { 168
159 ev->keyname = ""; 169 /* Fallback */
160 ev->key = ""; 170 if (!ev->keyname)
161 } 171 {
172 ev->keyname = "";
173 ev->key = "";
162 } 174 }
163 175
164 if (([keycharRaw length] == 0) && (keyType == NSEventTypeKeyDown)) 176 if (([keycharRaw length] == 0) && (keyType == NSEventTypeKeyDown))