ecore-wl2: Fix issue(s) of setting wrong event device
authorChris Michael <cp.michael@samsung.com>
Tue, 20 Jun 2017 15:59:36 +0000 (11:59 -0400)
committerChris Michael <cp.michael@samsung.com>
Tue, 20 Jun 2017 15:59:36 +0000 (11:59 -0400)
As we may have both a pointer and touch device on a given system, we
need to accurately set event->device when sending mouse move, wheel,
down, and up events. Previous code here would always try to find a
mouse device first which could potentially end up setting the wrong
event->device (if a touch device also existed).

This patch fixes the issue by comparing the window used for the event
to our focused windows (either mouse or touch) and setting the proper
event->device based on that.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/lib/ecore_wl2/ecore_wl2_input.c

index c544a89..8eef015 100644 (file)
@@ -205,9 +205,11 @@ _ecore_wl2_input_mouse_move_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *windo
    ev->multi.y = input->pointer.sy;
    ev->multi.root.x = input->pointer.sx;
    ev->multi.root.y = input->pointer.sy;
-   ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
-   if (!ev->dev)
+
+   if ((input->focus.touch) && (input->focus.touch == window))
      ev->dev = _ecore_wl2_touch_dev_get(input, window->id);
+   else if ((input->focus.pointer) && (input->focus.pointer == window))
+     ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
 
    info = _ecore_wl2_input_mouse_down_info_get(device);
    if (info)
@@ -252,16 +254,21 @@ _ecore_wl2_input_mouse_wheel_send(Ecore_Wl2_Input *input, unsigned int axis, int
      {
         ev->window = input->focus.pointer->id;
         ev->event_window = input->focus.pointer->id;
+        ev->dev = _ecore_wl2_mouse_dev_get(input, input->focus.pointer->id);
      }
    else if (input->focus.touch)
      {
         ev->window = input->focus.touch->id;
         ev->event_window = input->focus.touch->id;
+        ev->dev = _ecore_wl2_touch_dev_get(input, input->focus.touch->id);
      }
 
-   ev->dev = _ecore_wl2_mouse_dev_get(input, ev->window);
    if (!ev->dev)
-     ev->dev = _ecore_wl2_touch_dev_get(input, ev->window);
+     {
+        ev->dev = _ecore_wl2_mouse_dev_get(input, ev->window);
+        if (!ev->dev)
+          ev->dev = _ecore_wl2_touch_dev_get(input, ev->window);
+     }
 
    ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _input_event_cb_free, ev->dev);
 }
@@ -351,9 +358,11 @@ _ecore_wl2_input_mouse_down_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *windo
      {
         ev->window = window->id;
         ev->event_window = window->id;
-        ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
-        if (!ev->dev)
+
+        if ((input->focus.touch) && (input->focus.touch == window))
           ev->dev = _ecore_wl2_touch_dev_get(input, window->id);
+        else if ((input->focus.pointer) && (input->focus.pointer == window))
+          ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
      }
 
    ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev,
@@ -425,9 +434,11 @@ _ecore_wl2_input_mouse_up_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window,
 
    ev->window = window->id;
    ev->event_window = window->id;
-   ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
-   if (!ev->dev)
+
+   if ((input->focus.touch) && (input->focus.touch == window))
      ev->dev = _ecore_wl2_touch_dev_get(input, window->id);
+   else if ((input->focus.pointer) && (input->focus.pointer == window))
+     ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
 
    ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev,
                    _input_event_cb_free, ev->dev);