elm dnd/selection - only query wl things if thje window is a wl one...

check at RUNTIME not just with ifdefs at compile time. less ERR noise
for sure.
This commit is contained in:
Carsten Haitzler 2019-01-09 18:19:32 +00:00
parent afb779bda5
commit ab6c0e9f2b
3 changed files with 23 additions and 45 deletions

View File

@ -20,6 +20,9 @@ struct _Efl_Ui_Dnd_Container_Data
};
extern int _wl_default_seat_id_get(Evas_Object *obj);
#ifdef HAVE_ELEMENTARY_WL2
Ecore_Wl2_Window *_wl_window_get(const Evas_Object *obj);
#endif
Eo*
_efl_ui_selection_manager_get(Eo *obj)
@ -339,7 +342,7 @@ elm_drag_start(Evas_Object *obj, Elm_Sel_Format format, const char *data,
sl.mem = data;
sl.len = strlen(data);
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get(obj);
if (_wl_window_get(obj)) seatid = _wl_default_seat_id_get(obj);
#endif
ic->icon_data = icon_create_data;
@ -366,7 +369,7 @@ elm_drag_action_set(Evas_Object *obj, Elm_Xdnd_Action action)
int seatid = 1;
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get(obj);
if (_wl_window_get(obj)) seatid = _wl_default_seat_id_get(obj);
#endif
efl_ui_selection_manager_drag_action_set(sel_man, obj, (Efl_Ui_Selection_Action)action, seatid);
@ -380,7 +383,7 @@ elm_drag_cancel(Evas_Object *obj)
int seatid = 1;
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get(obj);
if (_wl_window_get(obj)) seatid = _wl_default_seat_id_get(obj);
#endif
efl_ui_selection_manager_drag_cancel(sel_man, obj, seatid);
@ -433,7 +436,7 @@ elm_drop_target_add(Evas_Object *obj, Elm_Sel_Format format,
drop = calloc(1, sizeof(Dnd_Drop));
if (!enter || !leave || !pos || !drop) goto on_error;
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get(obj);
if (_wl_window_get(obj)) seatid = _wl_default_seat_id_get(obj);
#endif
enter->state_cb = enter_cb;
enter->state_data = enter_data;
@ -489,7 +492,7 @@ elm_drop_target_del(Evas_Object *obj, Elm_Sel_Format format,
Dnd_Drop *drop;
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get(obj);
if (_wl_window_get(obj)) seatid = _wl_default_seat_id_get(obj);
#endif
drop_list = efl_key_data_get(obj, "__drop_list");
@ -650,7 +653,7 @@ elm_drop_item_container_add(Evas_Object *obj,
drop = calloc(1, sizeof(Dnd_Cont_Drop));
if (!enter || !leave || !pos || !drop) goto on_error;
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get(obj);
if (_wl_window_get(obj)) seatid = _wl_default_seat_id_get(obj);
#endif
enter->state_cb = enter_cb;
@ -703,7 +706,7 @@ elm_drop_item_container_del(Evas_Object *obj)
int seatid = 1;
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get(obj);
if (_wl_window_get(obj)) seatid = _wl_default_seat_id_get(obj);
#endif
_cont_drop_free_data(obj);
@ -806,7 +809,7 @@ elm_drag_item_container_add(Evas_Object *obj, double anim_tm, double tm_to_drag,
Item_Container_Drag_Info *di;
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get(obj);
if (_wl_window_get(obj)) seatid = _wl_default_seat_id_get(obj);
#endif
di = calloc(1, sizeof(Item_Container_Drag_Info));
@ -833,7 +836,7 @@ elm_drag_item_container_del(Evas_Object *obj)
int seatid = 1;
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get(obj);
if (_wl_window_get(obj)) seatid = _wl_default_seat_id_get(obj);
#endif
_cont_drag_free_data(obj);

View File

@ -10,6 +10,10 @@
#define MY_CLASS EFL_UI_SELECTION_MIXIN
#define MY_CLASS_NAME "Efl.Ui.Selection"
#ifdef HAVE_ELEMENTARY_WL2
Ecore_Wl2_Window *_wl_window_get(const Evas_Object *obj);
#endif
EOLIAN static void
_efl_ui_selection_selection_get(Eo *obj, void *pd EINA_UNUSED, Efl_Ui_Selection_Type type, Efl_Ui_Selection_Format format,
void *data_func_data, Efl_Ui_Selection_Data_Ready data_func, Eina_Free_Cb data_func_free_cb, unsigned int seat)
@ -72,34 +76,6 @@ _wl_is_wl(const Evas_Object *obj)
return NULL;
}
static Ecore_Wl2_Window *
_wl_window_get(const Evas_Object *obj)
{
Evas_Object *top;
Ecore_Wl2_Window *win = NULL;
if (elm_widget_is(obj))
{
top = elm_widget_top_get(obj);
if (!top) top = elm_widget_top_get(elm_widget_parent_widget_get(obj));
if (top && (efl_isa(top, EFL_UI_WIN_CLASS)))
win = elm_win_wl_window_get(top);
}
if (!win)
{
Ecore_Evas *ee = _wl_is_wl(obj);
if (ee)
{
/* In case the engine is not a buffer, we want to check once. */
win = ecore_evas_wayland2_window_get(ee);
if (!win) return NULL;
}
}
return win;
}
int
_wl_default_seat_id_get(Evas_Object *obj)
{
@ -212,8 +188,7 @@ elm_cnp_selection_get(const Evas_Object *obj, Elm_Sel_Type type,
if (!wdata) return EINA_FALSE;
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get((Evas_Object *)obj);
if (_wl_window_get(obj)) seatid = _wl_default_seat_id_get((Evas_Object *)obj);
#endif
wdata->udata = udata;
wdata->datacb = datacb;
@ -238,7 +213,7 @@ elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type type,
data.mem = selbuf;
data.len = buflen;
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get(obj);
if (_wl_window_get(obj)) seatid = _wl_default_seat_id_get(obj);
#endif
f = efl_ui_selection_manager_selection_set(sel_man, obj, (Efl_Ui_Selection_Type)type,
(Efl_Ui_Selection_Format)format, data, seatid);
@ -257,7 +232,7 @@ elm_object_cnp_selection_clear(Evas_Object *obj, Elm_Sel_Type type)
Eo *sel_man = _efl_ui_selection_manager_get((Evas_Object *)obj);
#ifdef HAVE_ELEMENTARY_WL2
seatid = _wl_default_seat_id_get(obj);
if (_wl_window_get(obj)) seatid = _wl_default_seat_id_get(obj);
#endif
efl_ui_selection_manager_selection_clear(sel_man, obj, (Efl_Ui_Selection_Type)type, seatid);
@ -289,7 +264,7 @@ elm_selection_selection_has_owner(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);
if (_wl_window_get(obj)) seatid = _wl_default_seat_id_get(obj);
#endif
return efl_ui_selection_manager_selection_has_owner(sel_man, obj,
@ -303,7 +278,7 @@ elm_cnp_clipboard_selection_has_owner(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);
if (_wl_window_get(obj)) seatid = _wl_default_seat_id_get(obj);
#endif
return efl_ui_selection_manager_selection_has_owner(sel_man, obj,
EFL_UI_SELECTION_TYPE_CLIPBOARD, seatid);

View File

@ -37,7 +37,7 @@ static Ecore_X_Window _x11_xwin_get(const Evas_Object *obj);
#endif
#ifdef HAVE_ELEMENTARY_WL2
static Ecore_Wl2_Window *_wl_window_get(const Evas_Object *obj);
Ecore_Wl2_Window *_wl_window_get(const Evas_Object *obj);
static Ecore_Wl2_Input *_wl_seat_get(Ecore_Wl2_Window *win, Evas_Object *obj, unsigned int seat_id);
#endif
@ -2806,7 +2806,7 @@ _wl_seat_get(Ecore_Wl2_Window *win, Evas_Object *obj, unsigned int seat_id)
evas_device_seat_id_get(seat));
}
static Ecore_Wl2_Window *
Ecore_Wl2_Window *
_wl_window_get(const Evas_Object *obj)
{
Evas_Object *top;