support 'transient_for' protocol 26/39526/3
authorDuna Oh <duna.oh@samsung.com>
Mon, 18 May 2015 07:38:26 +0000 (16:38 +0900)
committerBoram Park <boram1288.park@samsung.com>
Mon, 18 May 2015 12:23:33 +0000 (21:23 +0900)
Add 'tizen_surface_extension', 'tizen_resource' interfaces

Signed-off-by: Duna Oh <duna.oh@samsung.com>
Change-Id: Ibffb7da647a66ba38c9acce42cb58625c017805e

src/Makefile_Ecore_Wayland.am
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
src/lib/ecore_wayland/tizen-extension-client-protocol.h [new file with mode: 0644]
src/lib/ecore_wayland/tizen-extension-protocol.c [new file with mode: 0644]

index 4032b40..1b2730d 100644 (file)
@@ -23,7 +23,9 @@ lib/ecore_wayland/ivi-application-client-protocol.h \
 lib/ecore_wayland/xdg-shell-client-protocol.h \
 lib/ecore_wayland/xdg-shell-protocol.c \
 lib/ecore_wayland/tizen-policy-client-protocol.h \
-lib/ecore_wayland/tizen-policy-protocol.c
+lib/ecore_wayland/tizen-policy-protocol.c \
+lib/ecore_wayland/tizen-extension-client-protocol.h \
+lib/ecore_wayland/tizen-extension-protocol.c
 
 lib_ecore_wayland_libecore_wayland_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ECORE_WAYLAND_CFLAGS@
 lib_ecore_wayland_libecore_wayland_la_LIBADD = @ECORE_WAYLAND_LIBS@
index 703c2a6..168e877 100644 (file)
@@ -176,6 +176,7 @@ struct _Ecore_Wl_Event_Window_Show
    unsigned int win;
    unsigned int parent_win;
    unsigned int event_win;
+   unsigned int data[4];
 };
 
 struct _Ecore_Wl_Event_Window_Hide
index e4f69dc..6491a64 100644 (file)
@@ -518,6 +518,8 @@ _ecore_wl_shutdown(Eina_Bool close)
           wl_data_device_manager_destroy(_ecore_wl_disp->wl.data_device_manager);
         if (_ecore_wl_disp->wl.tz_policy)
           tizen_policy_destroy(_ecore_wl_disp->wl.tz_policy);
+        if (_ecore_wl_disp->wl.tz_surf_ext)
+          tizen_surface_extension_destroy(_ecore_wl_disp->wl.tz_surf_ext);
         if (_ecore_wl_disp->wl.compositor)
           wl_compositor_destroy(_ecore_wl_disp->wl.compositor);
         if (_ecore_wl_disp->wl.subcompositor)
@@ -701,6 +703,11 @@ _ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned in
         ewd->wl.tz_policy =
           wl_registry_bind(registry, id, &tizen_policy_interface, 1);
      }
+   else if (!strcmp(interface, "tizen_surface_extension"))
+     {
+        ewd->wl.tz_surf_ext =
+          wl_registry_bind(registry, id, &tizen_surface_extension_interface, 1);
+     }
 
    if ((ewd->wl.compositor) && (ewd->wl.shm) && 
        ((ewd->wl.shell) || (ewd->wl.xdg_shell)))
index 16af605..af4f1cb 100644 (file)
@@ -13,6 +13,7 @@
 # endif
 
 # include "tizen-policy-client-protocol.h"
+# include "tizen-extension-client-protocol.h"
 
 //# define LOGFNS 1
 
@@ -79,6 +80,7 @@ struct _Ecore_Wl_Display
         struct wl_shm *shm;
         struct wl_data_device_manager *data_device_manager;
         struct tizen_policy *tz_policy;
+        struct tizen_surface_extension *tz_surf_ext;
      } wl;
 
    int fd;
@@ -120,6 +122,8 @@ struct _Ecore_Wl_Window
    int ivi_surface_id;
 # endif
    struct tizen_visibility *tz_visibility;
+   struct tizen_resource *tz_resource;
+   unsigned int resource_id;
 
    struct wl_region *opaque_region;
    struct wl_region *input_region;
index 2789222..c414223 100644 (file)
@@ -5,6 +5,7 @@
 #include "ecore_wl_private.h"
 #include "xdg-shell-client-protocol.h"
 #include "tizen-policy-client-protocol.h"
+#include "tizen-extension-client-protocol.h"
 
 /* local function prototypes */
 static void _ecore_wl_window_cb_ping(void *data EINA_UNUSED, struct wl_shell_surface *shell_surface, unsigned int serial);
