efl_ui_dnd: fixup leaking inits and code duplication

In fff4d1ba97 one selection_manager_get
method was patched to behave like this, however, it completly broke the
fact of *only-one-manager* since the same code was duplicated in a other
files (efl_selection.c). This now unifies this code, and adds back the
assertion for only one manager per window.

Additionally a shutdown function is added, the app never destroyes, but
the selection manager decided to init some subsystems itself
(ecore_x for example). This lead to to a leak of init counts in ecore_x,
which lead to elementary test suite issues. This is now *finaly* fixed.

Differential Revision: https://phab.enlightenment.org/D7105
This commit is contained in:
Marcel Hollerbach 2018-09-25 15:08:47 +02:00
parent a349bd46eb
commit 66aa76ad89
4 changed files with 44 additions and 47 deletions

View File

@ -10,28 +10,11 @@
#define MY_CLASS EFL_SELECTION_MIXIN
#define MY_CLASS_NAME "Efl.Selection"
static inline Eo*
_selection_manager_get(Eo *obj)
{
Eo *top = elm_widget_top_get(obj);
if (!top)
{
top = obj;
}
Eo *sel_man = efl_key_data_get(top, "__selection_manager");
if (!sel_man)
{
sel_man = efl_add(EFL_SELECTION_MANAGER_CLASS, top);
efl_key_data_set(top, "__selection_manager", sel_man);
}
return sel_man;
}
EOLIAN static void
_efl_selection_selection_get(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, Efl_Selection_Format format,
void *data_func_data, Efl_Selection_Data_Ready data_func, Eina_Free_Cb data_func_free_cb, unsigned int seat)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
efl_selection_manager_selection_get(sel_man, obj, type, format,
data_func_data, data_func,
data_func_free_cb, seat);
@ -40,21 +23,21 @@ _efl_selection_selection_get(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type t
EOLIAN static Eina_Future *
_efl_selection_selection_set(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, Efl_Selection_Format format, Eina_Slice data, unsigned int seat)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
return efl_selection_manager_selection_set(sel_man, obj, type, format, data, seat);
}
EOLIAN static void
_efl_selection_selection_clear(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, unsigned int seat)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
efl_selection_manager_selection_clear(sel_man, obj, type, seat);
}
EOLIAN static Eina_Bool
_efl_selection_has_owner(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, unsigned int seat)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
return efl_selection_manager_selection_has_owner(sel_man, obj, type, seat);
}
@ -227,13 +210,13 @@ elm_cnp_selection_get(const Evas_Object *obj, Elm_Sel_Type type,
Elm_Sel_Format format, Elm_Drop_Cb datacb, void *udata)
{
int seatid = 1;
Eo *sel_man = _selection_manager_get((Evas_Object *)obj);
Eo *sel_man = _efl_ui_selection_manager_get((Evas_Object *)obj);
Cnp_Data_Cb_Wrapper *wdata = calloc(1, sizeof(Cnp_Data_Cb_Wrapper));
if (!wdata) return EINA_FALSE;
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get((Evas_Object *)obj);
#endif
wdata->udata = udata;
@ -251,7 +234,7 @@ elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type type,
int seatid = 1;
Eina_Future *f;
Sel_Lost_Data *ldata;
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
Eina_Slice data;
ldata = calloc(1, sizeof(Sel_Lost_Data));
@ -275,7 +258,7 @@ EAPI Eina_Bool
elm_object_cnp_selection_clear(Evas_Object *obj, Elm_Sel_Type type)
{
int seatid = 1;
Eo *sel_man = _selection_manager_get((Evas_Object *)obj);
Eo *sel_man = _efl_ui_selection_manager_get((Evas_Object *)obj);
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get(obj);
@ -307,7 +290,7 @@ EAPI Eina_Bool
elm_selection_selection_has_owner(Evas_Object *obj)
{
int seatid = 1;
Eo *sel_man = _selection_manager_get((Evas_Object *)obj);
Eo *sel_man = _efl_ui_selection_manager_get((Evas_Object *)obj);
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get(obj);
@ -321,7 +304,7 @@ EAPI Eina_Bool
elm_cnp_clipboard_selection_has_owner(Evas_Object *obj)
{
int seatid = 1;
Eo *sel_man = _selection_manager_get((Evas_Object *)obj);
Eo *sel_man = _efl_ui_selection_manager_get((Evas_Object *)obj);
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get(obj);

View File

@ -21,8 +21,8 @@ struct _Efl_Ui_Dnd_Container_Data
extern int _wl_default_seat_id_get(Evas_Object *obj);
static inline Eo *
_selection_manager_get(Eo *obj)
Eo*
_efl_ui_selection_manager_get(Eo *obj)
{
if (!efl_isa(obj, EFL_UI_WIDGET_CLASS)) return NULL;
Eo *app = efl_app_get();
@ -35,12 +35,21 @@ _selection_manager_get(Eo *obj)
return sel_man;
}
void
_efl_ui_dnd_shutdown(void)
{
Eo *app = efl_app_get();
Eo *sel_man = efl_key_data_get(app, "__selection_manager");
efl_del(sel_man);
}
EOLIAN static void
_efl_ui_dnd_drag_start(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format format, Eina_Slice data,
Efl_Selection_Action action, void *icon_func_data, Efl_Dnd_Drag_Icon_Create icon_func, Eina_Free_Cb icon_func_free_cb,
unsigned int seat)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
efl_selection_manager_drag_start(sel_man, obj, format, data, action,
icon_func_data, icon_func, icon_func_free_cb,
seat);
@ -49,14 +58,14 @@ _efl_ui_dnd_drag_start(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format forma
EOLIAN static void
_efl_ui_dnd_drag_cancel(Eo *obj, void *pd EINA_UNUSED, unsigned int seat)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
efl_selection_manager_drag_cancel(sel_man, obj, seat);
}
EOLIAN static void
_efl_ui_dnd_drag_action_set(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Action action, unsigned int seat)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
efl_selection_manager_drag_action_set(sel_man, obj, action, seat);
}
@ -64,14 +73,14 @@ _efl_ui_dnd_drag_action_set(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Action
EOLIAN static void
_efl_ui_dnd_drop_target_add(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format format, unsigned int seat)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
efl_selection_manager_drop_target_add(sel_man, obj, format, seat);
}
EOLIAN static void
_efl_ui_dnd_drop_target_del(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format format, unsigned int seat)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
efl_selection_manager_drop_target_del(sel_man, obj, format, seat);
}
@ -97,7 +106,7 @@ _efl_ui_dnd_container_drag_item_add(Eo *obj, Efl_Ui_Dnd_Container_Data *pd,
{
double drag_delay_time = pd->drag_delay_time;
double anim_time = elm_config_drag_anim_duration_get();
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
efl_selection_manager_container_drag_item_add(sel_man, obj, drag_delay_time, anim_time,
data_func_data, data_func, data_func_free_cb,
item_func_data, item_func, item_func_free_cb,
@ -109,7 +118,7 @@ _efl_ui_dnd_container_drag_item_add(Eo *obj, Efl_Ui_Dnd_Container_Data *pd,
static void
_efl_ui_dnd_container_drag_item_del(Eo *obj, Efl_Ui_Dnd_Container_Data *pd EINA_UNUSED, unsigned int seat)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
efl_selection_manager_container_drag_item_del(sel_man, obj, seat);
}
EOLIAN static void
@ -118,14 +127,14 @@ _efl_ui_dnd_container_drop_item_add(Eo *obj, Efl_Ui_Dnd_Container_Data *pd EINA_
void *item_func_data, Efl_Dnd_Item_Get item_func, Eina_Free_Cb item_func_free_cb,
unsigned int seat)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
efl_selection_manager_container_drop_item_add(sel_man, obj, format, item_func_data, item_func, item_func_free_cb, seat);
}
EOLIAN static void
_efl_ui_dnd_container_drop_item_del(Eo *obj, Efl_Ui_Dnd_Container_Data *pd EINA_UNUSED, unsigned int seat)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
efl_selection_manager_container_drop_item_del(sel_man, obj, seat);
}
@ -304,7 +313,7 @@ elm_drag_start(Evas_Object *obj, Elm_Sel_Format format, const char *data,
Elm_Drag_State drag_done_cb, void *drag_done_data)
{
if (!data) return EINA_FALSE;
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
int seatid = 1;
Eina_Slice sl;
Dnd_Drag_Pos *pos = calloc(1, sizeof(Dnd_Drag_Pos));
@ -353,7 +362,7 @@ on_error:
EAPI Eina_Bool
elm_drag_action_set(Evas_Object *obj, Elm_Xdnd_Action action)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
int seatid = 1;
#ifdef HAVE_ELEMENTARY_WL2
@ -367,7 +376,7 @@ elm_drag_action_set(Evas_Object *obj, Elm_Xdnd_Action action)
EAPI Eina_Bool
elm_drag_cancel(Evas_Object *obj)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
int seatid = 1;
#ifdef HAVE_ELEMENTARY_WL2
@ -411,7 +420,7 @@ elm_drop_target_add(Evas_Object *obj, Elm_Sel_Format format,
Elm_Drag_Pos pos_cb, void *pos_data,
Elm_Drop_Cb drop_cb, void *drop_data)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
int seatid = 1;
Dnd_Drag_State *enter, *leave;
Dnd_Drag_Pos *pos;
@ -473,7 +482,7 @@ elm_drop_target_del(Evas_Object *obj, Elm_Sel_Format format,
Elm_Drag_Pos pos_cb, void *pos_data,
Elm_Drop_Cb drop_cb, void *drop_data)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
int seatid = 1;
//Eina_List *l, *l2;
Eina_List *drop_list;
@ -628,7 +637,7 @@ elm_drop_item_container_add(Evas_Object *obj,
Elm_Drag_Item_Container_Pos pos_cb, void *pos_data,
Elm_Drop_Item_Container_Cb drop_cb, void *drop_data)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
int seatid = 1;
Dnd_Drag_State *enter = NULL, *leave = NULL;
Dnd_Cont_Drag_Pos *pos = NULL;
@ -690,7 +699,7 @@ on_error:
EAPI Eina_Bool
elm_drop_item_container_del(Evas_Object *obj)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
int seatid = 1;
#ifdef HAVE_ELEMENTARY_WL2
@ -791,7 +800,7 @@ EAPI Eina_Bool
elm_drag_item_container_add(Evas_Object *obj, double anim_tm, double tm_to_drag,
Elm_Xy_Item_Get_Cb item_get_cb, Elm_Item_Container_Data_Get_Cb data_get_cb)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
int seatid = 1;
Eina_List *di_list;
Item_Container_Drag_Info *di;
@ -820,7 +829,7 @@ elm_drag_item_container_add(Evas_Object *obj, double anim_tm, double tm_to_drag,
EAPI Eina_Bool
elm_drag_item_container_del(Evas_Object *obj)
{
Eo *sel_man = _selection_manager_get(obj);
Eo *sel_man = _efl_ui_selection_manager_get(obj);
int seatid = 1;
#ifdef HAVE_ELEMENTARY_WL2

View File

@ -866,6 +866,7 @@ elm_quicklaunch_sub_shutdown(void)
_elm_module_shutdown();
if (_elm_prefs_initted)
_elm_prefs_shutdown();
_efl_ui_dnd_shutdown();
elm_color_class_shutdown();
}

View File

@ -549,6 +549,10 @@ void _elm_prefs_shutdown(void);
void _elm_prefs_data_init(void);
void _elm_prefs_data_shutdown(void);
/* init functions for dnd and cnp */
Eo* _efl_ui_selection_manager_get(Eo *obj);
void _efl_ui_dnd_shutdown(void);
int _elm_ews_wm_init(void);
void _elm_ews_wm_shutdown(void);
void _elm_ews_wm_rescale(Elm_Theme *th,