ecore_wl2: add code for tizen protocols
authorDoyoun Kang <doyoun.kang@samsung.com>
Tue, 7 Nov 2017 01:01:51 +0000 (10:01 +0900)
committerJiyoun Park <jy0703.park@samsung.com>
Mon, 18 Dec 2017 22:29:54 +0000 (07:29 +0900)
tizen_policy, tizen_policy_ext, tizen_surface, tizen_effect, tizen_indicator, tizen_clipboard

@tizen_feature

Change-Id: I3a302a2abeea4e51d876a7cd4c9e271b4c330dd4

.gitignore
configure.ac
src/Makefile_Ecore_Wl2.am
src/lib/ecore_wl2/ecore_wl2_display.c
src/lib/ecore_wl2/ecore_wl2_private.h
src/lib/ecore_wl2/tizen-policy-ext-client-protocol.h [new file with mode: 0644]
src/lib/ecore_wl2/tizen-policy-ext-protocol.c [new file with mode: 0644]

index 76dd797..5d33fa3 100644 (file)
@@ -83,8 +83,7 @@ Session.vim
 /src/bin/efl_wl/efl_wl_test_stack
 
 #wayland generated protocol - some legacy headers will be ignored
-*-protocol.h
-*-protocol.c
+pc/efl-wl.pc
 
 /build
 .cproject
index c399877..272b837 100644 (file)
@@ -3765,7 +3765,7 @@ EFL_INTERNAL_DEPEND_PKG([ECORE_WL2], [efl])
 EFL_INTERNAL_DEPEND_PKG([ECORE_WL2], [eina])
 
 EFL_DEPEND_PKG([ECORE_WL2], [WAYLAND],
-   [wayland-server >= 1.11.0 wayland-client >= 1.11.0 xkbcommon >= 0.6.0])
+   [wayland-server >= 1.11.0 wayland-client >= 1.11.0 xkbcommon >= 0.6.0] tizen-extension-client)
 
 EFL_EVAL_PKGS([ECORE_WL2])
 
index a794d0b..baeab6e 100644 (file)
@@ -27,7 +27,8 @@ static_libs/libdrm/i915_drm.h \
 static_libs/libdrm/intel_bufmgr.h \
 static_libs/libdrm/vc4_drm.h \
 static_libs/libdrm/LICENSE
-
+lib/ecore_wl2/tizen-policy-ext-client-protocol.h \
+lib/ecore_wl2/tizen-policy-ext-protocol.c \
 
 nodist_lib_ecore_wl2_libecore_wl2_la_SOURCES = \
 lib/ecore_wl2/efl-aux-hints-protocol.c \
index 9785406..e1f704b 100644 (file)
@@ -216,6 +216,124 @@ static const struct efl_aux_hints_listener _aux_hints_listener =
    _aux_hints_aux_message,
 };
 
