From 587ae10f160b70bb45e072f243d4cad9bb3e0516 Mon Sep 17 00:00:00 2001 From: MinJeong Kim Date: Fri, 23 Sep 2016 17:07:03 +0900 Subject: [PATCH] ecore_wl: support 'tizen_clipboard' interface Change-Id: I50416388ed14db7cfa7330cfeb7a2ea3c8973d36 Signed-off-by: MinJeong Kim --- src/lib/ecore_wayland/Ecore_Wayland.h | 8 ++++++++ src/lib/ecore_wayland/ecore_wl.c | 33 ++++++++++++++++++++++++++++++++ src/lib/ecore_wayland/ecore_wl_private.h | 1 + src/lib/ecore_wayland/ecore_wl_window.c | 22 +++++++++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h b/src/lib/ecore_wayland/Ecore_Wayland.h index 91d232f..0fbd95b 100644 --- a/src/lib/ecore_wayland/Ecore_Wayland.h +++ b/src/lib/ecore_wayland/Ecore_Wayland.h @@ -88,6 +88,7 @@ typedef struct _Ecore_Wl_Display Ecore_Wl_Display; typedef struct _Ecore_Wl_Event_Global Ecore_Wl_Event_Global; typedef struct _Ecore_Wl_Event_Keymap_Update Ecore_Wl_Event_Keymap_Update; typedef struct _Ecore_Wl_Event_Indicator_Flick Ecore_Wl_Event_Indicator_Flick; +typedef struct _Ecore_Wl_Event_Clipboard_Data_Selected Ecore_Wl_Event_Clipboard_Data_Selected; struct _Ecore_Wl_Event_Global { @@ -440,6 +441,10 @@ struct _Ecore_Wl_Event_Indicator_Flick int type; }; +struct _Ecore_Wl_Event_Clipboard_Data_Selected +{ + unsigned int win; +}; /** * @internal * @@ -497,6 +502,7 @@ EAPI extern int ECORE_WL_EVENT_GLOBAL_ADDED; EAPI extern int ECORE_WL_EVENT_GLOBAL_REMOVED; EAPI extern int ECORE_WL_EVENT_KEYMAP_UPDATE; EAPI extern int ECORE_WL_EVENT_INDICATOR_FLICK; +EAPI extern int ECORE_WL_EVENT_CLIPBOARD_DATA_SELECTED; /** * @internal @@ -1515,6 +1521,8 @@ EAPI void ecore_wl_window_clipboard_geometry_set(Ecore_Wl_Window *win, int x, in EAPI Eina_Bool ecore_wl_window_clipboard_geometry_get(Ecore_Wl_Window *win, int *x, int *y, int *w, int *h); EAPI void ecore_wl_window_clipboard_state_set(Ecore_Wl_Window *win, Ecore_Wl_Clipboard_State state); EAPI Ecore_Wl_Clipboard_State ecore_wl_window_clipboard_state_get(Ecore_Wl_Window *win); +EAPI void ecore_wl_clipboard_show(Ecore_Wl_Window *win); +EAPI void ecore_wl_clipboard_hide(Ecore_Wl_Window *win); EAPI void ecore_wl_window_keyboard_geometry_set(Ecore_Wl_Window *win, int x, int y, int w, int h); EAPI Eina_Bool ecore_wl_window_keyboard_geometry_get(Ecore_Wl_Window *win, int *x, int *y, int *w, int *h); diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c index 88660b0..928c5e9 100644 --- a/src/lib/ecore_wayland/ecore_wl.c +++ b/src/lib/ecore_wayland/ecore_wl.c @@ -60,6 +60,7 @@ static void _ecore_wl_cb_active_angle(void *data EINA_UNUSED, struct tizen_polic static void _ecore_wl_cb_effect_start(void *data EINA_UNUSED, struct tizen_effect *tizen_effect EINA_UNUSED, struct wl_surface *surface_resource, unsigned int type); static void _ecore_wl_cb_effect_end(void *data EINA_UNUSED, struct tizen_effect *tizen_effect EINA_UNUSED, struct wl_surface *surface_resource, unsigned int type); static void _ecore_wl_cb_indicator_flick(void *data EINA_UNUSED, struct tizen_indicator *tizen_indicator EINA_UNUSED, struct wl_surface *surface_resource, int type); +static void _ecore_wl_cb_clipboard_data_selected(void *data EINA_UNUSED, struct tizen_clipboard *clipboard EINA_UNUSED, struct wl_surface *surface); static void _ecore_wl_log_cb_print(const char *format, va_list args); /* local variables */ static int _ecore_wl_init_count = 0; @@ -129,6 +130,11 @@ static const struct tizen_indicator_listener _ecore_tizen_indicator_listener = _ecore_wl_cb_indicator_flick, }; +static const struct tizen_clipboard_listener _ecore_tizen_clipboard_listener = +{ + _ecore_wl_cb_clipboard_data_selected, +}; + static void xdg_shell_ping(void *data EINA_UNUSED, struct xdg_shell *shell, uint32_t serial) { @@ -188,6 +194,7 @@ EAPI int ECORE_WL_EVENT_GLOBAL_ADDED = 0; EAPI int ECORE_WL_EVENT_GLOBAL_REMOVED = 0; EAPI int ECORE_WL_EVENT_KEYMAP_UPDATE = 0; EAPI int ECORE_WL_EVENT_INDICATOR_FLICK = 0; +EAPI int ECORE_WL_EVENT_CLIPBOARD_DATA_SELECTED = 0; static void @@ -282,6 +289,7 @@ ecore_wl_init(const char *name) ECORE_WL_EVENT_GLOBAL_REMOVED = ecore_event_type_new(); ECORE_WL_EVENT_KEYMAP_UPDATE = ecore_event_type_new(); ECORE_WL_EVENT_INDICATOR_FLICK = ecore_event_type_new(); + ECORE_WL_EVENT_CLIPBOARD_DATA_SELECTED = ecore_event_type_new(); } wl_log_set_handler_client(_ecore_wl_log_cb_print); @@ -712,6 +720,8 @@ _ecore_wl_shutdown(Eina_Bool close) tizen_effect_destroy(_ecore_wl_disp->wl.tz_effect); if (_ecore_wl_disp->wl.tz_indicator) tizen_indicator_destroy(_ecore_wl_disp->wl.tz_indicator); + if (_ecore_wl_disp->wl.tz_clipboard) + tizen_clipboard_destroy(_ecore_wl_disp->wl.tz_clipboard); if (_ecore_wl_disp->cursor_theme) wl_cursor_theme_destroy(_ecore_wl_disp->cursor_theme); if (_ecore_wl_disp->wl.display) @@ -1005,6 +1015,13 @@ _ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned in if (ewd->wl.tz_indicator) tizen_indicator_add_listener(ewd->wl.tz_indicator, &_ecore_tizen_indicator_listener, ewd->wl.display); } + else if (!strcmp(interface, "tizen_clipboard")) + { + ewd->wl.tz_clipboard = + wl_registry_bind(registry, id, &tizen_clipboard_interface, 1); + if (ewd->wl.tz_clipboard) + tizen_clipboard_add_listener(ewd->wl.tz_clipboard, &_ecore_tizen_clipboard_listener, ewd->wl.display); + } if ((ewd->wl.compositor) && (ewd->wl.shm) && ((ewd->wl.shell) || (ewd->wl.xdg_shell))) @@ -1796,6 +1813,22 @@ _ecore_wl_cb_indicator_flick(void *data EINA_UNUSED, struct tizen_indicator *tiz } static void +_ecore_wl_cb_clipboard_data_selected(void *data EINA_UNUSED, struct tizen_clipboard *tizen_clipboard EINA_UNUSED, struct wl_surface *surface) +{ + Ecore_Wl_Window *win = NULL; + Ecore_Wl_Event_Clipboard_Data_Selected *ev; + + if (!surface) return; + win = ecore_wl_window_surface_find(surface); + if (!win) return; + + if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Clipboard_Data_Selected)))) return; + ev->win = win->id; + + ecore_event_add(ECORE_WL_EVENT_CLIPBOARD_DATA_SELECTED, ev, NULL, NULL); +} + +static void _ecore_wl_log_cb_print(const char *format, va_list args) { char buffer[1024]; diff --git a/src/lib/ecore_wayland/ecore_wl_private.h b/src/lib/ecore_wayland/ecore_wl_private.h index 49007a7..f311496 100644 --- a/src/lib/ecore_wayland/ecore_wl_private.h +++ b/src/lib/ecore_wayland/ecore_wl_private.h @@ -101,6 +101,7 @@ struct _Ecore_Wl_Display struct tizen_input_device_manager *tz_input_device_manager; struct tizen_effect *tz_effect; struct tizen_indicator *tz_indicator; + struct tizen_clipboard *tz_clipboard; Eina_Bool prepare_read; } wl; diff --git a/src/lib/ecore_wayland/ecore_wl_window.c b/src/lib/ecore_wayland/ecore_wl_window.c index ea78aa1..1537082 100644 --- a/src/lib/ecore_wayland/ecore_wl_window.c +++ b/src/lib/ecore_wayland/ecore_wl_window.c @@ -2028,6 +2028,28 @@ ecore_wl_window_clipboard_state_get(Ecore_Wl_Window *win) return win->clipboard.state; } +EAPI void +ecore_wl_clipboard_show(Ecore_Wl_Window *win) +{ + LOGFN(__FILE__, __LINE__, __FUNCTION__); + if (!win) return; + if (!win->surface) return; + if (!_ecore_wl_disp->wl.tz_clipboard) return; + + tizen_clipboard_show(_ecore_wl_disp->wl.tz_clipboard, win->surface); +} + +EAPI void +ecore_wl_clipboard_hide(Ecore_Wl_Window *win) +{ + LOGFN(__FILE__, __LINE__, __FUNCTION__); + if (!win) return; + if (!win->surface) return; + if (!_ecore_wl_disp->wl.tz_clipboard) return; + + tizen_clipboard_hide(_ecore_wl_disp->wl.tz_clipboard, win->surface); +} + void ecore_wl_window_keyboard_geometry_set(Ecore_Wl_Window *win, int x, int y, int w, int h) { -- 2.7.4