summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--legacy/ecore/src/lib/ecore_wayland/ecore_wl_input.c78
1 files changed, 43 insertions, 35 deletions
diff --git a/legacy/ecore/src/lib/ecore_wayland/ecore_wl_input.c b/legacy/ecore/src/lib/ecore_wayland/ecore_wl_input.c
index 0b6a6933cb..176c173518 100644
--- a/legacy/ecore/src/lib/ecore_wayland/ecore_wl_input.c
+++ b/legacy/ecore/src/lib/ecore_wayland/ecore_wl_input.c
@@ -510,41 +510,69 @@ _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard __UNUSE
510 Ecore_Wl_Window *win; 510 Ecore_Wl_Window *win;
511 unsigned int code, num; 511 unsigned int code, num;
512 const xkb_keysym_t *syms; 512 const xkb_keysym_t *syms;
513 xkb_keysym_t sym; 513 xkb_keysym_t sym = XKB_KEY_NoSymbol;
514 char string[32], key[32], keyname[32]; 514 xkb_mod_mask_t mask;
515 char string[32], key[32], keyname[32];// compose[32];
515 Ecore_Event_Key *e; 516 Ecore_Event_Key *e;
516 struct itimerspec ts; 517 struct itimerspec ts;
518 int len = 0;
517 519
518 LOGFN(__FILE__, __LINE__, __FUNCTION__); 520 LOGFN(__FILE__, __LINE__, __FUNCTION__);
519 521
520 if (!(input = data)) return; 522 if (!(input = data)) return;
521 input->display->serial = serial; 523 input->display->serial = serial;
524
525 /* xkb rules reflect X broken keycodes, so offset by 8 */
522 code = keycode + 8; 526 code = keycode + 8;
523 527
524 win = input->keyboard_focus; 528 win = input->keyboard_focus;
525 if ((!win) || (win->keyboard_device != input) || (!input->xkb.state)) 529 if ((!win) || (win->keyboard_device != input) || (!input->xkb.state))
526 return; 530 return;
527 531
528 num = xkb_key_get_syms(input->xkb.state, code, &syms); 532 mask = xkb_state_serialize_mods(input->xkb.state,
533 XKB_STATE_DEPRESSED | XKB_STATE_LATCHED);
529 534
530 xkb_state_update_key(input->xkb.state, code, 535 input->modifiers = 0;
531 (state ? XKB_KEY_DOWN : XKB_KEY_UP)); 536
537 /* The Ecore_Event_Modifiers don't quite match the X mask bits */
538 if (mask & input->xkb.control_mask)
539 input->modifiers |= MOD_CONTROL_MASK;
540 if (mask & input->xkb.alt_mask)
541 input->modifiers |= MOD_ALT_MASK;
542 if (mask & input->xkb.shift_mask)
543 input->modifiers |= MOD_SHIFT_MASK;
532 544
545 num = xkb_key_get_syms(input->xkb.state, code, &syms);
533 if (num == 1) sym = syms[0]; 546 if (num == 1) sym = syms[0];
534 else sym = XKB_KEY_NoSymbol;
535 547
536 memset(key, 0, sizeof(key)); 548 memset(key, 0, sizeof(key));
549 xkb_keysym_get_name(sym, key, sizeof(key));
550
537 memset(keyname, 0, sizeof(keyname)); 551 memset(keyname, 0, sizeof(keyname));
538 memset(string, 0, sizeof(string)); 552 xkb_keysym_get_name(sym, keyname, sizeof(keyname));
553 if (keyname[0] == '\0')
554 snprintf(keyname, sizeof(keyname), "Keycode-%i", code);
539 555
556 memset(string, 0, sizeof(string));
540 if (xkb_keysym_to_utf8(sym, string, 32) <= 0) 557 if (xkb_keysym_to_utf8(sym, string, 32) <= 0)
541 string[0] = '\0'; 558 {
559 /* FIXME: NB: We may need to add more checks here for other
560 * non-printable characters */
561 if ((sym == XKB_KEY_Tab) || (sym == XKB_KEY_ISO_Left_Tab))
562 string[len++] = '\t';
563 }
542 564
543 xkb_keysym_get_name(sym, key, sizeof(key)); 565 /* FIXME: NB: Start hacking on compose key support */
544 xkb_keysym_get_name(sym, keyname, sizeof(keyname)); 566 /* memset(compose, 0, sizeof(compose)); */
567 /* if (sym == XKB_KEY_Multi_key) */
568 /* { */
569 /* if (xkb_keysym_to_utf8(sym, compose, 32) <= 0) */
570 /* compose[0] = '\0'; */
571 /* } */
545 572
546 e = malloc(sizeof(Ecore_Event_Key) + strlen(keyname) + strlen(key) + 573 e = malloc(sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
547 strlen(string) + 3); 574 ((string[0] != '\0') ? strlen(string) : 0) + 3);
575 if (!e) return;
548 576
549 e->keyname = (char *)(e + 1); 577 e->keyname = (char *)(e + 1);
550 e->key = e->keyname + strlen(keyname) + 1; 578 e->key = e->keyname + strlen(keyname) + 1;
@@ -553,8 +581,7 @@ _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard __UNUSE
553 581
554 strcpy((char *)e->keyname, keyname); 582 strcpy((char *)e->keyname, keyname);
555 strcpy((char *)e->key, key); 583 strcpy((char *)e->key, key);
556 if (strlen (string)) 584 if (strlen(string)) strcpy((char *)e->string, string);
557 strcpy((char *)e->string, string);
558 585
559 e->window = win->id; 586 e->window = win->id;
560 e->event_window = win->id; 587 e->event_window = win->id;
@@ -603,30 +630,12 @@ static void
603_ecore_wl_input_cb_keyboard_modifiers(void *data, struct wl_keyboard *keyboard __UNUSED__, unsigned int serial __UNUSED__, unsigned int depressed, unsigned int latched, unsigned int locked, unsigned int group) 630_ecore_wl_input_cb_keyboard_modifiers(void *data, struct wl_keyboard *keyboard __UNUSED__, unsigned int serial __UNUSED__, unsigned int depressed, unsigned int latched, unsigned int locked, unsigned int group)
604{ 631{
605 Ecore_Wl_Input *input; 632 Ecore_Wl_Input *input;
606 xkb_mod_mask_t mask = 0;
607 633
608 LOGFN(__FILE__, __LINE__, __FUNCTION__); 634 LOGFN(__FILE__, __LINE__, __FUNCTION__);
609 635
610 if (!(input = data)) return; 636 if (!(input = data)) return;
611 if (input->xkb.state) 637 xkb_state_update_mask(input->xkb.state, depressed, latched,
612 { 638 locked, 0, 0, group);
613 xkb_state_update_mask(input->xkb.state, depressed, latched,
614 locked, 0, 0, group);
615
616 mask =
617 xkb_state_serialize_mods(input->xkb.state,
618 (XKB_STATE_DEPRESSED | XKB_STATE_LATCHED));
619 }
620
621 input->modifiers = 0;
622
623 /* The Ecore_Event_Modifiers don't quite match the X mask bits */
624 if (mask & input->xkb.control_mask)
625 input->modifiers |= MOD_CONTROL_MASK;
626 if (mask & input->xkb.alt_mask)
627 input->modifiers |= MOD_ALT_MASK;
628 if (mask & input->xkb.shift_mask)
629 input->modifiers |= MOD_SHIFT_MASK;
630} 639}
631 640
632static Eina_Bool 641static Eina_Bool
@@ -1073,7 +1082,6 @@ _ecore_wl_input_mouse_down_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, uns
1073 ev->y = input->sy; 1082 ev->y = input->sy;
1074 /* ev->root.x = input->sx; */ 1083 /* ev->root.x = input->sx; */
1075 /* ev->root.y = input->sy; */ 1084 /* ev->root.y = input->sy; */
1076 /* printf("Input Modifiers: %d\n", input->modifiers); */
1077 ev->modifiers = input->modifiers; 1085 ev->modifiers = input->modifiers;
1078 1086
1079 /* FIXME: Need to get these from wayland somehow */ 1087 /* FIXME: Need to get these from wayland somehow */