Fix backspace key repeat issue in multibutton entry
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 20 Mar 2017 09:13:33 +0000 (18:13 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 21 Mar 2017 05:56:51 +0000 (14:56 +0900)
backspace key down event was delivered after focus out event,
but key up event was delivered after focus in event.
key down event without key up event leads to repeat key event.
To avoid this key repeat issue, key down and up event will be added sequently.

Change-Id: I7342b36a6a6482b5e93b1d785f3bc4343243faed
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/e_mod_main.c

index f6cc48a..660e12e 100644 (file)
@@ -689,6 +689,24 @@ _e_keyevent_free(void *data EINA_UNUSED, void *ev)
 }
 
 static void
+feed_key_event(const char *keyname, const char *key, const char *string, int keycode, int state)
+{
+   Ecore_Event_Key *e = E_NEW(Ecore_Event_Key, 1);
+   if (!e) return;
+
+   e->keyname = (char *)eina_stringshare_add(keyname);
+   e->key = (char *)eina_stringshare_add(key);
+   e->string = (char *)eina_stringshare_add(string);
+   e->compose = (char *)eina_stringshare_add(e->string);
+
+   e->timestamp = 0; /* For distinguishing S/W keyboard event */
+   e->same_screen = 1;
+   e->keycode = keycode;
+
+   ecore_event_add(state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_keyevent_free, NULL);
+}
+
+static void
 _e_text_input_method_context_cb_keysym(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers)
 {
    E_Input_Method_Context *context = wl_resource_get_user_data(resource);
@@ -709,10 +727,6 @@ _e_text_input_method_context_cb_keysym(struct wl_client *client EINA_UNUSED, str
    else
      {
         char string[32], key[32], keyname[32];
-        Ecore_Event_Key *e = NULL;
-
-        memset(key, 0, sizeof(key));
-        xkb_keysym_get_name(sym, key, sizeof(key));
 
         memset(keyname, 0, sizeof(keyname));
         xkb_keysym_get_name(sym, keyname, sizeof(keyname));
@@ -721,25 +735,20 @@ _e_text_input_method_context_cb_keysym(struct wl_client *client EINA_UNUSED, str
 
         if (strcmp(keyname, "BackSpace") == 0)
           {
+             /* backspace key should be supported in the multibutton entry of elementary
+                even though it losts focus */
+             memset(key, 0, sizeof(key));
+             xkb_keysym_get_name(sym, key, sizeof(key));
+
              memset(string, 0, sizeof(string));
              xkb_keysym_to_utf8(sym, string, 32);
 
-             e = E_NEW(Ecore_Event_Key, 1);
-             if (!e) return;
-
-             e->keyname = (char *)eina_stringshare_add(keyname);
-             e->key = (char *)eina_stringshare_add(key);
-             e->string = (char *)eina_stringshare_add(string);
-             e->compose = (char *)eina_stringshare_add(e->string);
-
-             e->timestamp = 0; /* For distinguishing S/W keyboard event */
-             e->same_screen = 1;
-             e->keycode = 22; /* Backspace keycode */
-
              if (state)
-               ecore_event_add(ECORE_EVENT_KEY_DOWN, e, _e_keyevent_free, NULL);
-             else
-               ecore_event_add(ECORE_EVENT_KEY_UP, e, _e_keyevent_free, NULL);
+               {
+                  /* Backspace keycode (22) */
+                  feed_key_event(keyname, key, string, 22, 1); /* key down */
+                  feed_key_event(keyname, key, string, 22, 0); /* key up */
+               }
           }
      }
 }