ecore_wl2: Fix dnd breakage when focus leaves window
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>
Mon, 27 Jun 2016 15:31:59 +0000 (11:31 -0400)
committerChris Michael <cpmichael@osg.samsung.com>
Mon, 27 Jun 2016 15:32:18 +0000 (11:32 -0400)
Summary:
If dnd in the same window is activated, the focus goes away from the
ecore_wl2 window to the dnd window, after that focus.pointer is NULL.
After focus.pointer is NULL ev->win of all the events will be 0 which
breaks dnd-motions, drop and end.

With prev_pointer beeing the last focused window, we can simply set this
window as event window. After that dnd with jesus works perfectly.

@fix

Reviewers: devilhorns

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D4093

src/lib/ecore_wl2/ecore_wl2_dnd.c
src/lib/ecore_wl2/ecore_wl2_input.c
src/lib/ecore_wl2/ecore_wl2_private.h

index e9feb12..e35a5cd 100644 (file)
@@ -147,6 +147,8 @@ data_source_event_emit(Ecore_Wl2_Input *input, int event)
 
    if (input->focus.pointer)
      ev->win = input->focus.pointer->id;
+   else if (input->focus.prev_pointer)
+     ev->win = input->focus.prev_pointer->id;
    if (input->focus.keyboard)
      ev->source = input->focus.keyboard->id;
 
@@ -360,6 +362,8 @@ _ecore_wl2_dnd_leave(Ecore_Wl2_Input *input)
 
    if (input->focus.pointer)
      ev->win = input->focus.pointer->id;
+   else if (input->focus.prev_pointer)
+     ev->win = input->focus.prev_pointer->id;
    if (input->focus.keyboard)
      ev->source = input->focus.keyboard->id;
 
@@ -381,6 +385,8 @@ _ecore_wl2_dnd_motion(Ecore_Wl2_Input *input, int x, int y, uint32_t serial)
 
    if (input->focus.pointer)
      ev->win = input->focus.pointer->id;
+   else if (input->focus.prev_pointer)
+     ev->win = input->focus.prev_pointer->id;
    if (input->focus.keyboard)
      ev->source = input->focus.keyboard->id;
 
@@ -405,6 +411,8 @@ _ecore_wl2_dnd_drop(Ecore_Wl2_Input *input)
      {
         if (input->focus.pointer)
           ev->win = input->focus.pointer->id;
+        else if (input->focus.prev_pointer)
+          ev->win = input->focus.prev_pointer->id;
         if (input->focus.keyboard)
           ev->source = input->focus.keyboard->id;
 
@@ -562,6 +570,8 @@ ecore_wl2_dnd_drag_end(Ecore_Wl2_Input *input)
 
    if (input->focus.pointer)
      ev->win = input->focus.pointer->id;
+   else if (input->focus.prev_pointer)
+     ev->win = input->focus.prev_pointer->id;
    if (input->focus.keyboard)
      ev->source = input->focus.keyboard->id;
 
index e86936c..7a5899f 100644 (file)
@@ -514,6 +514,7 @@ _pointer_cb_enter(void *data, struct wl_pointer *pointer EINA_UNUSED, unsigned i
    if (!window) return;
 
    window->input = input;
+   input->focus.prev_pointer = NULL;
    input->focus.pointer = window;
 
    _ecore_wl2_input_mouse_in_send(input, window);
@@ -536,6 +537,7 @@ _pointer_cb_leave(void *data, struct wl_pointer *pointer EINA_UNUSED, unsigned i
    if (!input) return;
 
    input->display->serial = serial;
+   input->focus.prev_pointer = input->focus.pointer;
    input->focus.pointer = NULL;
 
    /* trap for a surface that was just destroyed */
index fce1245..4f5a441 100644 (file)
@@ -370,6 +370,7 @@ struct _Ecore_Wl2_Input
    struct
      {
         Ecore_Wl2_Window *pointer;
+        Ecore_Wl2_Window *prev_pointer;
         Ecore_Wl2_Window *keyboard;
         Ecore_Wl2_Window *touch;
      } focus;