Fix mouse touch event processing bug.
authorSung-jae Park <nicesj.park@samsung.com>
Wed, 22 Apr 2015 06:17:17 +0000 (15:17 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Wed, 22 Apr 2015 06:17:17 +0000 (15:17 +0900)
When a user touch the screen (down & up), the master activate the thread and deactivate it shortly.
while processing this, the input thread's state machine goes wrong.

[model] Redwood,Kiran,B3(Wearable)
[binary_type] AP
[customer] Docomo/Orange/ATT/Open
[issue#] N/A
[problem]
[cause]
[solution]
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: Ib911c542456d37a5d5078f40d2c1c36ecf83bb2c

include/event.h
src/event.c
src/server.c

index 81ce421..b16ce31 100644 (file)
@@ -61,4 +61,6 @@ extern int event_reset_cbdata(int (*event_cb)(enum event_state state, struct eve
 extern int event_deactivate_thread(enum event_handler_activate_type activate_type);
 extern int event_activate_thread(enum event_handler_activate_type activate_type);
 
+extern void event_set_mouse_xy(int x, int y, double timestamp);
+
 /* End of a file */
index 6d64f1c..1fd139a 100644 (file)
@@ -666,6 +666,7 @@ static Eina_Bool event_read_cb(void *data, Ecore_Fd_Handler *handler)
        Eina_List *l;
        Eina_List *n;
        enum event_state next_state;
+       int state;
 
        fd = ecore_main_fd_handler_fd_get(handler);
        if (fd < 0) {
@@ -734,14 +735,39 @@ static Eina_Bool event_read_cb(void *data, Ecore_Fd_Handler *handler)
                case EVENT_STATE_DEACTIVATE:
                        if (compare_timestamp(listener, item) < 0) {
                                /* Consuming all events occurred while activating this listener */
+                               state = listener->prev_state;
                                listener->prev_state = listener->state;
-                               listener->state = EVENT_STATE_ACTIVATED;
+
+                               if (state == EVENT_STATE_ACTIVATE) {
+                                       /**
+                                        * @note
+                                        * If the previous state is ACTIVATE
+                                        * We should create DOWN event first.
+                                        */
+                                       listener->state = EVENT_STATE_ACTIVATE;
+                               } else {
+                                       listener->state = EVENT_STATE_ACTIVATED;
+                               }
+
                                if (invoke_event_cb(listener, item) == 1) {
                                        /* listener is deleted */
                                        continue;
                                }
 
-                               listener->prev_state = listener->state;
+                               if (listener->state == EVENT_STATE_ACTIVATE) {
+                                       /**
+                                        * We are already jumped into the DEACTIVATE state
+                                        * But the state is ACTIVATE, it means, we forcely chnaged it from LINE 747
+                                        * We successfully sent the DOWN event.
+                                        * We only need to send UP (or move) event.
+                                        * So change the previous states to ACTIVATED and then change current states to
+                                        * DEACTIVATE again.
+                                        */
+                                       listener->prev_state = EVENT_STATE_ACTIVATED;
+                               } else {
+                                       listener->prev_state = listener->state;
+                               }
+
                                listener->state = EVENT_STATE_DEACTIVATE;
                        } else {
                                memcpy(&s_info.skipped_event_data, item, sizeof(s_info.skipped_event_data));
@@ -1065,4 +1091,18 @@ HAPI int event_is_activated(void)
        return s_info.handle >= 0;
 }
 
+HAPI void event_set_mouse_xy(int x, int y, double timestamp)
+{
+       s_info.event_data.x = x;
+       s_info.event_data.y = y;
+       s_info.event_data.tv = timestamp;
+       /**
+        * Don't touch the timestamp_updated variable.
+        * if we toggle it, the input thread will not be terminated correctly. SEE LINE: 537
+       if (!s_info.timestamp_updated) {
+               // NOP
+       }
+        */
+}
+
 /* End of a file */
index 7486366..201885a 100644 (file)
@@ -2264,6 +2264,9 @@ static struct packet *client_widget_mouse_unset(pid_t pid, int handle, const str
 
        if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
                if (package_direct_input(pkg) == 0) {
+                       /* Forcely update the X,Y position using viewer's */
+                       event_set_mouse_xy(x, y, timestamp);
+
                        ret = event_deactivate(mouse_event_widget_route_cb, inst);
                        if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
                                (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_OFF);
@@ -2288,6 +2291,9 @@ static struct packet *client_widget_mouse_unset(pid_t pid, int handle, const str
                        }
                }
        } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
+               /* Forcely update the X,Y position using viewer's */
+               event_set_mouse_xy(x, y, timestamp);
+
                ret = event_deactivate(mouse_event_widget_consume_cb, inst);
                if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
                        (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_OFF);
@@ -2853,6 +2859,9 @@ static struct packet *client_gbar_mouse_unset(pid_t pid, int handle, const struc
 
        if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
                if (package_direct_input(pkg) == 0) {
+                       /* Forcely update the X,Y position using viewer's */
+                       event_set_mouse_xy(x, y, timestamp);
+
                        ret = event_deactivate(mouse_event_gbar_route_cb, inst);
                        if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
                                (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_OFF);
@@ -2877,6 +2886,9 @@ static struct packet *client_gbar_mouse_unset(pid_t pid, int handle, const struc
                        }
                }
        } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
+               /* Forcely update the X,Y position using viewer's */
+               event_set_mouse_xy(x, y, timestamp);
+
                ret = event_deactivate(mouse_event_gbar_consume_cb, inst);
                if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
                        (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_OFF);