ecore_wl2_input: fix issue to deliver same timestamp 00/290300/2 accepted/tizen/unified/20230329.013238
authorJihoon Kim <jihoon48.kim@samsung.com>
Thu, 23 Mar 2023 02:54:26 +0000 (11:54 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 23 Mar 2023 08:23:51 +0000 (08:23 +0000)
Change-Id: Ib32c7e8c7f3b072e7e87a8413941f96225775179
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/lib/ecore_wl2/ecore_wl2_input.c

index bceb10f..a2d680c 100644 (file)
@@ -85,6 +85,14 @@ static void _keyboard_cb_key(void *data, struct wl_keyboard *keyboard EINA_UNUSE
 static void _cb_pointer_frame(void *data, struct wl_callback *callback, unsigned int timestamp EINA_UNUSED);
 //
 
+static unsigned int _timestamp_get()
+{
+   struct timespec ts;
+   clock_gettime(CLOCK_MONOTONIC, &ts);
+
+   return ts.tv_sec * 1000 + (ts.tv_nsec / 1000000);
+}
+
 // TIZEN ONLY(20160223) : Add back/menu/home key conversion support
 static int
 _ecore_wl2_input_convert_old_keys(unsigned int code)
@@ -1807,7 +1815,7 @@ _touch_cb_cancel(void *data, struct wl_touch *touch EINA_UNUSED)
    if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) return;
    EINA_SAFETY_ON_NULL_RETURN(ev);
 
-   ev->timestamp = (int)(ecore_time_get()*1000);
+   ev->timestamp = _timestamp_get();
    ev->same_screen = 1;
    ev->window = input->focus.touch->id;
    ev->event_window = ev->window;
@@ -3528,7 +3536,7 @@ _ecore_wl2_input_device_cb_axis(void *data, struct tizen_input_device *tizen_inp
              e->direction = ECORE_DETENT_DIRECTION_CLOCKWISE;
            else
              e->direction = ECORE_DETENT_DIRECTION_COUNTER_CLOCKWISE;
-           e->timestamp = (int)(ecore_time_get() * 1000.0);
+           e->timestamp = _timestamp_get();
            DBG("detent: dir: %d, time: %d", e->direction, e->timestamp);
            ecore_event_add(ECORE_EVENT_DETENT_ROTATE, e, _ecore_wl2_input_detent_rotate_free, NULL);
            break;