Ecore Evas: Add multi seat support for mouse in/out.

This commit is contained in:
Guilherme Iscaro 2016-11-09 17:54:55 -02:00 committed by Bruno Dilly
parent 1d0c0d5024
commit 75619fc290
14 changed files with 163 additions and 31 deletions

View File

@ -1861,8 +1861,9 @@ EAPI void ecore_evas_callback_unsticky_set(Ecore_Evas *ee, Ecore_Evas_Eve
*
* @warning If and when this function is called depends on the underlying
* windowing system.
* @since 1.19
*/
EAPI void ecore_evas_callback_mouse_in_set(Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
EAPI void ecore_evas_callback_device_mouse_in_set(Ecore_Evas *ee, Ecore_Evas_Mouse_IO_Cb func);
/**
* @brief Set a callback for Ecore_Evas mouse out events.
* @param ee The Ecore_Evas to set callbacks on
@ -1873,6 +1874,35 @@ EAPI void ecore_evas_callback_mouse_in_set(Ecore_Evas *ee, Ecore_Evas_Eve
*
* @warning If and when this function is called depends on the underlying
* windowing system.
* @since 1.19
*/
EAPI void ecore_evas_callback_device_mouse_out_set(Ecore_Evas *ee, Ecore_Evas_Mouse_IO_Cb func);
/**
* @brief Set a callback for Ecore_Evas mouse in events.
* @param ee The Ecore_Evas to set callbacks on
* @param func The function to call
* A call to this function will set a callback on an Ecore_Evas, causing
* @p func to be called whenever the mouse enters @p ee.
*
* @note the @p func will only report events for the default mouse.
* @warning If and when this function is called depends on the underlying
* windowing system.
* @see ecore_evas_callback_device_mouse_in_set
*/
EAPI void ecore_evas_callback_mouse_in_set(Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
/**
* @brief Set a callback for Ecore_Evas mouse out events.
* @param ee The Ecore_Evas to set callbacks on
* @param func The function to call
* A call to this function will set a callback on an Ecore_Evas, causing
* @p func to be called whenever the mouse leaves @p ee.
*
* @note the @p func will only report events for the default mouse.
* @warning If and when this function is called depends on the underlying
* windowing system.
* @see ecore_evas_callback_device_mouse_out_set
*/
EAPI void ecore_evas_callback_mouse_out_set(Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
/**

View File

@ -42,6 +42,7 @@ typedef struct _Ecore_Cocoa_Window Ecore_Cocoa_Window;
typedef struct _Ecore_Evas Ecore_Evas;
typedef void (*Ecore_Evas_Event_Cb) (Ecore_Evas *ee); /**< Callback used for several ecore evas events @since 1.2 */
typedef void (*Ecore_Evas_Focus_Device_Event_Cb) (Ecore_Evas *ee, Eo *seat); /** Callback used to report an focus in/out event originated from a seat. @since 1.19*/
typedef void (*Ecore_Evas_Mouse_IO_Cb) (Ecore_Evas *ee, Eo *mouse); /**< Callback used to report mouse in/out events. @since 1.19 */
#endif
#ifndef _ECORE_WAYLAND_H_

View File

@ -82,6 +82,22 @@ _ecore_evas_device_del_cb(void *data, const Efl_Event *ev)
_ecore_evas_focus_out_dispatch(ee, ev->object);
}
static void
_ecore_evas_mouse_out_dispatch(Ecore_Evas *ee, Efl_Input_Device *mouse)
{
if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee);
if (ee->func.fn_device_mouse_out) ee->func.fn_device_mouse_out(ee, mouse);
}
static void
_ecore_evas_mouse_del_cb(void *data, const Efl_Event *ev)
{
Ecore_Evas *ee = data;
ee->mice_in = eina_list_remove(ee->mice_in, ev->object);
_ecore_evas_mouse_out_dispatch(ee, ev->object);
}
static void
_ecore_evas_animator(void *data, const Efl_Event *ev EINA_UNUSED)
{
@ -2754,7 +2770,7 @@ _ecore_evas_vnc_stop(Ecore_Evas *ee)
EAPI void
_ecore_evas_free(Ecore_Evas *ee)
{
Efl_Input_Device *seat;
Efl_Input_Device *dev;
Ecore_Evas_Interface *iface;
ee->deleted = EINA_TRUE;
@ -2778,11 +2794,16 @@ _ecore_evas_free(Ecore_Evas *ee)
{
_ecore_evas_free(ee->sub_ecore_evas->data);
}
EINA_LIST_FREE(ee->prop.focused_by, seat)
EINA_LIST_FREE(ee->prop.focused_by, dev)
{
efl_event_callback_del(seat, EFL_EVENT_DEL,
efl_event_callback_del(dev, EFL_EVENT_DEL,
_ecore_evas_device_del_cb, ee);
}
EINA_LIST_FREE(ee->mice_in, dev)
{
efl_event_callback_del(dev, EFL_EVENT_DEL,
_ecore_evas_mouse_del_cb, ee);
}
if (ee->data) eina_hash_free(ee->data);
ee->data = NULL;
if (ee->name) free(ee->name);
@ -4243,3 +4264,63 @@ _ecore_evas_input_direct_cb(void *window, int type, const void *info)
return EINA_FALSE;
}
}
EAPI void
_ecore_evas_mouse_inout_set(Ecore_Evas *ee, Efl_Input_Device *mouse,
Eina_Bool in, Eina_Bool force_out)
{
Efl_Input_Device *present;
if (!mouse)
mouse = evas_default_device_get(ee->evas,
EFL_INPUT_DEVICE_CLASS_MOUSE);;
EINA_SAFETY_ON_NULL_RETURN(mouse);
present = eina_list_data_find(ee->mice_in, mouse);
if (in)
{
if (present) return;
ee->mice_in = eina_list_append(ee->mice_in, mouse);
efl_event_callback_add(mouse, EFL_EVENT_DEL,
_ecore_evas_mouse_del_cb, ee);
if (ee->func.fn_mouse_in) ee->func.fn_mouse_in(ee);
}
else
{
if (present) ee->mice_in = eina_list_remove(ee->mice_in, mouse);
else if (!present && !force_out) return;
efl_event_callback_del(mouse, EFL_EVENT_DEL,
_ecore_evas_mouse_del_cb, ee);
_ecore_evas_mouse_out_dispatch(ee, mouse);
}
}
EAPI Eina_Bool
_ecore_evas_mouse_in_check(Ecore_Evas *ee, Efl_Input_Device *mouse)
{
if (!mouse)
mouse = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(mouse, EINA_FALSE);
return eina_list_data_find(ee->mice_in, mouse) ? EINA_TRUE : EINA_FALSE;
}
EAPI void
ecore_evas_callback_device_mouse_out_set(Ecore_Evas *ee,
Ecore_Evas_Mouse_IO_Cb func)
{
ECORE_EVAS_CHECK(ee);
IFC(ee, fn_callback_device_mouse_out_set) (ee, func);
IFE;
ee->func.fn_device_mouse_out = func;
}
EAPI void
ecore_evas_callback_device_mouse_in_set(Ecore_Evas *ee,
Ecore_Evas_Mouse_IO_Cb func)
{
ECORE_EVAS_CHECK(ee);
IFC(ee, fn_callback_device_mouse_in_set) (ee, func);
IFE;
ee->func.fn_device_mouse_in = func;
}

View File

@ -605,6 +605,8 @@ static Ecore_Evas_Engine_Func _ecore_buffer_engine_func =
NULL, //fn_focus_device_set
NULL, //fn_callback_focus_device_in_set
NULL, //fn_callback_focus_device_out_set
NULL, //fn_callback_device_mouse_in_set
NULL, //fn_callback_device_mouse_out_set
};
static void *

View File

@ -717,6 +717,8 @@ static const Ecore_Evas_Engine_Func _ecore_ews_engine_func =
NULL, //fn_focus_device_set
NULL, //fn_callback_focus_device_in_set
NULL, //fn_callback_focus_device_out_set
NULL, //fn_callback_device_mouse_in_set
NULL, //fn_callback_device_mouse_out_set
};
void

View File

@ -162,6 +162,9 @@ struct _Ecore_Evas_Engine_Func
void (*fn_focus_device_set) (Ecore_Evas *ee, Efl_Input_Device *seat, Eina_Bool on);
void (*fn_callback_focus_device_in_set) (Ecore_Evas *ee, Ecore_Evas_Focus_Device_Event_Cb func);
void (*fn_callback_focus_device_out_set) (Ecore_Evas *ee, Ecore_Evas_Focus_Device_Event_Cb func);
void (*fn_callback_device_mouse_in_set) (Ecore_Evas *ee, Ecore_Evas_Mouse_IO_Cb func);
void (*fn_callback_device_mouse_out_set) (Ecore_Evas *ee, Ecore_Evas_Mouse_IO_Cb func);
};
struct _Ecore_Evas_Interface
@ -198,10 +201,10 @@ struct _Ecore_Evas
Eina_Bool should_be_visible : 1;
Eina_Bool alpha : 1;
Eina_Bool transparent : 1;
Eina_Bool in : 1;
Eina_Bool events_block : 1; /* @since 1.14 */
Eina_Hash *data;
Eina_List *mice_in;
void *vnc_server; /* @since 1.19 */
@ -306,6 +309,8 @@ struct _Ecore_Evas
Eina_Bool (*fn_pointer_warp) (const Ecore_Evas *ee, Evas_Coord x, Evas_Coord y);
void (*fn_focus_device_in) (Ecore_Evas *ee, Efl_Input_Device *seat);
void (*fn_focus_device_out) (Ecore_Evas *ee, Efl_Input_Device *seat);
void (*fn_device_mouse_in) (Ecore_Evas *ee, Efl_Input_Device *mouse);
void (*fn_device_mouse_out) (Ecore_Evas *ee, Efl_Input_Device *mouse);
} func;
Ecore_Evas_Engine engine;
@ -455,6 +460,9 @@ Eina_Module *_ecore_evas_vnc_server_module_load(void);
EAPI void _ecore_evas_focus_device_set(Ecore_Evas *ee, Efl_Input_Device *seat,
Eina_Bool on);
EAPI Eina_Bool _ecore_evas_mouse_in_check(Ecore_Evas *ee, Efl_Input_Device *mouse);
EAPI void _ecore_evas_mouse_inout_set(Ecore_Evas *ee, Efl_Input_Device *mouse,
Eina_Bool in, Eina_Bool force_out);
#undef EAPI
#define EAPI

