forked from enlightenment/efl
ecore_wl2: ref / unref evas devices on ecore events
Summary: It should avoid issues when device is removed after the ecore event addition but before listeners are called (so pointer would be invalid). Reviewers: iscaro Reviewed By: iscaro Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4407
This commit is contained in:
parent
f50b0fed13
commit
6f66c6e676
|
@ -86,12 +86,20 @@ _ecore_wl2_mouse_dev_get(Ecore_Wl2_Input *input, int window_id)
|
||||||
Ecore_Wl2_Input_Devices *devices;
|
Ecore_Wl2_Input_Devices *devices;
|
||||||
|
|
||||||
devices = _ecore_wl2_devices_get(input, window_id);
|
devices = _ecore_wl2_devices_get(input, window_id);
|
||||||
if (devices)
|
if (devices && devices->pointer_dev)
|
||||||
return devices->pointer_dev;
|
return efl_ref(devices->pointer_dev);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_input_event_cb_free(void *data, void *event)
|
||||||
|
{
|
||||||
|
if (data)
|
||||||
|
efl_unref(data);
|
||||||
|
free(event);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_wl2_input_mouse_in_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window)
|
_ecore_wl2_input_mouse_in_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window)
|
||||||
{
|
{
|
||||||
|
@ -108,7 +116,7 @@ _ecore_wl2_input_mouse_in_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window)
|
||||||
ev->modifiers = input->keyboard.modifiers;
|
ev->modifiers = input->keyboard.modifiers;
|
||||||
ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
|
ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
|
||||||
|
|
||||||
ecore_event_add(ECORE_EVENT_MOUSE_IN, ev, NULL, NULL);
|
ecore_event_add(ECORE_EVENT_MOUSE_IN, ev, _input_event_cb_free, ev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -127,7 +135,7 @@ _ecore_wl2_input_mouse_out_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window
|
||||||
ev->modifiers = input->keyboard.modifiers;
|
ev->modifiers = input->keyboard.modifiers;
|
||||||
ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
|
ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
|
||||||
|
|
||||||
ecore_event_add(ECORE_EVENT_MOUSE_OUT, ev, NULL, NULL);
|
ecore_event_add(ECORE_EVENT_MOUSE_OUT, ev, _input_event_cb_free, ev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -166,7 +174,7 @@ _ecore_wl2_input_mouse_move_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *windo
|
||||||
info->sy = input->pointer.sy;
|
info->sy = input->pointer.sy;
|
||||||
}
|
}
|
||||||
|
|
||||||
ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL);
|
ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _input_event_cb_free, ev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -205,7 +213,7 @@ _ecore_wl2_input_mouse_wheel_send(Ecore_Wl2_Input *input, unsigned int axis, int
|
||||||
}
|
}
|
||||||
ev->dev = _ecore_wl2_mouse_dev_get(input, ev->window);
|
ev->dev = _ecore_wl2_mouse_dev_get(input, ev->window);
|
||||||
|
|
||||||
ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL);
|
ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _input_event_cb_free, ev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -296,7 +304,8 @@ _ecore_wl2_input_mouse_down_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *windo
|
||||||
ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
|
ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL);
|
ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev,
|
||||||
|
_input_event_cb_free, ev->dev);
|
||||||
|
|
||||||
if ((info) && (!info->triple_click))
|
if ((info) && (!info->triple_click))
|
||||||
{
|
{
|
||||||
|
@ -366,7 +375,8 @@ _ecore_wl2_input_mouse_up_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window,
|
||||||
ev->event_window = window->id;
|
ev->event_window = window->id;
|
||||||
ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
|
ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
|
||||||
|
|
||||||
ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL);
|
ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev,
|
||||||
|
_input_event_cb_free, ev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -479,8 +489,8 @@ _ecore_wl2_keyboard_dev_get(Ecore_Wl2_Input *input, int window_id)
|
||||||
Ecore_Wl2_Input_Devices *devices;
|
Ecore_Wl2_Input_Devices *devices;
|
||||||
|
|
||||||
devices = _ecore_wl2_devices_get(input, window_id);
|
devices = _ecore_wl2_devices_get(input, window_id);
|
||||||
if (devices)
|
if (devices && devices->keyboard_dev)
|
||||||
return devices->keyboard_dev;
|
return efl_ref(devices->keyboard_dev);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -524,9 +534,9 @@ _ecore_wl2_input_key_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window, xkb_
|
||||||
/* DBG("Emitting Key event (%s,%s,%s,%s)\n", ev->keyname, ev->key, ev->compose, ev->string); */
|
/* DBG("Emitting Key event (%s,%s,%s,%s)\n", ev->keyname, ev->key, ev->compose, ev->string); */
|
||||||
|
|
||||||
if (state)
|
if (state)
|
||||||
ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL);
|
ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, _input_event_cb_free, ev->dev);
|
||||||
else
|
else
|
||||||
ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
|
ecore_event_add(ECORE_EVENT_KEY_UP, ev, _input_event_cb_free, ev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue