summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-05-27 23:55:24 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-05-27 23:57:30 +0900
commit072674dbe2118a26d8616b56b4169a6e543805ef (patch)
treea3d8e81f8c86350594856900dd08582baf42d1ac
parent20f418b8d7010aa3a4b9d174780a1dec8e76ef4e (diff)
efl - ecore c+ ecore-imf - fix odd case input when faking a real event
so ibus module for ecore-imf likes to send an x event back to ourselves faking a key... this works unless we are looking at modifiers that make make for odd combos with keysyms turned into keycodes. so actualyl use the correct original keycode plus state unless we are having to explicitly send a keysym from ibus core. this fixes T3703 @fix
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_events.c11
-rw-r--r--src/modules/ecore_imf/ibus/ibus_imcontext.c36
2 files changed, 32 insertions, 15 deletions
diff --git a/src/lib/ecore_x/xlib/ecore_x_events.c b/src/lib/ecore_x/xlib/ecore_x_events.c
index 21e3489..0049fca 100644
--- a/src/lib/ecore_x/xlib/ecore_x_events.c
+++ b/src/lib/ecore_x/xlib/ecore_x_events.c
@@ -347,14 +347,15 @@ _ecore_key_press(int event,
347 char *key; 347 char *key;
348 char keyname_buffer[256]; 348 char keyname_buffer[256];
349 char compose_buffer[256]; 349 char compose_buffer[256];
350 KeySym sym; 350 KeySym sym, sym2 = 0;
351 XComposeStatus status; 351 XComposeStatus status;
352 int val; 352 int val;
353 int key_len, keyname_len, compose_len; 353 int key_len, keyname_len, compose_len;
354 354
355 _ecore_x_last_event_mouse_move = 0; 355 _ecore_x_last_event_mouse_move = 0;
356 keyname = XKeysymToString(_ecore_x_XKeycodeToKeysym(xevent->display, 356 sym = _ecore_x_XKeycodeToKeysym(xevent->display, xevent->keycode, 0);
357 xevent->keycode, 0)); 357 keyname = XKeysymToString(sym);
358
358 if (!keyname) 359 if (!keyname)
359 { 360 {
360 snprintf(keyname_buffer, 361 snprintf(keyname_buffer,
@@ -364,13 +365,12 @@ _ecore_key_press(int event,
364 keyname = keyname_buffer; 365 keyname = keyname_buffer;
365 } 366 }
366 367
367 sym = 0;
368 key = NULL; 368 key = NULL;
369 compose = NULL; 369 compose = NULL;
370 val = XLookupString(xevent, 370 val = XLookupString(xevent,
371 compose_buffer, 371 compose_buffer,
372 sizeof(compose_buffer), 372 sizeof(compose_buffer),
373 &sym, 373 &sym2,
374 &status); 374 &status);
375 if (val > 0) 375 if (val > 0)
376 { 376 {
@@ -381,6 +381,7 @@ _ecore_key_press(int event,
381 ERR("Ecore_X cannot convert input key string '%s' to UTF-8. " 381 ERR("Ecore_X cannot convert input key string '%s' to UTF-8. "
382 "Is Eina built with iconv support?", compose_buffer); 382 "Is Eina built with iconv support?", compose_buffer);
383 tmp = compose; 383 tmp = compose;
384 sym = sym2;
384 } 385 }
385 386
386 key = XKeysymToString(sym); 387 key = XKeysymToString(sym);
diff --git a/src/modules/ecore_imf/ibus/ibus_imcontext.c b/src/modules/ecore_imf/ibus/ibus_imcontext.c
index 4bfe627..40c9b6c 100644
--- a/src/modules/ecore_imf/ibus/ibus_imcontext.c
+++ b/src/modules/ecore_imf/ibus/ibus_imcontext.c
@@ -48,6 +48,7 @@ typedef struct _KeyEvent KeyEvent;
48struct _KeyEvent 48struct _KeyEvent
49{ 49{
50 int keysym; 50 int keysym;
51 int keycode;
51 int state; 52 int state;
52}; 53};
53 54
@@ -64,6 +65,7 @@ static void _ecore_imf_context_ibus_bus_connected_cb(IBusBus *bus, IBusIMContext
64static XKeyEvent _ecore_imf_ibus_x_key_event_generate(Window win, 65static XKeyEvent _ecore_imf_ibus_x_key_event_generate(Window win,
65 Eina_Bool press, 66 Eina_Bool press,
66 int keysym, 67 int keysym,
68 int keycode,
67 int modifiers); 69 int modifiers);
68 70
69static unsigned int 71static unsigned int
@@ -163,7 +165,7 @@ _ecore_imf_locks_to_ibus_modifier(unsigned int locks)
163} 165}
164 166
165static void 167static void
166_ecore_imf_ibus_key_event_put(int keysym, int state) 168_ecore_imf_ibus_key_event_put(int keysym, int keycode, int state)
167{ 169{
168 // Find the window which has the current keyboard focus. 170 // Find the window which has the current keyboard focus.
169 Window winFocus = 0; 171 Window winFocus = 0;
@@ -177,6 +179,7 @@ _ecore_imf_ibus_key_event_put(int keysym, int state)
177 event = _ecore_imf_ibus_x_key_event_generate(winFocus, 179 event = _ecore_imf_ibus_x_key_event_generate(winFocus,
178 EINA_FALSE, 180 EINA_FALSE,
179 keysym, 181 keysym,
182 keycode,
180 state); 183 state);
181 XSendEvent(event.display, event.window, True, KeyReleaseMask, (XEvent *)&event); 184 XSendEvent(event.display, event.window, True, KeyReleaseMask, (XEvent *)&event);
182 } 185 }
@@ -185,16 +188,18 @@ _ecore_imf_ibus_key_event_put(int keysym, int state)
185 event = _ecore_imf_ibus_x_key_event_generate(winFocus, 188 event = _ecore_imf_ibus_x_key_event_generate(winFocus,
186 EINA_TRUE, 189 EINA_TRUE,
187 keysym, 190 keysym,
191 keycode,
188 state); 192 state);
189 XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event); 193 XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event);
190 } 194 }
191} 195}
192 196
193static KeyEvent * 197static KeyEvent *
194_ecore_imf_ibus_key_event_copy(int keysym, int state) 198_ecore_imf_ibus_key_event_copy(int keysym, int keycode, int state)
195{ 199{
196 KeyEvent *kev = calloc(1, sizeof(KeyEvent)); 200 KeyEvent *kev = calloc(1, sizeof(KeyEvent));
197 kev->keysym = keysym; 201 kev->keysym = keysym;
202 kev->keycode = keycode;
198 kev->state = state; 203 kev->state = state;
199 204
200 return kev; 205 return kev;
@@ -221,7 +226,9 @@ _ecore_imf_ibus_process_key_event_done(GObject *object,
221 226
222 if (retval == EINA_FALSE) 227 if (retval == EINA_FALSE)
223 { 228 {
224 _ecore_imf_ibus_key_event_put(event->keysym, event->state); 229 _ecore_imf_ibus_key_event_put(event->keysym,
230 event->keycode,
231 event->state);
225 } 232 }
226 free(event); 233 free(event);
227} 234}
@@ -394,7 +401,7 @@ ecore_imf_context_ibus_filter_event(Ecore_IMF_Context *ctx,
394 if (ev->timestamp == 0) 401 if (ev->timestamp == 0)
395 return EINA_FALSE; 402 return EINA_FALSE;
396 403
397 keycode = ecore_x_keysym_keycode_get(ev->key); 404 keycode = ecore_x_keysym_keycode_get(ev->keyname);
398 keysym = XStringToKeysym(ev->key); 405 keysym = XStringToKeysym(ev->key);
399 state = _ecore_imf_modifier_to_ibus_modifier(ev->modifiers) | 406 state = _ecore_imf_modifier_to_ibus_modifier(ev->modifiers) |
400 _ecore_imf_locks_to_ibus_modifier(ev->locks) | IBUS_RELEASE_MASK; 407 _ecore_imf_locks_to_ibus_modifier(ev->locks) | IBUS_RELEASE_MASK;
@@ -415,7 +422,7 @@ ecore_imf_context_ibus_filter_event(Ecore_IMF_Context *ctx,
415 -1, 422 -1,
416 NULL, 423 NULL,
417 _ecore_imf_ibus_process_key_event_done, 424 _ecore_imf_ibus_process_key_event_done,
418 _ecore_imf_ibus_key_event_copy(keysym, state)); 425 _ecore_imf_ibus_key_event_copy(keysym, keycode, state));
419 retval = EINA_TRUE; 426 retval = EINA_TRUE;
420 } 427 }
421 } 428 }
@@ -427,7 +434,7 @@ ecore_imf_context_ibus_filter_event(Ecore_IMF_Context *ctx,
427 434
428 _request_surrounding_text(ibusimcontext); 435 _request_surrounding_text(ibusimcontext);
429 436
430 keycode = ecore_x_keysym_keycode_get(ev->key); 437 keycode = ecore_x_keysym_keycode_get(ev->keyname);
431 keysym = XStringToKeysym(ev->key); 438 keysym = XStringToKeysym(ev->key);
432 state = _ecore_imf_modifier_to_ibus_modifier(ev->modifiers) | 439 state = _ecore_imf_modifier_to_ibus_modifier(ev->modifiers) |
433 _ecore_imf_locks_to_ibus_modifier(ev->locks); 440 _ecore_imf_locks_to_ibus_modifier(ev->locks);
@@ -448,7 +455,7 @@ ecore_imf_context_ibus_filter_event(Ecore_IMF_Context *ctx,
448 -1, 455 -1,
449 NULL, 456 NULL,
450 _ecore_imf_ibus_process_key_event_done, 457 _ecore_imf_ibus_process_key_event_done,
451 _ecore_imf_ibus_key_event_copy(keysym, state)); 458 _ecore_imf_ibus_key_event_copy(keysym, keycode, state));
452 retval = EINA_TRUE; 459 retval = EINA_TRUE;
453 } 460 }
454 } 461 }
@@ -716,6 +723,7 @@ _ecore_imf_context_ibus_commit_text_cb(IBusInputContext *ibuscontext EINA_UNUSED
716static XKeyEvent _ecore_imf_ibus_x_key_event_generate(Window win, 723static XKeyEvent _ecore_imf_ibus_x_key_event_generate(Window win,
717 Eina_Bool press, 724 Eina_Bool press,
718 int keysym, 725 int keysym,
726 int keycode,
719 int modifiers) 727 int modifiers)
720{ 728{
721 XKeyEvent event; 729 XKeyEvent event;
@@ -731,8 +739,16 @@ static XKeyEvent _ecore_imf_ibus_x_key_event_generate(Window win,
731 event.x_root = 1; 739 event.x_root = 1;
732 event.y_root = 1; 740 event.y_root = 1;
733 event.same_screen = EINA_TRUE; 741 event.same_screen = EINA_TRUE;
734 event.state = modifiers; 742 if (keycode == -1)
735 event.keycode = XKeysymToKeycode(display, keysym); 743 {
744 event.keycode = XKeysymToKeycode(display, keysym);
745 event.state = 0;
746 }
747 else
748 {
749 event.keycode = keycode;
750 event.state = modifiers;
751 }
736 if (press) 752 if (press)
737 event.type = KeyPress; 753 event.type = KeyPress;
738 else 754 else
@@ -751,7 +767,7 @@ _ecore_imf_context_ibus_forward_key_event_cb(IBusInputContext *ibuscontext EINA
751{ 767{
752 EINA_LOG_DBG("keyval : %d, state : %d", keyval, state); 768 EINA_LOG_DBG("keyval : %d, state : %d", keyval, state);
753 769
754 _ecore_imf_ibus_key_event_put(keyval, state); 770 _ecore_imf_ibus_key_event_put(keyval, -1, state);
755} 771}
756 772
757static void 773static void