View File

@ -673,6 +673,8 @@ static Ecore_Evas_Engine_Func _ecore_cocoa_engine_func =
NULL, //fn_focus_device_set
NULL, //fn_callback_focus_device_in_set
NULL, //fn_callback_focus_device_out_set
NULL, //fn_callback_device_mouse_in_set
NULL, //fn_callback_device_mouse_out_set
};
static Ecore_Cocoa_Window *

View File

@ -923,6 +923,8 @@ static const Ecore_Evas_Engine_Func _ecore_extn_plug_engine_func =
NULL, //fn_focus_device_set
NULL, //fn_callback_focus_device_in_set
NULL, //fn_callback_focus_device_out_set
NULL, //fn_callback_device_mouse_in_set
NULL, //fn_callback_device_mouse_out_set
};
static Eina_Bool

View File

@ -640,6 +640,8 @@ static Ecore_Evas_Engine_Func _ecore_fb_engine_func =
NULL, //fn_focus_device_set
NULL, //fn_callback_focus_device_in_set
NULL, //fn_callback_focus_device_out_set
NULL, //fn_callback_device_mouse_in_set
NULL, //fn_callback_device_mouse_out_set
};
EAPI Ecore_Evas *

View File

@ -461,6 +461,8 @@ static Ecore_Evas_Engine_Func _ecore_psl1ght_engine_func =
NULL, //fn_focus_device_set
NULL, //fn_callback_focus_device_in_set
NULL, //fn_callback_focus_device_out_set
NULL, //fn_callback_device_mouse_in_set
NULL, //fn_callback_device_mouse_out_set
};
EAPI Ecore_Evas *

