ecore_wl: support 'tizen_clipboard' interface 93/89393/5 submit/tizen/20161011.025405
authorMinJeong Kim <minjjj.kim@samsung.com>
Fri, 23 Sep 2016 08:07:03 +0000 (17:07 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Fri, 7 Oct 2016 09:46:16 +0000 (02:46 -0700)
Change-Id: I50416388ed14db7cfa7330cfeb7a2ea3c8973d36
Signed-off-by: MinJeong Kim <minjjj.kim@samsung.com>
src/lib/ecore_wayland/Ecore_Wayland.h
src/lib/ecore_wayland/ecore_wl.c
src/lib/ecore_wayland/ecore_wl_private.h
src/lib/ecore_wayland/ecore_wl_window.c

index 91d232f..0fbd95b 100644 (file)
@@ -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);
index 88660b0..928c5e9 100644 (file)
@@ -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];
index 49007a7..f311496 100644 (file)
@@ -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;
index ea78aa1..1537082 100644 (file)
@@ -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)
 {