Modified to skip outdated touch events 68/96868/2
authorJi-hoon Lee <dalton.lee@samsung.com>
Thu, 10 Nov 2016 10:57:21 +0000 (19:57 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Thu, 10 Nov 2016 11:49:36 +0000 (20:49 +0900)
Change-Id: I35d2189b8be05411d63fbcfe3e4a2f1939c7aba8

scl/gwes/efl/sclevents-efl.cpp
scl/gwes/efl/sclwindows-efl.cpp
scl/scluibuilder.cpp

index 96f6b8b..c39551a 100644 (file)
@@ -65,6 +65,12 @@ typedef struct
 static sclboolean mouse_pressed = FALSE; /* Checks whether mouse is pressed or not */
 static sclwindow pressed_window = SCLWINDOW_INVALID;
 
+/* If the gap between two timestamps are bigger than 1 sec, do not compare */
+const unsigned int _touch_event_timestamp_compare_range = 1000;
+/* If the gap between two timestamps are smaller than 50 msec, do not process */
+const unsigned int _touch_event_timestamp_valid_threshold = 50;
+extern unsigned int g_timestamp_last_base_window_resized;
+
 #define MIN_XY_DIFF 14
 
 static Eina_Bool mouse_press(void *data, int type, void *event_info);
@@ -345,6 +351,24 @@ SclPoint get_rotated_local_coords(sclint x, sclint y, SCLRotation rotation, SclR
     return ret;
 }
 
+static Eina_Bool check_timestamp_outdated(unsigned int timestamp)
+{
+    /* Skip events that were generated nearly at the same time when our base window resized */
+    timestamp -= _touch_event_timestamp_valid_threshold;
+    unsigned int gap = (g_timestamp_last_base_window_resized > timestamp) ?
+        (g_timestamp_last_base_window_resized - timestamp) :
+        (timestamp - g_timestamp_last_base_window_resized);
+    if (gap < _touch_event_timestamp_compare_range) {
+        if (g_timestamp_last_base_window_resized > timestamp) {
+            /* This event was generated before the base window resize event, ignore */
+            LOGD("Skipping event since turned out to be outdated : %u, %u",
+                    g_timestamp_last_base_window_resized, timestamp);
+            return EINA_TRUE;
+        }
+    }
+    return EINA_FALSE;
+}
+
 //void mouse_press (void *data, Evas *e, Evas_Object *object, void *event_info)
 static Eina_Bool mouse_press(void *data, int type, void *event_info)
 {
@@ -363,8 +387,13 @@ static Eina_Bool mouse_press(void *data, int type, void *event_info)
 
     Ecore_Event_Mouse_Button *ev = (Ecore_Event_Mouse_Button*)event_info;
 
+    if (ev && check_timestamp_outdated(ev->timestamp)) {
+        return TRUE;
+    }
+
     if (controller && windows && context && utils && adjustment && ev) {
-        LOGD("mouse_press : %d %d, %d %d\n", ev->root.x, ev->root.y, ev->x, ev->y);
+        LOGD("mouse_press : %d %d, %d %d, %d %d\n", ev->root.x, ev->root.y, ev->x, ev->y,
+                g_timestamp_last_base_window_resized, ev->timestamp);
 
         sclbyte index = 0;
         sclboolean processed = FALSE;
@@ -560,6 +589,9 @@ static Eina_Bool mouse_release(void *data, int type, void *event_info)
     Ecore_Event_Mouse_Button *ev = (Ecore_Event_Mouse_Button*)event_info;
 
     //if (!mouse_pressed) return FALSE;
+    if (ev && check_timestamp_outdated(ev->timestamp)) {
+        return TRUE;
+    }
 
     if (controller && windows && context && ev) {
         LOGD("mouse_release : %d %d, %d %d\n", ev->root.x, ev->root.y, ev->x, ev->y);
@@ -798,6 +830,9 @@ static Eina_Bool mouse_move(void *data, int type, void *event_info)
     Ecore_Event_Mouse_Move *ev = (Ecore_Event_Mouse_Move*)event_info;
 
     //if (!mouse_pressed) return FALSE;
+    if (ev && check_timestamp_outdated(ev->timestamp)) {
+        return TRUE;
+    }
 
     if (controller && windows && context && cache && ev) {
         sclbyte index = 0;
index 9fd8b93..b8a8c8c 100644 (file)
@@ -64,6 +64,11 @@ extern std::vector<TextCache> g_TextCache;
 #else
 #endif
 
+/* When the base window is resized, any mouse events generated before this timestamp value
+ * that are waiting in the event queue, could be considered as outdated so we are going to
+ * skip those events */
+unsigned int g_timestamp_last_base_window_resized = 0;
+
 /**
  * Constructor
  */
@@ -810,6 +815,8 @@ CSCLWindowsImplEfl::resize_window(const sclwindow window, scl16 width, scl16 hei
     if (windows && window) {
         if (window != windows->get_base_window()) {
             evas_object_resize(win, width, height);
+        } else {
+            g_timestamp_last_base_window_resized = (unsigned int)(ecore_loop_time_get() * 1000.0f);
         }
 
         if (window == windows->get_dim_window()) {
index c29dfd1..7d97180 100644 (file)
@@ -980,6 +980,7 @@ CSCLUIBuilder::show_magnifier(const sclwindow window, scldrawctx draw_ctx)
     SCL_DEBUG();
     scl_assert_return_false(window);
 
+
     CSCLUtils *utils = CSCLUtils::get_instance();
     CSCLContext *context = CSCLContext::get_instance();
     CSCLResourceCache *cache = CSCLResourceCache::get_instance();
@@ -988,6 +989,7 @@ CSCLUIBuilder::show_magnifier(const sclwindow window, scldrawctx draw_ctx)
 
     if (!utils || !context || !cache || !state || !windows) return FALSE;
 
+    utils->log("show_magnifier");
     sclwindow pressed_window = context->get_cur_pressed_window(context->get_last_touch_device_id());
     scl8 pressed_key = context->get_cur_pressed_key(context->get_last_touch_device_id());