Enable/Disable the gesture module after all finger is released 76/100476/3
authorJengHyun Kang <jhyuni.kang@samsung.com>
Mon, 28 Nov 2016 08:47:46 +0000 (17:47 +0900)
committerJengHyun Kang <jhyuni.kang@samsung.com>
Mon, 28 Nov 2016 09:40:44 +0000 (18:40 +0900)
Change-Id: If8c9f8a3cb3fbae4a83457b304a200402a8458dc

src/e_mod_gesture_events.c
src/e_mod_main.c
src/e_mod_main.h

index 076166e..6004cf0 100644 (file)
@@ -326,8 +326,12 @@ _e_gesture_process_mouse_button_up(void *event)
 {
    Ecore_Event_Mouse_Button *ev = event;
 
-   gesture->gesture_events.num_pressed--;
+   if (gesture->gesture_events.num_pressed == 0)
+     {
+        return EINA_TRUE;
+     }
 
+   gesture->gesture_events.num_pressed--;
    if (!gesture->grabbed_gesture)
      {
         return EINA_TRUE;
@@ -342,6 +346,14 @@ _e_gesture_process_mouse_button_up(void *event)
         if (gesture->gesture_events.num_pressed == 0)
           {
              gesture->gesture_events.recognized_gesture = 0x0;
+             if (gesture->enable)
+               {
+                  e_gesture_event_filter_enable(EINA_TRUE);
+               }
+             else
+               {
+                  e_gesture_event_filter_enable(EINA_FALSE);
+               }
           }
         return EINA_FALSE;
      }
@@ -360,6 +372,10 @@ _e_gesture_process_mouse_move(void *event)
 {
    Ecore_Event_Mouse_Move *ev = event;
 
+   if (gesture->gesture_events.num_pressed == 0)
+     {
+        return EINA_TRUE;
+     }
    if (!gesture->grabbed_gesture)
      {
         return EINA_TRUE;
index 41999b1..e32d6d1 100644 (file)
@@ -308,12 +308,11 @@ _e_gesture_cb_bind(struct wl_client *client, void *data, uint32_t version, uint3
    wl_resource_set_implementation(resource, &_e_gesture_implementation, gesture_instance, _e_gesture_cb_destory);
 }
 
-
-
 static Eina_Bool
 _e_gesture_event_filter(void *data, void *loop_data EINA_UNUSED, int type, void *event)
 {
    (void) data;
+   if (!gesture->enable) return EINA_TRUE;
 
    return e_gesture_process_events(event, type);
 }
@@ -331,18 +330,20 @@ _e_gesture_cb_client_focus_in(void *data, int type, void *event)
 
    if (ec->gesture_disable && gesture->enable)
      {
-        GTINF("Disable gesture\n");
-        ecore_event_filter_del(gesture->ef_handler);
-        gesture->ef_handler = NULL;
+        GTINF("Gesture disabled window\n");
         gesture->enable = EINA_FALSE;
      }
    else if (!ec->gesture_disable && !gesture->enable)
      {
-        GTINF("enable gesture\n");
-        gesture->ef_handler = ecore_event_filter_add(NULL, _e_gesture_event_filter, NULL, NULL);
+        GTINF("Gesture enabled window\n");
         gesture->enable = EINA_TRUE;
      }
 
+   if (gesture->gesture_events.num_pressed == 0)
+     {
+        e_gesture_event_filter_enable(gesture->enable);
+     }
+
    return ECORE_CALLBACK_PASS_ON;
 }
 
@@ -498,3 +499,18 @@ out:
           }
      }
 }
+
+void
+e_gesture_event_filter_enable(Eina_Bool enabled)
+{
+   if (enabled && !gesture->enable)
+     {
+        GTINF("Gestures will be enabled by for now.\n");
+        gesture->enable = EINA_TRUE;
+     }
+   else if (!enabled && gesture->enable)
+     {
+        GTINF("Gestures will be enabled from now.\n");
+        gesture->enable = EINA_FALSE;
+     }
+}
\ No newline at end of file
index 2f552f4..7d8e2d3 100644 (file)
@@ -174,4 +174,6 @@ Eina_Bool e_gesture_device_del(Ecore_Event_Device_Info *ev);
 Eina_Bool e_gesture_is_touch_device(const Ecore_Device *dev);
 void e_gesture_device_keydev_set(char *option);
 
+void e_gesture_event_filter_enable(Eina_Bool enabled);
+
 #endif