View File

@ -553,6 +553,8 @@ static Ecore_Evas_Engine_Func _ecore_sdl_engine_func =
NULL, //fn_focus_device_set
NULL, //fn_callback_focus_device_in_set
NULL, //fn_callback_focus_device_out_set
NULL, //fn_callback_device_mouse_in_set
NULL, //fn_callback_device_mouse_out_set
};
static Ecore_Evas*

View File

@ -88,6 +88,8 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
NULL, //fn_focus_device_set
NULL, //fn_callback_focus_device_in_set
NULL, //fn_callback_focus_device_out_set
NULL, //fn_callback_device_mouse_in_set
NULL, //fn_callback_device_mouse_out_set
};
#define _smart_frame_type "ecore_evas_wl_frame"
@ -163,13 +165,12 @@ _ecore_evas_wl_common_cb_mouse_in(void *data EINA_UNUSED, int type EINA_UNUSED,
ee = ecore_event_window_match(ev->window);
if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
if (ev->window != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
if (ee->in) return ECORE_CALLBACK_PASS_ON;
if (_ecore_evas_mouse_in_check(ee, ev->dev)) return ECORE_CALLBACK_PASS_ON;
if (ee->func.fn_mouse_in) ee->func.fn_mouse_in(ee);
_ecore_evas_mouse_inout_set(ee, ev->dev, EINA_TRUE, EINA_FALSE);
ecore_event_evas_modifier_lock_update(ee->evas, ev->modifiers);
evas_event_feed_mouse_in(ee->evas, ev->timestamp, NULL);
_ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->timestamp);
ee->in = EINA_TRUE;
return ECORE_CALLBACK_PASS_ON;
}
@ -185,16 +186,13 @@ _ecore_evas_wl_common_cb_mouse_out(void *data EINA_UNUSED, int type EINA_UNUSED,
ee = ecore_event_window_match(ev->window);
if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
if (ev->window != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
if (!_ecore_evas_mouse_in_check(ee, ev->dev)) return ECORE_CALLBACK_PASS_ON;
if (ee->in)
{
ecore_event_evas_modifier_lock_update(ee->evas, ev->modifiers);
_ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->timestamp);
evas_event_feed_mouse_out(ee->evas, ev->timestamp, NULL);
if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee);
if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object);
ee->in = EINA_FALSE;
}
ecore_event_evas_modifier_lock_update(ee->evas, ev->modifiers);
_ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->timestamp);
evas_event_feed_mouse_out(ee->evas, ev->timestamp, NULL);
_ecore_evas_mouse_inout_set(ee, ev->dev, EINA_FALSE, EINA_FALSE);
if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object);
return ECORE_CALLBACK_PASS_ON;
}

