From 4924fc73eeb579684c1a480805d7347e77c38721 Mon Sep 17 00:00:00 2001 From: Alastair Poole Date: Mon, 23 Jul 2018 15:48:28 -0400 Subject: [PATCH] macos: allow text to be selected. Summary: This gives us basic clipboard handling for MacOS after the refactor was done. Test Plan: Open an entry test. select text with mouse or keyboard. Text can be cut. Text can be copied. Text can be pasted. Reviewers: ajwillia.ms, zmike, jayji Reviewed By: zmike Subscribers: jayji, herdsman, cedric, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D6599 --- src/lib/elementary/efl_selection.c | 5 +++++ src/lib/elementary/efl_selection_manager.c | 21 ++++++++++----------- src/lib/elementary/efl_ui_win.c | 8 ++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/lib/elementary/efl_selection.c b/src/lib/elementary/efl_selection.c index 5b6bccf2b0..657a7eb885 100644 --- a/src/lib/elementary/efl_selection.c +++ b/src/lib/elementary/efl_selection.c @@ -290,6 +290,11 @@ elm_cnp_selection_loss_callback_set(Evas_Object *obj, Elm_Sel_Type type, Elm_Selection_Loss_Cb func, const void *data) { Sel_Lost_Data *ldata = calloc(1, sizeof(Sel_Lost_Data)); +#if HAVE_ELEMENTARY_COCOA + // Currently, we have no way to track changes in Cocoa pasteboard. + // Therefore, don't track this... + return; +#endif if (!ldata) return; ldata->obj = obj; ldata->type = type; diff --git a/src/lib/elementary/efl_selection_manager.c b/src/lib/elementary/efl_selection_manager.c index 0498820e98..34c876270e 100644 --- a/src/lib/elementary/efl_selection_manager.c +++ b/src/lib/elementary/efl_selection_manager.c @@ -3823,23 +3823,17 @@ _cocoa_sel_manager_seat_selection_init(Efl_Selection_Manager_Data *pd, unsigned static Ecore_Cocoa_Window * _cocoa_window_get(const Evas_Object *obj) { - Evas_Object *top, *par; Ecore_Cocoa_Window *win = NULL; + Evas_Object *_win; - if (elm_widget_is(obj)) + _win = elm_win_get(obj); + if (_win) { - top = elm_widget_top_get(obj); - if (!top) - { - par = elm_widget_parent_widget_get(obj); - if (par) top = elm_widget_top_get(par); - } - if ((top) && (efl_isa(top, EFL_UI_WIN_CLASS))) - win = elm_win_cocoa_window_get(top); + win = elm_win_cocoa_window_get(_win); } + if (!win) { - // FIXME CRI("WIN has not been retrieved!!!"); } @@ -3942,6 +3936,7 @@ _cocoa_efl_sel_manager_selection_set(Efl_Selection_Manager_Data *pd, seat_sel = _cocoa_sel_manager_seat_selection_init(pd, seat); seat_sel->active_type = type; sel = seat_sel->sel; + if ((!data.mem) && (format != EFL_SELECTION_FORMAT_IMAGE)) { efl_selection_manager_selection_clear(pd->sel_man, owner, type, seat); @@ -4853,6 +4848,10 @@ _efl_selection_manager_selection_has_owner(Eo *obj EINA_UNUSED, Efl_Selection_Ma win = _wl_window_get(request); if (win) return !!ecore_wl2_dnd_selection_get(_wl_seat_get(win, request, seat)); +#endif +#ifdef HAVE_ELEMENTARY_COCOA + // FIXME: need to check if there is clipboard data. Paste always enabled. + return EINA_TRUE; #endif return EINA_FALSE; } diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c index c62559d1bd..170edd2928 100644 --- a/src/lib/elementary/efl_ui_win.c +++ b/src/lib/elementary/efl_ui_win.c @@ -7629,8 +7629,16 @@ elm_win_cocoa_window_get(const Evas_Object *obj) Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS); if (!sd) return NULL; +#if HAVE_ELEMENTARY_COCOA + if (sd->cocoa.win) return sd->cocoa.win; + if (sd->ee) return _elm_ee_cocoa_win_get(sd->ee); + if (sd->parent) return elm_win_cocoa_window_get(sd->parent); +#endif + Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj)); return _elm_ee_cocoa_win_get(ee); + + return NULL; } EAPI Ecore_Win32_Window *