@@ -20,6 +21,7 @@ static void _ecore_xdg_handle_surface_configure(void *data, struct xdg_surface *
 static void _ecore_xdg_handle_surface_delete(void *data, struct xdg_surface *xdg_surface);
 static void _ecore_xdg_handle_popup_done(void *data, struct xdg_popup *xdg_popup, unsigned int serial);
 static void _ecore_wl_window_cb_visibility_change(void *data, struct tizen_visibility *tizen_visibility, uint32_t visibility);
+static void _ecore_wl_window_cb_resource_id(void *data, struct tizen_resource *tizen_resource, uint32_t id);
 
 /* local variables */
 static Eina_Hash *_windows = NULL;
@@ -54,6 +56,11 @@ static const struct tizen_visibility_listener _ecore_tizen_visibility_listener =
    _ecore_wl_window_cb_visibility_change,
 };
 
+static const struct tizen_resource_listener _ecore_tizen_resource_listener =
+{
+   _ecore_wl_window_cb_resource_id,
+};
+
 /* internal functions */
 void 
 _ecore_wl_window_init(void)
@@ -392,6 +399,15 @@ ecore_wl_window_show(Ecore_Wl_Window *win)
              tizen_visibility_add_listener(win->tz_visibility,
                                            &_ecore_tizen_visibility_listener, win);
           }
+        if ((!win->tz_resource) && (_ecore_wl_disp->wl.tz_surf_ext))
+          {
+             win->tz_resource =
+               tizen_surface_extension_get_tizen_resource(_ecore_wl_disp->wl.tz_surf_ext,
+                                                          win->surface);
+             if (!win->tz_resource) return;
+             tizen_resource_add_listener(win->tz_resource,
+                                         &_ecore_tizen_resource_listener, win);
+          }
      }
 
    /* trap for valid shell surface */
@@ -1164,6 +1180,29 @@ _ecore_wl_window_cb_visibility_change(void *data,
 }
 
 static void
+_ecore_wl_window_cb_resource_id(void *data,
+                                struct tizen_resource *tizen_resource,
+                                uint32_t id)
+{
+   Ecore_Wl_Window *win;
+   Ecore_Wl_Event_Window_Show *ev;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   if (!(win = data)) return;
+   if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Window_Show)))) return;
+   ev->win = win->id;
+   if (win->parent)
+       ev->parent_win = win->parent->id;
+   else
+       ev->parent_win = 0;
+   ev->event_win = win->id;
+   ev->data[0] = (unsigned int)id;
+   win->resource_id = (unsigned int)id;
+   ecore_event_add(ECORE_WL_EVENT_WINDOW_SHOW, ev, NULL, NULL);
+}
+
+static void
 _ecore_wl_window_cb_xdg_surface_delete(void *data EINA_UNUSED, struct xdg_surface *xdg_surface EINA_UNUSED)
 {
 }
