Modify ecore_wl_input keypress code to handle modifiers Not on every
authorChris Michael <cp.michael@samsung.com>
Fri, 7 Jun 2013 14:32:19 +0000 (15:32 +0100)
committerChris Michael <cp.michael@samsung.com>
Fri, 7 Jun 2013 14:42:53 +0000 (15:42 +0100)
keypress, but rather Only on they actual modifier event.

Add some printf debugging for Non-Printables like Ctrl, etc

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/lib/ecore_wayland/ecore_wl_input.c

index 47aa84f..e07804a 100644 (file)
@@ -590,7 +590,6 @@ _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard EINA_UN
    unsigned int code, num;
    const xkb_keysym_t *syms;
    xkb_keysym_t sym = XKB_KEY_NoSymbol;
-   xkb_mod_mask_t mask;
    char string[32], key[32], keyname[32];// compose[32];
    Ecore_Event_Key *e;
    struct itimerspec ts;
@@ -608,20 +607,9 @@ _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard EINA_UN
    if ((!win) || (win->keyboard_device != input) || (!input->xkb.state)) 
      return;
 
-   mask = xkb_state_serialize_mods(input->xkb.state, 
-                                   XKB_STATE_DEPRESSED | XKB_STATE_LATCHED);
-
-   input->modifiers = 0;
-
-   /* The Ecore_Event_Modifiers don't quite match the X mask bits */
-   if (mask & input->xkb.control_mask)
-     input->modifiers |= ECORE_EVENT_MODIFIER_CTRL;
-   if (mask & input->xkb.alt_mask)
-     input->modifiers |= ECORE_EVENT_MODIFIER_ALT;
-   if (mask & input->xkb.shift_mask)
-     input->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
-
    num = xkb_key_get_syms(input->xkb.state, code, &syms);
+
+   sym = XKB_KEY_NoSymbol;
    if (num == 1) sym = syms[0];
 
    memset(key, 0, sizeof(key));
@@ -639,6 +627,14 @@ _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard EINA_UN
          * non-printable characters */
         if ((sym == XKB_KEY_Tab) || (sym == XKB_KEY_ISO_Left_Tab)) 
           string[len++] = '\t';
+        /* else if ((sym == XKB_KEY_Control_L) || (sym == XKB_KEY_Control_R)) */
+        /*   string[len++] = '\'; */
+        else
+          {
+             printf("Non Printable Key\n");
+             printf("\tKey: %s\n", key);
+             printf("\tKeyname: %s\n", keyname);
+          }
      }
 
    /* FIXME: NB: Start hacking on compose key support */
@@ -685,9 +681,9 @@ _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard EINA_UN
 
         timerfd_settime(input->repeat.timerfd, 0, &ts, NULL);
      }
-   else if ((state) && 
-            ((!input->repeat.key) || 
-                ((keycode) && (keycode != input->repeat.key))))
+   else if ((state)) //&& 
+            /* ((!input->repeat.key) ||  */
+            /*     ((keycode) && (keycode != input->repeat.key)))) */
      {
         input->repeat.sym = sym;
         input->repeat.key = keycode;
@@ -709,12 +705,26 @@ static void
 _ecore_wl_input_cb_keyboard_modifiers(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial EINA_UNUSED, unsigned int depressed, unsigned int latched, unsigned int locked, unsigned int group)
 {
    Ecore_Wl_Input *input;
+   xkb_mod_mask_t mask;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
    if (!(input = data)) return;
+
    xkb_state_update_mask(input->xkb.state, depressed, latched, 
                          locked, 0, 0, group);
+
+   mask = xkb_state_serialize_mods(input->xkb.state, 
+                                   XKB_STATE_DEPRESSED | XKB_STATE_LATCHED);
+
+   input->modifiers = 0;
+   /* The Ecore_Event_Modifiers don't quite match the X mask bits */
+   if (mask & input->xkb.control_mask)
+     input->modifiers |= ECORE_EVENT_MODIFIER_CTRL;
+   if (mask & input->xkb.alt_mask)
+     input->modifiers |= ECORE_EVENT_MODIFIER_ALT;
+   if (mask & input->xkb.shift_mask)
+     input->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
 }
 
 static Eina_Bool