View File

@ -190,7 +190,7 @@ _ecore_evas_win32_event_mouse_in(void *data EINA_UNUSED, int type EINA_UNUSED, v
if ((!ee) || (ee->ignore_events)) return 1; /* pass on event */
if ((Ecore_Window)e->window != ee->prop.window) return 1;
if (ee->func.fn_mouse_in) ee->func.fn_mouse_in(ee);
_ecore_evas_mouse_inout_set(ee, NULL, EINA_TRUE, EINA_FALSE);
/* FIXME to do */
/* _ecore_evas_x_modifier_locks_update(ee, e->modifiers); */
evas_event_feed_mouse_in(ee->evas, e->timestamp, NULL);
@ -215,11 +215,11 @@ _ecore_evas_win32_event_mouse_out(void *data EINA_UNUSED, int type EINA_UNUSED,
/* _ecore_evas_x_modifier_locks_update(ee, e->modifiers); */
_ecore_evas_mouse_move_process(ee, e->x, e->y, e->timestamp);
if (ee->in)
if (_ecore_evas_mouse_in_check(ee, NULL))
{
if (evas_event_down_count_get(ee->evas) > 0) return ECORE_CALLBACK_PASS_ON;
evas_event_feed_mouse_out(ee->evas, e->timestamp, NULL);
if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee);
_ecore_evas_mouse_inout_set(ee, NULL, EINA_FALSE, EINA_FALSE);
if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object);
}
@ -1205,6 +1205,8 @@ static Ecore_Evas_Engine_Func _ecore_win32_engine_func =
NULL, //fn_focus_device_set
NULL, //fn_callback_focus_device_in_set
NULL, //fn_callback_focus_device_out_set
NULL, //fn_callback_device_mouse_in_set
NULL, //fn_callback_device_mouse_out_set
};
#endif /* BUILD_ECORE_EVAS_WIN32 */