+// TIZEN_ONLY : To use tizen protocols
+static void
+_tizen_policy_cb_conformant(void *data EINA_UNUSED, struct tizen_policy *tizen_policy EINA_UNUSED, struct wl_surface *surface_resource, uint32_t is_conformant)
+{
+}
+
+static void
+_tizen_policy_cb_conformant_area(void *data EINA_UNUSED, struct tizen_policy *tizen_policy EINA_UNUSED, struct wl_surface *surface_resource, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
+{
+}
+
+static void
+_tizen_policy_cb_notification_done(void *data EINA_UNUSED, struct tizen_policy *tizen_policy EINA_UNUSED, struct wl_surface *surface EINA_UNUSED, int32_t level EINA_UNUSED, uint32_t state EINA_UNUSED)
+{
+}
+
+static void
+_tizen_policy_cb_transient_for_done(void *data EINA_UNUSED, struct tizen_policy *tizen_policy EINA_UNUSED, uint32_t child_id EINA_UNUSED)
+{
+}
+
+static void
+_tizen_policy_cb_window_screen_mode_done(void *data EINA_UNUSED, struct tizen_policy *tizen_policy EINA_UNUSED, struct wl_surface *surface EINA_UNUSED, uint32_t mode EINA_UNUSED, uint32_t state EINA_UNUSED)
+{
+}
+
+static void
+_tizen_policy_cb_iconify_state_changed(void *data EINA_UNUSED, struct tizen_policy *tizen_policy EINA_UNUSED, struct wl_surface *surface_resource, uint32_t iconified, uint32_t force)
+{
+}
+
+static void
+_tizen_policy_cb_supported_aux_hints(void *data EINA_UNUSED, struct tizen_policy *tizen_policy EINA_UNUSED, struct wl_surface *surface_resource, struct wl_array *hints, uint32_t num_hints)
+{
+}
+
+static void
+_tizen_policy_cb_allowed_aux_hint(void *data  EINA_UNUSED, struct tizen_policy *tizen_policy  EINA_UNUSED, struct wl_surface *surface_resource, int id)
+{
+}
+
+static void
+_tizen_policy_cb_aux_message(void *data EINA_UNUSED, struct tizen_policy *tizen_policy EINA_UNUSED, struct wl_surface *surface_resource, const char *key, const char *val, struct wl_array *options)
+{
+}
+
+static void
+_tizen_policy_cb_conformant_region(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial)
+{
+}
+
+static const struct tizen_policy_listener _tizen_policy_listener =
+{
+   _tizen_policy_cb_conformant,
+   _tizen_policy_cb_conformant_area,
+   _tizen_policy_cb_notification_done,
+   _tizen_policy_cb_transient_for_done,
+   _tizen_policy_cb_window_screen_mode_done,
+   _tizen_policy_cb_iconify_state_changed,
+   _tizen_policy_cb_supported_aux_hints,
+   _tizen_policy_cb_allowed_aux_hint,
+   _tizen_policy_cb_aux_message,
+   _tizen_policy_cb_conformant_region,
+};
+
+static void
+_tizen_policy_ext_cb_active_angle(void *data EINA_UNUSED, struct tizen_policy_ext *tizen_policy_ext EINA_UNUSED, uint32_t angle)
+{
+}
+
+static const struct tizen_policy_ext_listener _tizen_policy_ext_listener =
+{
+   _tizen_policy_ext_cb_active_angle,
+};
+
+static void
+_tizen_effect_cb_start(void *data EINA_UNUSED, struct tizen_effect *tizen_effect EINA_UNUSED, struct wl_surface *surface_resource, unsigned int type)
+{
+}
+
+static void
+_tizen_effect_cb_end(void *data EINA_UNUSED, struct tizen_effect *tizen_effect EINA_UNUSED, struct wl_surface *surface_resource, unsigned int type)
+{
+}
+
+static const struct tizen_effect_listener _tizen_effect_listener =
+{
+   _tizen_effect_cb_start,
+   _tizen_effect_cb_end,
+};
+
+static void
+_tizen_indicator_cb_flick(void *data EINA_UNUSED, struct tizen_indicator *tizen_indicator EINA_UNUSED, struct wl_surface *surface_resource, int type)
+{
+}
+
+static const struct tizen_indicator_listener _tizen_indicator_listener =
+{
+   _tizen_indicator_cb_flick,
+};
+
+static void
+_tizen_clipboard_cb_data_selected(void *data EINA_UNUSED, struct tizen_clipboard *tizen_clipboard EINA_UNUSED, struct wl_surface *surface)
+{
+}
+
+static void
+_tizen_clipboard_cb_allowed_data_only(void *data EINA_UNUSED, struct tizen_clipboard *tizen_clipboard EINA_UNUSED, uint32_t allowed)
+{
+}
+
+static const struct tizen_clipboard_listener _tizen_clipboard_listener =
+{
+   _tizen_clipboard_cb_data_selected,
+   _tizen_clipboard_cb_allowed_data_only,
+};
+//
+
 static void
 _cb_global_event_free(void *data EINA_UNUSED, void *event)
 {
@@ -232,6 +350,9 @@ _cb_global_add(void *data, struct wl_registry *registry, unsigned int id, const
 {
    Ecore_Wl2_Display *ewd;
    Ecore_Wl2_Event_Global *ev;
+   // TIZEN_ONLY
+   int client_version = 1;
+   //
 
    ewd = data;
 
@@ -346,6 +467,63 @@ _cb_global_add(void *data, struct wl_registry *registry, unsigned int id, const
                  window->zxdg_surface, window->weight.w, window->weight.h);
           }
      }
+   // TIZEN_ONLY : To use tizen protocols
+   else if (!strcmp(interface, "tizen_policy"))
+     {
+        if (version >= 7)
+          client_version = 7;
+        else
+          client_version = version;
+
+        ewd->wl.tz_policy =
+           wl_registry_bind(registry, id, &tizen_policy_interface, client_version);
+        if (ewd->wl.tz_policy)
+          tizen_policy_add_listener(ewd->wl.tz_policy, &_tizen_policy_listener, ewd->wl.display);
+     }
+   else if (!strcmp(interface, "tizen_policy_ext"))
+     {
+        if (version >= 3)
+          client_version = 3;
+        else
+          client_version = version;
+
+        ewd->wl.tz_policy_ext =
+           wl_registry_bind(registry, id, &tizen_policy_ext_interface, client_version);
+        if (ewd->wl.tz_policy_ext)
+          tizen_policy_ext_add_listener(ewd->wl.tz_policy_ext, &_tizen_policy_ext_listener, ewd->wl.display);
+     }
+   else if (!strcmp(interface, "tizen_surface"))
+     {
+        ewd->wl.tz_surf =
+           wl_registry_bind(registry, id, &tizen_surface_interface, 1);
+     }
+   else if (!strcmp(interface, "tizen_effect"))
+     {
+        ewd->wl.tz_effect =
+           wl_registry_bind(registry, id, &tizen_effect_interface, 1);
+        if (ewd->wl.tz_effect)
+          tizen_effect_add_listener(ewd->wl.tz_effect, &_tizen_effect_listener, ewd->wl.display);
+     }
+   else if (!strcmp(interface, "tizen_indicator"))
+     {
+        ewd->wl.tz_indicator =
+           wl_registry_bind(registry, id, &tizen_indicator_interface, 1);
+        if (ewd->wl.tz_indicator)
+          tizen_indicator_add_listener(ewd->wl.tz_indicator, &_tizen_indicator_listener, ewd->wl.display);
+     }
+   else if (!strcmp(interface, "tizen_clipboard"))
+     {
+        if (version >= 2)
+          client_version = 2;
+        else
+          client_version = version;
+
+        ewd->wl.tz_clipboard =
+           wl_registry_bind(registry, id, &tizen_clipboard_interface, client_version);
+        if (ewd->wl.tz_clipboard)
+          tizen_clipboard_add_listener(ewd->wl.tz_clipboard, &_tizen_clipboard_listener, ewd->wl.display);
+     }
+   //
 
 event:
    /* allocate space for event structure */
index 0648bfc..c4c4593 100644 (file)
 # include "xdg-shell-unstable-v6-client-protocol.h"
 # include "efl-aux-hints-client-protocol.h"
 
+// TIZEN_ONLY : To use tizen protocols
+# include <wayland-extension/tizen-extension-client-protocol.h>
+# include "tizen-policy-ext-client-protocol.h"
+//
+
 extern int _ecore_wl2_log_dom;
 extern Eina_Bool no_session_recovery;
 
@@ -93,6 +98,14 @@ struct _Ecore_Wl2_Display
         struct efl_aux_hints *efl_aux_hints;
         struct zwp_teamwork *teamwork;
         struct efl_hints *efl_hints;
+        // TIZEN_ONLY : To use tizen protocols
+        struct tizen_policy *tz_policy;
+        struct tizen_policy_ext *tz_policy_ext;
+        struct tizen_surface *tz_surf;
+        struct tizen_effect *tz_effect;
+        struct tizen_indicator *tz_indicator;
+        struct tizen_clipboard *tz_clipboard;
+        //
         int compositor_version;
      } wl;
 
diff --git a/src/lib/ecore_wl2/tizen-policy-ext-client-protocol.h b/src/lib/ecore_wl2/tizen-policy-ext-client-protocol.h
new file mode 100644 (file)
index 0000000..b3b04f0
--- /dev/null
@@ -0,0 +1,222 @@
+#ifndef TIZEN_POLICY_EXT_CLIENT_PROTOCOL_H
+#define TIZEN_POLICY_EXT_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_policy_ext;
+struct tizen_rotation;
+struct wl_surface;
+
+extern const struct wl_interface tizen_policy_ext_interface;
+extern const struct wl_interface tizen_rotation_interface;
+
+struct tizen_policy_ext_listener {
+       /**
+        * active_angle - (none)
+        * @angle: (none)
+        */
+       void (*active_angle)(void *data,
+                            struct tizen_policy_ext *tizen_policy_ext,
+                            uint32_t angle);
+};
+
+static inline int
+tizen_policy_ext_add_listener(struct tizen_policy_ext *tizen_policy_ext,
+                             const struct tizen_policy_ext_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) tizen_policy_ext,
+                                    (void (**)(void)) listener, data);
+}
+
+#define TIZEN_POLICY_EXT_GET_ROTATION  0
+#define TIZEN_POLICY_EXT_GET_ACTIVE_ANGLE      1
+
+#define TIZEN_POLICY_EXT_GET_ROTATION_SINCE_VERSION    1
+#define TIZEN_POLICY_EXT_GET_ACTIVE_ANGLE_SINCE_VERSION        1
+
+static inline void
+tizen_policy_ext_set_user_data(struct tizen_policy_ext *tizen_policy_ext, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) tizen_policy_ext, user_data);
+}
+
+static inline void *
+tizen_policy_ext_get_user_data(struct tizen_policy_ext *tizen_policy_ext)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) tizen_policy_ext);
+}
+
+static inline uint32_t
+tizen_policy_ext_get_version(struct tizen_policy_ext *tizen_policy_ext)
+{
+       return wl_proxy_get_version((struct wl_proxy *) tizen_policy_ext);
+}
+
+static inline void
+tizen_policy_ext_destroy(struct tizen_policy_ext *tizen_policy_ext)
+{
+       wl_proxy_destroy((struct wl_proxy *) tizen_policy_ext);
+}
+
+static inline struct tizen_rotation *
+tizen_policy_ext_get_rotation(struct tizen_policy_ext *tizen_policy_ext, struct wl_surface *surface)
+{
+       struct wl_proxy *id;
+
+       id = wl_proxy_marshal_constructor((struct wl_proxy *) tizen_policy_ext,
+                        TIZEN_POLICY_EXT_GET_ROTATION, &tizen_rotation_interface, NULL, surface);
+
+       return (struct tizen_rotation *) id;
+}
+
+static inline void
+tizen_policy_ext_get_active_angle(struct tizen_policy_ext *tizen_policy_ext, struct wl_surface *surface)
+{
+       wl_proxy_marshal((struct wl_proxy *) tizen_policy_ext,
+                        TIZEN_POLICY_EXT_GET_ACTIVE_ANGLE, surface);
+}
+
+#ifndef TIZEN_ROTATION_ANGLE_ENUM
+#define TIZEN_ROTATION_ANGLE_ENUM
+enum tizen_rotation_angle {
+       TIZEN_ROTATION_ANGLE_NONE = 0,
+       TIZEN_ROTATION_ANGLE_0 = 1,
+       TIZEN_ROTATION_ANGLE_90 = 2,
+       TIZEN_ROTATION_ANGLE_180 = 4,
+       TIZEN_ROTATION_ANGLE_270 = 8,
+};
+#endif /* TIZEN_ROTATION_ANGLE_ENUM */
+
+struct tizen_rotation_listener {
+       /**
+        * available_angles_done - (none)
+        * @angles: (none)
+        */
+       void (*available_angles_done)(void *data,
+                                     struct tizen_rotation *tizen_rotation,
+                                     uint32_t angles);
+       /**
+        * preferred_angle_done - (none)
+        * @angle: (none)
+        */
+       void (*preferred_angle_done)(void *data,
+                                    struct tizen_rotation *tizen_rotation,
+                                    uint32_t angle);
+       /**
+        * angle_change - suggest a angle_change
+        * @angle: (none)
+        * @serial: (none)
+        *
+        *
+        */
+       void (*angle_change)(void *data,
+                            struct tizen_rotation *tizen_rotation,
+                            uint32_t angle,
+                            uint32_t serial);
+       /**
+        * angle_change_with_resize - suggest a angle change with resize
+        *      of window
+        * @angle: (none)
+        * @serial: (none)
+        * @width: (none)
+        * @height: (none)
+        *
+        *
+        * @since: 2
+        */
+       void (*angle_change_with_resize)(void *data,
+                                        struct tizen_rotation *tizen_rotation,
+                                        uint32_t angle,
+                                        uint32_t serial,
+                                        uint32_t width,
+                                        uint32_t height);
+};
+
+static inline int
+tizen_rotation_add_listener(struct tizen_rotation *tizen_rotation,
+                           const struct tizen_rotation_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) tizen_rotation,
+                                    (void (**)(void)) listener, data);
+}
+
+#define TIZEN_ROTATION_DESTROY 0
+#define TIZEN_ROTATION_SET_AVAILABLE_ANGLES    1
+#define TIZEN_ROTATION_SET_PREFERRED_ANGLE     2
+#define TIZEN_ROTATION_ACK_ANGLE_CHANGE        3
+#define TIZEN_ROTATION_SET_GEOMETRY_HINT       4
+
+#define TIZEN_ROTATION_DESTROY_SINCE_VERSION   1
+#define TIZEN_ROTATION_SET_AVAILABLE_ANGLES_SINCE_VERSION      1
+#define TIZEN_ROTATION_SET_PREFERRED_ANGLE_SINCE_VERSION       1
+#define TIZEN_ROTATION_ACK_ANGLE_CHANGE_SINCE_VERSION  1
+
+static inline void
+tizen_rotation_set_user_data(struct tizen_rotation *tizen_rotation, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) tizen_rotation, user_data);
+}
+
+static inline void *
+tizen_rotation_get_user_data(struct tizen_rotation *tizen_rotation)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) tizen_rotation);
+}
+
+static inline uint32_t
+tizen_rotation_get_version(struct tizen_rotation *tizen_rotation)
+{
+       return wl_proxy_get_version((struct wl_proxy *) tizen_rotation);
+}
+
+static inline void
+tizen_rotation_destroy(struct tizen_rotation *tizen_rotation)
+{
+       wl_proxy_marshal((struct wl_proxy *) tizen_rotation,
+                        TIZEN_ROTATION_DESTROY);
+
+       wl_proxy_destroy((struct wl_proxy *) tizen_rotation);
+}
+
+static inline void
+tizen_rotation_set_available_angles(struct tizen_rotation *tizen_rotation, uint32_t angles)
+{
+       wl_proxy_marshal((struct wl_proxy *) tizen_rotation,
+                        TIZEN_ROTATION_SET_AVAILABLE_ANGLES, angles);
+}
+
+static inline void
+tizen_rotation_set_preferred_angle(struct tizen_rotation *tizen_rotation, uint32_t angle)
+{
+       wl_proxy_marshal((struct wl_proxy *) tizen_rotation,
+                        TIZEN_ROTATION_SET_PREFERRED_ANGLE, angle);
+}
+
+static inline void
+tizen_rotation_ack_angle_change(struct tizen_rotation *tizen_rotation, uint32_t serial)
+{
+       wl_proxy_marshal((struct wl_proxy *) tizen_rotation,
+                        TIZEN_ROTATION_ACK_ANGLE_CHANGE, serial);
+}
+
+static inline void
+tizen_rotation_set_geometry_hint(struct tizen_rotation *tizen_rotation, uint32_t angle, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
+{
+       wl_proxy_marshal((struct wl_proxy *) tizen_rotation,
+                        TIZEN_ROTATION_SET_GEOMETRY_HINT, angle, x, y, w, h);
+}
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/lib/ecore_wl2/tizen-policy-ext-protocol.c b/src/lib/ecore_wl2/tizen-policy-ext-protocol.c
new file mode 100644 (file)
index 0000000..a8af24c
--- /dev/null
@@ -0,0 +1,54 @@
+#include <stdlib.h>
+#include <stdint.h>
+#include "wayland-util.h"
+
+extern const struct wl_interface tizen_rotation_interface;
+extern const struct wl_interface wl_surface_interface;
+
+static const struct wl_interface *types[] = {
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       &tizen_rotation_interface,
+       &wl_surface_interface,
+       &wl_surface_interface,
+};
+
+static const struct wl_message tizen_policy_ext_requests[] = {
+       { "get_rotation", "no", types + 5 },
+       { "get_active_angle", "?o", types + 7 },
+};
+
+static const struct wl_message tizen_policy_ext_events[] = {
+       { "active_angle", "u", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface tizen_policy_ext_interface = {
+       "tizen_policy_ext", 3,
+       2, tizen_policy_ext_requests,
+       1, tizen_policy_ext_events,
+};
+
+static const struct wl_message tizen_rotation_requests[] = {
+       { "destroy", "", types + 0 },
+       { "set_available_angles", "u", types + 0 },
+       { "set_preferred_angle", "u", types + 0 },
+       { "ack_angle_change", "u", types + 0 },
+       { "set_geometry_hint", "3uuuuu", types + 0 },
+};
+
+static const struct wl_message tizen_rotation_events[] = {
+       { "available_angles_done", "u", types + 0 },
+       { "preferred_angle_done", "u", types + 0 },
+       { "angle_change", "uu", types + 0 },
+       { "angle_change_with_resize", "2uuuu", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface tizen_rotation_interface = {
+       "tizen_rotation", 3,
+       5, tizen_rotation_requests,
+       4, tizen_rotation_events,
+};
+