ecore_wayland: added protocol and funtion for getting active angle 39/75639/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Tue, 21 Jun 2016 00:53:18 +0000 (09:53 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Tue, 21 Jun 2016 00:53:18 +0000 (09:53 +0900)
Change-Id: I465ccb630d39561db03870e7251eb36207c098a2

src/lib/ecore_wayland/Ecore_Wayland.h
src/lib/ecore_wayland/ecore_wl.c
src/lib/ecore_wayland/tizen-policy-ext-client-protocol.h
src/lib/ecore_wayland/tizen-policy-ext-protocol.c

index b64b3ad..11b3c8f 100644 (file)
@@ -795,6 +795,7 @@ EAPI void ecore_wl_window_parent_set(Ecore_Wl_Window *win, Ecore_Wl_Window *pare
 EAPI void ecore_wl_window_position_set(Ecore_Wl_Window *win, int x, int y);
 EAPI void ecore_wl_window_focus_skip_set(Ecore_Wl_Window *win, Eina_Bool focus_skip);
 EAPI void ecore_wl_window_role_set(Ecore_Wl_Window *win, const char *role);
+EAPI int ecore_wl_window_active_angle_get(Ecore_Wl_Window *win);
 
 /**
  * Iconify a window
index 91c4a2e..57ae6dc 100644 (file)
@@ -55,6 +55,7 @@ static void _ecore_wl_cb_iconify_state_changed(void *data EINA_UNUSED, struct ti
 static void _ecore_wl_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 _ecore_wl_cb_allowed_aux_hint(void *data  EINA_UNUSED, struct tizen_policy *tizen_policy  EINA_UNUSED, struct wl_surface *surface_resource, int id);
 static void _ecore_wl_window_conformant_area_send(Ecore_Wl_Window *win, uint32_t conformant_part, uint32_t state);
+static void _ecore_wl_cb_active_angle(void *data EINA_UNUSED, struct tizen_policy_ext *tizen_policy_ext EINA_UNUSED, uint32_t angle);
 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_log_cb_print(const char *format, va_list args);
@@ -66,6 +67,7 @@ static Eina_Bool _ecore_wl_server_mode = EINA_FALSE;
 // TIZEN_ONLY(20150722): Add ecore_wl_window_keygrab_* APIs
 static Eina_Hash *_keygrabs = NULL;
 static int _ecore_wl_keygrab_error = -1;
+static int _ecore_wl_active_angle = -1;
 //
 
 static const struct wl_registry_listener _ecore_wl_registry_listener =
@@ -108,6 +110,11 @@ static const struct tizen_policy_listener _ecore_tizen_policy_listener =
    _ecore_wl_cb_allowed_aux_hint,
 };
 
+static const struct tizen_policy_ext_listener _ecore_tizen_policy_ext_listener =
+{
+   _ecore_wl_cb_active_angle,
+};
+
 static const struct tizen_effect_listener _ecore_tizen_effect_listener =
 {
    _ecore_wl_cb_effect_start,
@@ -950,6 +957,8 @@ _ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned in
      {
         ewd->wl.tz_policy_ext =
           wl_registry_bind(registry, id, &tizen_policy_ext_interface, 1);
+        if (ewd->wl.tz_policy_ext)
+          tizen_policy_add_listener(_ecore_wl_disp->wl.tz_policy_ext, &_ecore_tizen_policy_ext_listener, ewd->wl.display);
      }
    else if (!strcmp(interface, "tizen_surface"))
      {
@@ -1450,6 +1459,23 @@ ecore_wl_window_keygrab_unset(Ecore_Wl_Window *win, const char *key, int mod EIN
    _ecore_wl_keygrab_error = -1;
    return ret;
 }
+
+EAPI int
+ecore_wl_window_active_angle_get(Ecore_Wl_Window *win)
+{
+   struct wl_surface *surface = NULL;
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   if (!_ecore_wl_disp->wl.tz_policy_ext) return 0;
+
+   if (win)
+     surface = ecore_wl_window_surface_get(win);
+
+   tizen_policy_ext_get_active_angle(_ecore_wl_disp->wl.tz_policy_ext, surface);
+   ecore_wl_sync();
+
+   return _ecore_wl_active_angle;
+}
 //
 
 static void
@@ -1657,6 +1683,13 @@ _ecore_wl_cb_allowed_aux_hint(void *data  EINA_UNUSED, struct tizen_policy *tize
 }
 
 static void
+_ecore_wl_cb_active_angle(void *data EINA_UNUSED, struct tizen_policy_ext *tizen_policy_ext EINA_UNUSED, uint32_t angle)
+{
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   _ecore_wl_active_angle = angle;
+}
+
+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)
 {
    struct wl_surface *surface = surface_resource;
index 45964a4..e80a5df 100644 (file)
@@ -18,7 +18,26 @@ struct tizen_rotation;
 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
 
 static inline void
 tizen_policy_ext_set_user_data(struct tizen_policy_ext *tizen_policy_ext, void *user_data)
@@ -49,6 +68,13 @@ tizen_policy_ext_get_rotation(struct tizen_policy_ext *tizen_policy_ext, struct
        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 {
@@ -113,6 +139,12 @@ 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)
 {
index d5ab495..cb915f0 100644 (file)
@@ -10,16 +10,22 @@ static const struct wl_interface *types[] = {
        NULL,
        &tizen_rotation_interface,
        &wl_surface_interface,
+       &wl_surface_interface,
 };
 
 static const struct wl_message tizen_policy_ext_requests[] = {
        { "get_rotation", "no", types + 2 },
+       { "get_active_angle", "?o", types + 4 },
+};
+
+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", 1,
-       1, tizen_policy_ext_requests,
-       0, NULL,
+       2, tizen_policy_ext_requests,
+       1, tizen_policy_ext_events,
 };
 
 static const struct wl_message tizen_rotation_requests[] = {