View File

@ -1314,9 +1314,8 @@ _fake_out(void *data)
_ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
_feed_cancel_out(e, (e->mode == ECORE_X_EVENT_MODE_GRAB));
if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee);
_ecore_evas_mouse_inout_set(ee, NULL, EINA_FALSE, EINA_TRUE);
if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object);
ee->in = EINA_FALSE;
return EINA_FALSE;
}
@ -1385,7 +1384,7 @@ _ecore_evas_x_event_mouse_in(void *data EINA_UNUSED, int type EINA_UNUSED, void
}
/* if (e->mode != ECORE_X_EVENT_MODE_NORMAL) return 0; */
if (!ee->in)
if (!_ecore_evas_mouse_in_check(ee, NULL))
{
Ecore_Event_Mouse_IO io = {
.event_window = (Ecore_Window) e->win, /* not event_win! */
@ -1396,9 +1395,8 @@ _ecore_evas_x_event_mouse_in(void *data EINA_UNUSED, int type EINA_UNUSED, void
.y = e->y
};
if (ee->func.fn_mouse_in) ee->func.fn_mouse_in(ee);
_ecore_evas_mouse_inout_set(ee, NULL, EINA_TRUE, EINA_FALSE);
ecore_event_evas_mouse_in(NULL, ECORE_EVENT_MOUSE_IN, &io);
ee->in = EINA_TRUE;
}
return ECORE_CALLBACK_PASS_ON;
}
@ -1472,7 +1470,7 @@ _ecore_evas_x_event_mouse_out(void *data EINA_UNUSED, int type EINA_UNUSED, void
// if (e->mode != ECORE_X_EVENT_MODE_NORMAL) return 0;
// printf("OUT: ee->in=%i, e->mode=%i, e->detail=%i, dount_count=%i\n",
// ee->in, e->mode, e->detail, evas_event_down_count_get(ee->evas));
if (ee->in)
if (_ecore_evas_mouse_in_check(ee, NULL))
{
if ((evas_event_down_count_get(ee->evas) > 0) &&
(!((e->mode == ECORE_X_EVENT_MODE_GRAB) &&
@ -1480,10 +1478,9 @@ _ecore_evas_x_event_mouse_out(void *data EINA_UNUSED, int type EINA_UNUSED, void
return ECORE_CALLBACK_PASS_ON;
ecore_event_evas_modifier_lock_update(ee->evas, e->modifiers);
_ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
_ecore_evas_mouse_inout_set(ee, NULL, EINA_FALSE, EINA_FALSE);
_feed_cancel_out(e, (e->mode == ECORE_X_EVENT_MODE_GRAB));
if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee);
if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object);
ee->in = EINA_FALSE;
}
return ECORE_CALLBACK_PASS_ON;
}
@ -1791,7 +1788,7 @@ _ecore_evas_x_event_window_hide(void *data EINA_UNUSED, int type EINA_UNUSED, vo
ee = ecore_event_window_match(e->win);
if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
if (ee->in)
if (_ecore_evas_mouse_in_check(ee, NULL))
{
Ecore_X_Event_Mouse_Out out = {
.event_win = e->event_win,
@ -1802,9 +1799,8 @@ _ecore_evas_x_event_window_hide(void *data EINA_UNUSED, int type EINA_UNUSED, vo
.y = 0,
};
_feed_cancel_out(&out, EINA_TRUE);
if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee);
_ecore_evas_mouse_inout_set(ee, NULL, EINA_FALSE, EINA_FALSE);
if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object);
ee->in = EINA_FALSE;
}
if (ee->prop.override)
{
@ -3787,6 +3783,8 @@ static Ecore_Evas_Engine_Func _ecore_x_engine_func =
NULL, //fn_focus_device_set
NULL, //fn_callback_focus_device_in_set
NULL, //fn_callback_focus_device_out_set
NULL, //fn_callback_device_mouse_in_set
NULL, //fn_callback_device_mouse_out_set
};
/*