summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorGuilherme Iscaro <iscaro@profusion.mobi>2016-11-09 17:54:55 -0200
committerBruno Dilly <bdilly@profusion.mobi>2016-11-28 13:57:55 -0200
commit75619fc290963e1061e5f8be10e4bc965292ce21 (patch)
tree716fca993596e6cb5d2ecf0e6e88fbdf1a800715 /src/lib
parent1d0c0d50248de537d4b77b2a19a9e0cd54ae1fe6 (diff)
Ecore Evas: Add multi seat support for mouse in/out.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ecore_evas/Ecore_Evas.h30
-rw-r--r--src/lib/ecore_evas/Ecore_Evas_Types.h1
-rw-r--r--src/lib/ecore_evas/ecore_evas.c87
-rw-r--r--src/lib/ecore_evas/ecore_evas_buffer.c2
-rw-r--r--src/lib/ecore_evas/ecore_evas_ews.c2
-rw-r--r--src/lib/ecore_evas/ecore_evas_private.h10
6 files changed, 128 insertions, 4 deletions
diff --git a/src/lib/ecore_evas/Ecore_Evas.h b/src/lib/ecore_evas/Ecore_Evas.h
index 096cb9002f..c2295f8e78 100644
--- a/src/lib/ecore_evas/Ecore_Evas.h
+++ b/src/lib/ecore_evas/Ecore_Evas.h
@@ -1861,6 +1861,34 @@ EAPI void ecore_evas_callback_unsticky_set(Ecore_Evas *ee, Ecore_Evas_Eve
1861 * 1861 *
1862 * @warning If and when this function is called depends on the underlying 1862 * @warning If and when this function is called depends on the underlying
1863 * windowing system. 1863 * windowing system.
1864 * @since 1.19
1865 */
1866EAPI void ecore_evas_callback_device_mouse_in_set(Ecore_Evas *ee, Ecore_Evas_Mouse_IO_Cb func);
1867/**
1868 * @brief Set a callback for Ecore_Evas mouse out events.
1869 * @param ee The Ecore_Evas to set callbacks on
1870 * @param func The function to call
1871
1872 * A call to this function will set a callback on an Ecore_Evas, causing
1873 * @p func to be called whenever the mouse leaves @p ee.
1874 *
1875 * @warning If and when this function is called depends on the underlying
1876 * windowing system.
1877 * @since 1.19
1878 */
1879EAPI void ecore_evas_callback_device_mouse_out_set(Ecore_Evas *ee, Ecore_Evas_Mouse_IO_Cb func);
1880/**
1881 * @brief Set a callback for Ecore_Evas mouse in events.
1882 * @param ee The Ecore_Evas to set callbacks on
1883 * @param func The function to call
1884
1885 * A call to this function will set a callback on an Ecore_Evas, causing
1886 * @p func to be called whenever the mouse enters @p ee.
1887 *
1888 * @note the @p func will only report events for the default mouse.
1889 * @warning If and when this function is called depends on the underlying
1890 * windowing system.
1891 * @see ecore_evas_callback_device_mouse_in_set
1864 */ 1892 */
1865EAPI void ecore_evas_callback_mouse_in_set(Ecore_Evas *ee, Ecore_Evas_Event_Cb func); 1893EAPI void ecore_evas_callback_mouse_in_set(Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
1866/** 1894/**
@@ -1871,8 +1899,10 @@ EAPI void ecore_evas_callback_mouse_in_set(Ecore_Evas *ee, Ecore_Evas_Eve
1871 * A call to this function will set a callback on an Ecore_Evas, causing 1899 * A call to this function will set a callback on an Ecore_Evas, causing
1872 * @p func to be called whenever the mouse leaves @p ee. 1900 * @p func to be called whenever the mouse leaves @p ee.
1873 * 1901 *
1902 * @note the @p func will only report events for the default mouse.
1874 * @warning If and when this function is called depends on the underlying 1903 * @warning If and when this function is called depends on the underlying
1875 * windowing system. 1904 * windowing system.
1905 * @see ecore_evas_callback_device_mouse_out_set
1876 */ 1906 */
1877EAPI void ecore_evas_callback_mouse_out_set(Ecore_Evas *ee, Ecore_Evas_Event_Cb func); 1907EAPI void ecore_evas_callback_mouse_out_set(Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
1878/** 1908/**
diff --git a/src/lib/ecore_evas/Ecore_Evas_Types.h b/src/lib/ecore_evas/Ecore_Evas_Types.h
index e84a674b39..442e07b072 100644
--- a/src/lib/ecore_evas/Ecore_Evas_Types.h
+++ b/src/lib/ecore_evas/Ecore_Evas_Types.h
@@ -42,6 +42,7 @@ typedef struct _Ecore_Cocoa_Window Ecore_Cocoa_Window;
42typedef struct _Ecore_Evas Ecore_Evas; 42typedef struct _Ecore_Evas Ecore_Evas;
43typedef void (*Ecore_Evas_Event_Cb) (Ecore_Evas *ee); /**< Callback used for several ecore evas events @since 1.2 */ 43typedef void (*Ecore_Evas_Event_Cb) (Ecore_Evas *ee); /**< Callback used for several ecore evas events @since 1.2 */
44typedef 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*/ 44typedef 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*/
45typedef void (*Ecore_Evas_Mouse_IO_Cb) (Ecore_Evas *ee, Eo *mouse); /**< Callback used to report mouse in/out events. @since 1.19 */
45#endif 46#endif
46 47
47#ifndef _ECORE_WAYLAND_H_ 48#ifndef _ECORE_WAYLAND_H_
diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c
index ae3fed8ded..293b1e3170 100644
--- a/src/lib/ecore_evas/ecore_evas.c
+++ b/src/lib/ecore_evas/ecore_evas.c
@@ -83,6 +83,22 @@ _ecore_evas_device_del_cb(void *data, const Efl_Event *ev)
83} 83}
84 84
85static void 85static void
86_ecore_evas_mouse_out_dispatch(Ecore_Evas *ee, Efl_Input_Device *mouse)
87{
88 if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee);
89 if (ee->func.fn_device_mouse_out) ee->func.fn_device_mouse_out(ee, mouse);
90}
91
92static void
93_ecore_evas_mouse_del_cb(void *data, const Efl_Event *ev)
94{
95 Ecore_Evas *ee = data;
96
97 ee->mice_in = eina_list_remove(ee->mice_in, ev->object);
98 _ecore_evas_mouse_out_dispatch(ee, ev->object);
99}
100
101static void
86_ecore_evas_animator(void *data, const Efl_Event *ev EINA_UNUSED) 102_ecore_evas_animator(void *data, const Efl_Event *ev EINA_UNUSED)
87{ 103{
88 Ecore_Evas *ee = data; 104 Ecore_Evas *ee = data;
@@ -2754,7 +2770,7 @@ _ecore_evas_vnc_stop(Ecore_Evas *ee)
2754EAPI void 2770EAPI void
2755_ecore_evas_free(Ecore_Evas *ee) 2771_ecore_evas_free(Ecore_Evas *ee)
2756{ 2772{
2757 Efl_Input_Device *seat; 2773 Efl_Input_Device *dev;
2758 Ecore_Evas_Interface *iface; 2774 Ecore_Evas_Interface *iface;
2759 2775
2760 ee->deleted = EINA_TRUE; 2776 ee->deleted = EINA_TRUE;
@@ -2778,11 +2794,16 @@ _ecore_evas_free(Ecore_Evas *ee)
2778 { 2794 {
2779 _ecore_evas_free(ee->sub_ecore_evas->data); 2795 _ecore_evas_free(ee->sub_ecore_evas->data);
2780 } 2796 }
2781 EINA_LIST_FREE(ee->prop.focused_by, seat) 2797 EINA_LIST_FREE(ee->prop.focused_by, dev)
2782 { 2798 {
2783 efl_event_callback_del(seat, EFL_EVENT_DEL, 2799 efl_event_callback_del(dev, EFL_EVENT_DEL,
2784 _ecore_evas_device_del_cb, ee); 2800 _ecore_evas_device_del_cb, ee);
2785 } 2801 }
2802 EINA_LIST_FREE(ee->mice_in, dev)
2803 {
2804 efl_event_callback_del(dev, EFL_EVENT_DEL,
2805 _ecore_evas_mouse_del_cb, ee);
2806 }
2786 if (ee->data) eina_hash_free(ee->data); 2807 if (ee->data) eina_hash_free(ee->data);
2787 ee->data = NULL; 2808 ee->data = NULL;
2788 if (ee->name) free(ee->name); 2809 if (ee->name) free(ee->name);
@@ -4243,3 +4264,63 @@ _ecore_evas_input_direct_cb(void *window, int type, const void *info)
4243 return EINA_FALSE; 4264 return EINA_FALSE;
4244 } 4265 }
4245} 4266}
4267
4268EAPI void
4269_ecore_evas_mouse_inout_set(Ecore_Evas *ee, Efl_Input_Device *mouse,
4270 Eina_Bool in, Eina_Bool force_out)
4271{
4272 Efl_Input_Device *present;
4273
4274 if (!mouse)
4275 mouse = evas_default_device_get(ee->evas,
4276 EFL_INPUT_DEVICE_CLASS_MOUSE);;
4277
4278 EINA_SAFETY_ON_NULL_RETURN(mouse);
4279 present = eina_list_data_find(ee->mice_in, mouse);
4280
4281 if (in)
4282 {
4283 if (present) return;
4284 ee->mice_in = eina_list_append(ee->mice_in, mouse);
4285 efl_event_callback_add(mouse, EFL_EVENT_DEL,
4286 _ecore_evas_mouse_del_cb, ee);
4287 if (ee->func.fn_mouse_in) ee->func.fn_mouse_in(ee);
4288 }
4289 else
4290 {
4291 if (present) ee->mice_in = eina_list_remove(ee->mice_in, mouse);
4292 else if (!present && !force_out) return;
4293 efl_event_callback_del(mouse, EFL_EVENT_DEL,
4294 _ecore_evas_mouse_del_cb, ee);
4295 _ecore_evas_mouse_out_dispatch(ee, mouse);
4296 }
4297}
4298
4299EAPI Eina_Bool
4300_ecore_evas_mouse_in_check(Ecore_Evas *ee, Efl_Input_Device *mouse)
4301{
4302 if (!mouse)
4303 mouse = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE);
4304 EINA_SAFETY_ON_NULL_RETURN_VAL(mouse, EINA_FALSE);
4305 return eina_list_data_find(ee->mice_in, mouse) ? EINA_TRUE : EINA_FALSE;
4306}
4307
4308EAPI void
4309ecore_evas_callback_device_mouse_out_set(Ecore_Evas *ee,
4310 Ecore_Evas_Mouse_IO_Cb func)
4311{
4312 ECORE_EVAS_CHECK(ee);
4313 IFC(ee, fn_callback_device_mouse_out_set) (ee, func);
4314 IFE;
4315 ee->func.fn_device_mouse_out = func;
4316}
4317
4318EAPI void
4319ecore_evas_callback_device_mouse_in_set(Ecore_Evas *ee,
4320 Ecore_Evas_Mouse_IO_Cb func)
4321{
4322 ECORE_EVAS_CHECK(ee);
4323 IFC(ee, fn_callback_device_mouse_in_set) (ee, func);
4324 IFE;
4325 ee->func.fn_device_mouse_in = func;
4326}
diff --git a/src/lib/ecore_evas/ecore_evas_buffer.c b/src/lib/ecore_evas/ecore_evas_buffer.c
index ae9fb62646..0d1643cdfb 100644
--- a/src/lib/ecore_evas/ecore_evas_buffer.c
+++ b/src/lib/ecore_evas/ecore_evas_buffer.c
@@ -605,6 +605,8 @@ static Ecore_Evas_Engine_Func _ecore_buffer_engine_func =
605 NULL, //fn_focus_device_set 605 NULL, //fn_focus_device_set
606 NULL, //fn_callback_focus_device_in_set 606 NULL, //fn_callback_focus_device_in_set
607 NULL, //fn_callback_focus_device_out_set 607 NULL, //fn_callback_focus_device_out_set
608 NULL, //fn_callback_device_mouse_in_set
609 NULL, //fn_callback_device_mouse_out_set
608}; 610};
609 611
610static void * 612static void *
diff --git a/src/lib/ecore_evas/ecore_evas_ews.c b/src/lib/ecore_evas/ecore_evas_ews.c
index c7dcb7087f..693e9db126 100644
--- a/src/lib/ecore_evas/ecore_evas_ews.c
+++ b/src/lib/ecore_evas/ecore_evas_ews.c
@@ -717,6 +717,8 @@ static const Ecore_Evas_Engine_Func _ecore_ews_engine_func =
717 NULL, //fn_focus_device_set 717 NULL, //fn_focus_device_set
718 NULL, //fn_callback_focus_device_in_set 718 NULL, //fn_callback_focus_device_in_set
719 NULL, //fn_callback_focus_device_out_set 719 NULL, //fn_callback_focus_device_out_set
720 NULL, //fn_callback_device_mouse_in_set
721 NULL, //fn_callback_device_mouse_out_set
720}; 722};
721 723
722void 724void
diff --git a/src/lib/ecore_evas/ecore_evas_private.h b/src/lib/ecore_evas/ecore_evas_private.h
index af1c5319f6..f9c66fea1d 100644
--- a/src/lib/ecore_evas/ecore_evas_private.h
+++ b/src/lib/ecore_evas/ecore_evas_private.h
@@ -162,6 +162,9 @@ struct _Ecore_Evas_Engine_Func
162 void (*fn_focus_device_set) (Ecore_Evas *ee, Efl_Input_Device *seat, Eina_Bool on); 162 void (*fn_focus_device_set) (Ecore_Evas *ee, Efl_Input_Device *seat, Eina_Bool on);
163 void (*fn_callback_focus_device_in_set) (Ecore_Evas *ee, Ecore_Evas_Focus_Device_Event_Cb func); 163 void (*fn_callback_focus_device_in_set) (Ecore_Evas *ee, Ecore_Evas_Focus_Device_Event_Cb func);
164 void (*fn_callback_focus_device_out_set) (Ecore_Evas *ee, Ecore_Evas_Focus_Device_Event_Cb func); 164 void (*fn_callback_focus_device_out_set) (Ecore_Evas *ee, Ecore_Evas_Focus_Device_Event_Cb func);
165
166 void (*fn_callback_device_mouse_in_set) (Ecore_Evas *ee, Ecore_Evas_Mouse_IO_Cb func);
167 void (*fn_callback_device_mouse_out_set) (Ecore_Evas *ee, Ecore_Evas_Mouse_IO_Cb func);
165}; 168};
166 169
167struct _Ecore_Evas_Interface 170struct _Ecore_Evas_Interface
@@ -198,10 +201,10 @@ struct _Ecore_Evas
198 Eina_Bool should_be_visible : 1; 201 Eina_Bool should_be_visible : 1;
199 Eina_Bool alpha : 1; 202 Eina_Bool alpha : 1;
200 Eina_Bool transparent : 1; 203 Eina_Bool transparent : 1;
201 Eina_Bool in : 1;
202 Eina_Bool events_block : 1; /* @since 1.14 */ 204 Eina_Bool events_block : 1; /* @since 1.14 */
203 205
204 Eina_Hash *data; 206 Eina_Hash *data;
207 Eina_List *mice_in;
205 208
206 void *vnc_server; /* @since 1.19 */ 209 void *vnc_server; /* @since 1.19 */
207 210
@@ -306,6 +309,8 @@ struct _Ecore_Evas
306 Eina_Bool (*fn_pointer_warp) (const Ecore_Evas *ee, Evas_Coord x, Evas_Coord y); 309 Eina_Bool (*fn_pointer_warp) (const Ecore_Evas *ee, Evas_Coord x, Evas_Coord y);
307 void (*fn_focus_device_in) (Ecore_Evas *ee, Efl_Input_Device *seat); 310 void (*fn_focus_device_in) (Ecore_Evas *ee, Efl_Input_Device *seat);
308 void (*fn_focus_device_out) (Ecore_Evas *ee, Efl_Input_Device *seat); 311 void (*fn_focus_device_out) (Ecore_Evas *ee, Efl_Input_Device *seat);
312 void (*fn_device_mouse_in) (Ecore_Evas *ee, Efl_Input_Device *mouse);
313 void (*fn_device_mouse_out) (Ecore_Evas *ee, Efl_Input_Device *mouse);
309 } func; 314 } func;
310 315
311 Ecore_Evas_Engine engine; 316 Ecore_Evas_Engine engine;
@@ -455,6 +460,9 @@ Eina_Module *_ecore_evas_vnc_server_module_load(void);
455EAPI void _ecore_evas_focus_device_set(Ecore_Evas *ee, Efl_Input_Device *seat, 460EAPI void _ecore_evas_focus_device_set(Ecore_Evas *ee, Efl_Input_Device *seat,
456 Eina_Bool on); 461 Eina_Bool on);
457 462
463EAPI Eina_Bool _ecore_evas_mouse_in_check(Ecore_Evas *ee, Efl_Input_Device *mouse);
464EAPI void _ecore_evas_mouse_inout_set(Ecore_Evas *ee, Efl_Input_Device *mouse,
465 Eina_Bool in, Eina_Bool force_out);
458#undef EAPI 466#undef EAPI
459#define EAPI 467#define EAPI
460 468