diff --git a/src/lib/ecore_wayland/tizen-extension-client-protocol.h b/src/lib/ecore_wayland/tizen-extension-client-protocol.h
new file mode 100644 (file)
index 0000000..4c9efe7
--- /dev/null
@@ -0,0 +1,152 @@
+#ifndef TIZEN_EXTENSION_CLIENT_PROTOCOL_H
+#define TIZEN_EXTENSION_CLIENT_PROTOCOL_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-client.h"
+
+struct wl_client;
+struct wl_resource;
+
+struct tizen_resource;
+struct tizen_surface_extension;
+struct tizen_transient_for;
+
+extern const struct wl_interface tizen_resource_interface;
+extern const struct wl_interface tizen_surface_extension_interface;
+extern const struct wl_interface tizen_transient_for_interface;
+
+struct tizen_resource_listener {
+       /**
+        * resource_id - (none)
+        * @id: (none)
+        */
+       void (*resource_id)(void *data,
+                           struct tizen_resource *tizen_resource,
+                           uint32_t id);
+};
+
+static inline int
+tizen_resource_add_listener(struct tizen_resource *tizen_resource,
+                           const struct tizen_resource_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) tizen_resource,
+                                    (void (**)(void)) listener, data);
+}
+
+#define TIZEN_RESOURCE_DESTROY 0
+
+static inline void
+tizen_resource_set_user_data(struct tizen_resource *tizen_resource, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) tizen_resource, user_data);
+}
+
+static inline void *
+tizen_resource_get_user_data(struct tizen_resource *tizen_resource)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) tizen_resource);
+}
+
+static inline void
+tizen_resource_destroy(struct tizen_resource *tizen_resource)
+{
+       wl_proxy_marshal((struct wl_proxy *) tizen_resource,
+                        TIZEN_RESOURCE_DESTROY);
+
+       wl_proxy_destroy((struct wl_proxy *) tizen_resource);
+}
+
+#define TIZEN_SURFACE_EXTENSION_GET_TIZEN_RESOURCE     0
+#define TIZEN_SURFACE_EXTENSION_PLACE_BELOW_PARENT     1
+
+static inline void
+tizen_surface_extension_set_user_data(struct tizen_surface_extension *tizen_surface_extension, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) tizen_surface_extension, user_data);
+}
+
+static inline void *
+tizen_surface_extension_get_user_data(struct tizen_surface_extension *tizen_surface_extension)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) tizen_surface_extension);
+}
+
+static inline void
+tizen_surface_extension_destroy(struct tizen_surface_extension *tizen_surface_extension)
+{
+       wl_proxy_destroy((struct wl_proxy *) tizen_surface_extension);
+}
+
+static inline struct tizen_resource *
+tizen_surface_extension_get_tizen_resource(struct tizen_surface_extension *tizen_surface_extension, struct wl_surface *surface)
+{
+       struct wl_proxy *id;
+
+       id = wl_proxy_marshal_constructor((struct wl_proxy *) tizen_surface_extension,
+                        TIZEN_SURFACE_EXTENSION_GET_TIZEN_RESOURCE, &tizen_resource_interface, NULL, surface);
+
+       return (struct tizen_resource *) id;
+}
+
+static inline void
+tizen_surface_extension_place_below_parent(struct tizen_surface_extension *tizen_surface_extension, struct wl_subsurface *subsurface)
+{
+       wl_proxy_marshal((struct wl_proxy *) tizen_surface_extension,
+                        TIZEN_SURFACE_EXTENSION_PLACE_BELOW_PARENT, subsurface);
+}
+
+struct tizen_transient_for_listener {
+       /**
+        * done - (none)
+        * @child_id: (none)
+        */
+       void (*done)(void *data,
+                    struct tizen_transient_for *tizen_transient_for,
+                    uint32_t child_id);
+};
+
+static inline int
+tizen_transient_for_add_listener(struct tizen_transient_for *tizen_transient_for,
+                                const struct tizen_transient_for_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) tizen_transient_for,
+                                    (void (**)(void)) listener, data);
+}
+
+#define TIZEN_TRANSIENT_FOR_SET        0
+
+static inline void
+tizen_transient_for_set_user_data(struct tizen_transient_for *tizen_transient_for, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) tizen_transient_for, user_data);
+}
+
+static inline void *
+tizen_transient_for_get_user_data(struct tizen_transient_for *tizen_transient_for)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) tizen_transient_for);
+}
+
+static inline void
+tizen_transient_for_destroy(struct tizen_transient_for *tizen_transient_for)
+{
+       wl_proxy_destroy((struct wl_proxy *) tizen_transient_for);
+}
+
+static inline void
+tizen_transient_for_set(struct tizen_transient_for *tizen_transient_for, uint32_t child_id, uint32_t parent_id)
+{
+       wl_proxy_marshal((struct wl_proxy *) tizen_transient_for,
+                        TIZEN_TRANSIENT_FOR_SET, child_id, parent_id);
+}
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/lib/ecore_wayland/tizen-extension-protocol.c b/src/lib/ecore_wayland/tizen-extension-protocol.c
new file mode 100644 (file)
index 0000000..66d2e62
--- /dev/null
@@ -0,0 +1,54 @@
+#include <stdlib.h>
+#include <stdint.h>
+#include "wayland-util.h"
+
+extern const struct wl_interface tizen_resource_interface;
+extern const struct wl_interface wl_surface_interface;
+extern const struct wl_interface wl_subsurface_interface;
+
+static const struct wl_interface *types[] = {
+       NULL,
+       NULL,
+       &tizen_resource_interface,
+       &wl_surface_interface,
+       &wl_subsurface_interface,
+};
+
+static const struct wl_message tizen_resource_requests[] = {
+       { "destroy", "", types + 0 },
+};
+
+static const struct wl_message tizen_resource_events[] = {
+       { "resource_id", "u", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface tizen_resource_interface = {
+       "tizen_resource", 1,
+       1, tizen_resource_requests,
+       1, tizen_resource_events,
+};
+
+static const struct wl_message tizen_surface_extension_requests[] = {
+       { "get_tizen_resource", "no", types + 2 },
+       { "place_below_parent", "o", types + 4 },
+};
+
+WL_EXPORT const struct wl_interface tizen_surface_extension_interface = {
+       "tizen_surface_extension", 1,
+       2, tizen_surface_extension_requests,
+       0, NULL,
+};
+
+static const struct wl_message tizen_transient_for_requests[] = {
+       { "set", "uu", types + 0 },
+};
+
+static const struct wl_message tizen_transient_for_events[] = {
+       { "done", "u", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface tizen_transient_for_interface = {
+       "tizen_transient_for", 1,
+       1, tizen_transient_for_requests,
+       1, tizen_transient_for_events,
+};