ecore-input-evas: fix canvas mouse event dispatch

this was broken in 5cb6cdbc5e such that
when multiple sources produce mouse events using the same device,
these events are marshalled as though they were from the same canvas.
the result is that eventing is wrong on at least one of the canvases,
and spurious mouse-up events are triggered before every mouse down

fix T2509
This commit is contained in:
Mike Blumenkrantz 2015-07-07 14:15:29 -04:00
parent e9688e63a5
commit fbb462371f
1 changed files with 13 additions and 7 deletions

View File

@ -48,6 +48,7 @@ struct _Ecore_Input_Last
unsigned int device;
unsigned int buttons;
Ecore_Input_State state;
Ecore_Window win;
Eina_Bool faked : 1;
};
@ -118,7 +119,7 @@ _ecore_event_last_check(Ecore_Event_Last *eel, Ecore_Event_Press press)
}
static Ecore_Event_Last *
_ecore_event_evas_lookup(unsigned int device, unsigned int buttons, Eina_Bool create_new)
_ecore_event_evas_lookup(unsigned int device, unsigned int buttons, Ecore_Window win, Eina_Bool create_new)
{
Ecore_Event_Last *eel;
Eina_List *l;
@ -137,6 +138,7 @@ _ecore_event_evas_lookup(unsigned int device, unsigned int buttons, Eina_Bool cr
eel->buttons = buttons;
eel->state = ECORE_INPUT_NONE;
eel->faked = EINA_FALSE;
eel->win = win;
_last_events = eina_list_append(_last_events, eel);
return eel;
@ -174,14 +176,15 @@ static Eina_Bool
_ecore_event_evas_push_mouse_button(Ecore_Event_Mouse_Button *e, Ecore_Event_Press press)
{
Ecore_Event_Last *eel;
Ecore_Input_Action action;
Ecore_Input_Action action = ECORE_INPUT_CONTINUE;
//_ecore_event_evas_mouse_button already check press or cancel without history
eel = _ecore_event_evas_lookup(e->multi.device, e->buttons, EINA_TRUE);
eel = _ecore_event_evas_lookup(e->multi.device, e->buttons, e->window, EINA_TRUE);
if (!eel) return EINA_FALSE;
INF("dev(%d), button(%d), last_press(%d), press(%d)", e->multi.device, e->buttons, eel->state, press);
action = _ecore_event_last_check(eel, press);
if (e->window == eel->win)
action = _ecore_event_last_check(eel, press);
INF("action(%d)", action);
switch (action)
{
@ -191,6 +194,7 @@ _ecore_event_evas_push_mouse_button(Ecore_Event_Mouse_Button *e, Ecore_Event_Pre
break;
case ECORE_INPUT_IGNORE:
default:
eel->win = e->window;
return EINA_FALSE;
}
@ -205,6 +209,7 @@ _ecore_event_evas_push_mouse_button(Ecore_Event_Mouse_Button *e, Ecore_Event_Pre
default:
break;
}
eel->win = e->window;
//if up event not occurs from under layers of ecore
//up event is generated by ecore
@ -456,15 +461,16 @@ _ecore_event_evas_mouse_button(Ecore_Event_Mouse_Button *e, Ecore_Event_Press pr
if (press != ECORE_DOWN)
{
//ECORE_UP or ECORE_CANCEL
eel = _ecore_event_evas_lookup(e->multi.device, e->buttons, EINA_FALSE);
eel = _ecore_event_evas_lookup(e->multi.device, e->buttons, e->window, EINA_FALSE);
if (!eel)
{
WRN("ButtonEvent has no history.");
return ECORE_CALLBACK_PASS_ON;
}
if ((eel->state == ECORE_INPUT_UP) ||
(eel->state == ECORE_INPUT_CANCEL))
if ((e->window == eel->win) &&
((eel->state == ECORE_INPUT_UP) ||
(eel->state == ECORE_INPUT_CANCEL)))
{
WRN("ButtonEvent has wrong history. Last state=%d", eel->state);
return ECORE_CALLBACK_PASS_ON;