ecore_wayland: Add rotation geometry hint 19/45219/5
authorMun, Gwan-gyeong <kk.moon@samsung.com>
Fri, 24 Jul 2015 05:26:04 +0000 (14:26 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Tue, 8 Sep 2015 10:49:58 +0000 (03:49 -0700)
               implement manual_rotation_done

Change-Id: I3db849f8601e77727d3fa96d50de131ae0a7baf8

src/lib/ecore_wayland/Ecore_Wayland.h
src/lib/ecore_wayland/ecore_wl_private.h
src/lib/ecore_wayland/ecore_wl_window.c
src/lib/ecore_wayland/tizen-policy-ext-client-protocol.h
src/lib/ecore_wayland/tizen-policy-ext-protocol.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_shm.c

index ebe2f89..5329adc 100644 (file)
@@ -232,6 +232,7 @@ struct _Ecore_Wl_Event_Window_Rotate
 {
    unsigned int win;
    unsigned int angle;
+   int w, h;
 };
 
 struct _Ecore_Wl_Event_Window_Show
@@ -1029,6 +1030,8 @@ EAPI Ecore_Wl_Virtual_Keyboard_State ecore_wl_window_keyboard_state_get(Ecore_Wl
 
 EAPI void ecore_wl_window_rotation_preferred_rotation_set(Ecore_Wl_Window *win, int rot);
 EAPI void ecore_wl_window_rotation_available_rotations_set(Ecore_Wl_Window *win, const int *rots, unsigned int count);
+EAPI void ecore_wl_window_rotation_change_done_send(Ecore_Wl_Window *win);
+EAPI void ecore_wl_window_rotation_geometry_set(Ecore_Wl_Window *win, int rot, int x, int y, int w, int h);
 
 #ifdef __cplusplus
 }
index 7b70705..e803877 100644 (file)
@@ -129,6 +129,7 @@ struct _Ecore_Wl_Window
    struct tizen_rotation *tz_rotation;
    struct tizen_resource *tz_resource;
    unsigned int resource_id;
+   unsigned int tz_rotation_serial;
 
    struct wl_region *opaque_region;
    struct wl_region *input_region;
index 84ac917..16e6fb5 100644 (file)
@@ -6,6 +6,14 @@
 #include <xdg-shell-client-protocol.h>
 #include <tizen-extension-client-protocol.h>
 
+typedef struct _Rotation_Geometry Rotation_Geometry;
+
+struct _Rotation_Geometry
+{
+   enum tizen_rotation_angle angle;
+   int x, y, w, h;
+};
+
 /* local function prototypes */
 static void _ecore_wl_window_cb_ping(void *data EINA_UNUSED, struct wl_shell_surface *shell_surface, unsigned int serial);
 static void _ecore_wl_window_cb_configure(void *data, struct wl_shell_surface *shell_surface EINA_UNUSED, unsigned int edges, int w, int h);
@@ -22,8 +30,8 @@ static void _ecore_xdg_handle_popup_done(void *data, struct xdg_popup *xdg_popup
 static void _ecore_wl_window_cb_visibility_change(void *data, struct tizen_visibility *tizen_visibility, uint32_t visibility);
 static void _ecore_wl_window_cb_position_change(void *data, struct tizen_position *tizen_position, int32_t x, int32_t y);
 static void _ecore_wl_window_cb_available_angles_done(void *data, struct tizen_rotation *tizen_rotation, uint32_t angles);
-static void _ecore_wl_window_cb_preferred_angles_done(void *data, struct tizen_rotation *tizen_rotation, uint32_t angles);
-static void _ecore_wl_window_cb_angle_change(void *data, struct tizen_rotation *tizen_rotation, uint32_t angle, uint32_t serial);
+static void _ecore_wl_window_cb_preferred_angle_done(void *data, struct tizen_rotation *tizen_rotation, uint32_t angle);
+static void _ecore_wl_window_cb_angle_change(void *data, struct tizen_rotation *tizen_rotation, uint32_t angle, int32_t width, int32_t height, uint32_t serial);
 static void _ecore_wl_window_cb_resource_id(void *data, struct tizen_resource *tizen_resource, uint32_t id);
 
 /* local variables */
@@ -66,7 +74,7 @@ static const struct tizen_position_listener _ecore_tizen_position_listener =
 static const struct tizen_rotation_listener _ecore_tizen_rotation_listener =
 {
    _ecore_wl_window_cb_available_angles_done,
-   _ecore_wl_window_cb_preferred_angles_done,
+   _ecore_wl_window_cb_preferred_angle_done,
    _ecore_wl_window_cb_angle_change,
 };
 
@@ -1213,7 +1221,7 @@ ecore_wl_window_keyboard_get(Ecore_Wl_Window *win)
 EAPI void
 ecore_wl_window_rotation_preferred_rotation_set(Ecore_Wl_Window *win, int rot)
 {
-   enum tizen_rotation_angle angle;
+   enum tizen_rotation_angle angle = TIZEN_ROTATION_ANGLE_NONE;
 
    if (!win) return;
    if (!win->tz_rotation) return;
@@ -1233,11 +1241,10 @@ ecore_wl_window_rotation_preferred_rotation_set(Ecore_Wl_Window *win, int rot)
           angle = TIZEN_ROTATION_ANGLE_270;
           break;
         default:
-          angle = TIZEN_ROTATION_ANGLE_0;
           break;
      }
 
-    tizen_rotation_set_preferred_angles(win->tz_rotation, (uint32_t)angle);
+    tizen_rotation_set_preferred_angle(win->tz_rotation, (uint32_t)angle);
 }
 
 EAPI void
@@ -1274,6 +1281,64 @@ ecore_wl_window_rotation_available_rotations_set(Ecore_Wl_Window *win, const int
    tizen_rotation_set_available_angles(win->tz_rotation, angles);
 }
 
+EAPI void
+ecore_wl_window_rotation_change_done_send(Ecore_Wl_Window *win)
+{
+   if (!win) return;
+   if (!win->tz_rotation) return;
+
+   tizen_rotation_ack_angle_change(win->tz_rotation, win->tz_rotation_serial);
+}
+
+
+EAPI void
+ecore_wl_window_rotation_geometry_set(Ecore_Wl_Window *win, int rot, int x, int y, int w, int h)
+{
+   struct wl_array geometry;
+   Rotation_Geometry *rot_geo;
+
+   if (!win) return;
+   if (!win->tz_rotation) return;
+
+   if ((rot % 90 != 0) || (rot / 90 > 3) || (rot < 0)) return;
+
+   wl_array_init(&geometry);
+   rot_geo = (Rotation_Geometry *)wl_array_add(&geometry, sizeof(Rotation_Geometry));
+
+   if (!rot_geo)
+     {
+        wl_array_release(&geometry);
+        return;
+     }
+
+   switch (rot)
+     {
+        case 0:
+           rot_geo->angle = TIZEN_ROTATION_ANGLE_0;
+           break;
+        case 90:
+           rot_geo->angle = TIZEN_ROTATION_ANGLE_90;
+           break;
+        case 180:
+           rot_geo->angle = TIZEN_ROTATION_ANGLE_180;
+           break;
+        case 270:
+           rot_geo->angle = TIZEN_ROTATION_ANGLE_270;
+           break;
+        default:
+           break;
+     }
+
+   rot_geo->x = x;
+   rot_geo->y = y;
+   rot_geo->w = w;
+   rot_geo->h = h;
+
+   tizen_rotation_set_geometry_hints(win->tz_rotation, &geometry);
+
+   wl_array_release(&geometry);
+}
+
 /* local functions */
 static void 
 _ecore_wl_window_cb_ping(void *data EINA_UNUSED, struct wl_shell_surface *shell_surface, unsigned int serial)
@@ -1454,9 +1519,9 @@ _ecore_wl_window_cb_available_angles_done(void *data,
 }
 
 static void
-_ecore_wl_window_cb_preferred_angles_done(void *data,
-                                          struct tizen_rotation *tizen_rotation,
-                                          uint32_t angles)
+_ecore_wl_window_cb_preferred_angle_done(void *data,
+                                         struct tizen_rotation *tizen_rotation,
+                                         uint32_t angle)
 {
    return;
 }
@@ -1465,6 +1530,8 @@ static void
 _ecore_wl_window_cb_angle_change(void *data,
                                  struct tizen_rotation *tizen_rotation,
                                  uint32_t angle,
+                                 int32_t width,
+                                 int32_t height,
                                  uint32_t serial)
 {
    Ecore_Wl_Window *win;
@@ -1475,7 +1542,11 @@ _ecore_wl_window_cb_angle_change(void *data,
    if (!(win = data)) return;
    if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Window_Rotate)))) return;
 
+   win->tz_rotation_serial = serial;
+
    ev->win = win->id;
+   ev->w = width;
+   ev->h = height;
 
    switch (angle)
      {
index 8ae45f7..3cca623 100644 (file)
@@ -52,6 +52,7 @@ tizen_policy_ext_get_rotation(struct tizen_policy_ext *tizen_policy_ext, struct
 #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,
@@ -68,15 +69,17 @@ struct tizen_rotation_listener {
                                      struct tizen_rotation *tizen_rotation,
                                      uint32_t angles);
        /**
-        * preferred_angles_done - (none)
-        * @angles: (none)
+        * preferred_angle_done - (none)
+        * @angle: (none)
         */
-       void (*preferred_angles_done)(void *data,
-                                     struct tizen_rotation *tizen_rotation,
-                                     uint32_t angles);
+       void (*preferred_angle_done)(void *data,
+                                    struct tizen_rotation *tizen_rotation,
+                                    uint32_t angle);
        /**
         * angle_change - suggest a angle_change
         * @angle: (none)
+        * @width: (none)
+        * @height: (none)
         * @serial: (none)
         *
         * 
@@ -84,6 +87,8 @@ struct tizen_rotation_listener {
        void (*angle_change)(void *data,
                             struct tizen_rotation *tizen_rotation,
                             uint32_t angle,
+                            int32_t width,
+                            int32_t height,
                             uint32_t serial);
 };
 
@@ -96,8 +101,9 @@ tizen_rotation_add_listener(struct tizen_rotation *tizen_rotation,
 }
 
 #define TIZEN_ROTATION_SET_AVAILABLE_ANGLES    0
-#define TIZEN_ROTATION_SET_PREFERRED_ANGLES    1
+#define TIZEN_ROTATION_SET_PREFERRED_ANGLE     1
 #define TIZEN_ROTATION_ACK_ANGLE_CHANGE        2
+#define TIZEN_ROTATION_SET_GEOMETRY_HINTS      3
 
 static inline void
 tizen_rotation_set_user_data(struct tizen_rotation *tizen_rotation, void *user_data)
@@ -125,10 +131,10 @@ tizen_rotation_set_available_angles(struct tizen_rotation *tizen_rotation, uint3
 }
 
 static inline void
-tizen_rotation_set_preferred_angles(struct tizen_rotation *tizen_rotation, uint32_t angles)
+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_ANGLES, angles);
+                        TIZEN_ROTATION_SET_PREFERRED_ANGLE, angle);
 }
 
 static inline void
@@ -138,6 +144,13 @@ tizen_rotation_ack_angle_change(struct tizen_rotation *tizen_rotation, uint32_t
                         TIZEN_ROTATION_ACK_ANGLE_CHANGE, serial);
 }
 
+static inline void
+tizen_rotation_set_geometry_hints(struct tizen_rotation *tizen_rotation, struct wl_array *geometry_hints)
+{
+       wl_proxy_marshal((struct wl_proxy *) tizen_rotation,
+                        TIZEN_ROTATION_SET_GEOMETRY_HINTS, geometry_hints);
+}
+
 #ifdef  __cplusplus
 }
 #endif
index 008ac93..6b54618 100644 (file)
@@ -8,12 +8,14 @@ extern const struct wl_interface wl_surface_interface;
 static const struct wl_interface *types[] = {
        NULL,
        NULL,
+       NULL,
+       NULL,
        &tizen_rotation_interface,
        &wl_surface_interface,
 };
 
 static const struct wl_message tizen_policy_ext_requests[] = {
-       { "get_rotation", "no", types + 2 },
+       { "get_rotation", "no", types + 4 },
 };
 
 WL_EXPORT const struct wl_interface tizen_policy_ext_interface = {
@@ -24,19 +26,20 @@ WL_EXPORT const struct wl_interface tizen_policy_ext_interface = {
 
 static const struct wl_message tizen_rotation_requests[] = {
        { "set_available_angles", "u", types + 0 },
-       { "set_preferred_angles", "u", types + 0 },
+       { "set_preferred_angle", "u", types + 0 },
        { "ack_angle_change", "u", types + 0 },
+       { "set_geometry_hints", "a", types + 0 },
 };
 
 static const struct wl_message tizen_rotation_events[] = {
        { "available_angles_done", "u", types + 0 },
-       { "preferred_angles_done", "u", types + 0 },
-       { "angle_change", "uu", types + 0 },
+       { "preferred_angle_done", "u", types + 0 },
+       { "angle_change", "uiiu", types + 0 },
 };
 
 WL_EXPORT const struct wl_interface tizen_rotation_interface = {
        "tizen_rotation", 1,
-       3, tizen_rotation_requests,
+       4, tizen_rotation_requests,
        3, tizen_rotation_events,
 };
 
index 0bfaa0f..327d237 100644 (file)
@@ -45,6 +45,8 @@ static void _rotation_do(Ecore_Evas *ee, int rotation, int resize);
 static void _ecore_evas_wayland_alpha_do(Ecore_Evas *ee, int alpha);
 static void _ecore_evas_wayland_transparent_do(Ecore_Evas *ee, int transparent);
 static void _ecore_evas_wl_common_border_update(Ecore_Evas *ee);
+static Eina_Bool _ecore_evas_wl_common_wm_rot_manual_rotation_done_timeout(void *data);
+static void      _ecore_evas_wl_common_wm_rot_manual_rotation_done_timeout_update(Ecore_Evas *ee);
 
 /* Frame listener */
 static void _ecore_evas_wl_frame_complete(void *data, struct wl_callback *callback, uint32_t tm);
@@ -381,7 +383,7 @@ _ecore_evas_wl_common_cb_window_rotate(void *data EINA_UNUSED, int type EINA_UNU
 {
    Ecore_Evas *ee;
    Ecore_Wl_Event_Window_Rotate *ev;
-   int resize;
+   Ecore_Evas_Engine_Wl_Data *wdata;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
@@ -390,22 +392,49 @@ _ecore_evas_wl_common_cb_window_rotate(void *data EINA_UNUSED, int type EINA_UNU
    if (!ee) return ECORE_CALLBACK_PASS_ON;
    if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
 
-   //FIXME: resize
-   resize = 0;
+   wdata = ee->engine.data;
+   if (!wdata) return ECORE_CALLBACK_PASS_ON;
+
+   if ((!ee->prop.wm_rot.supported) || (!ee->prop.wm_rot.app_set))
+     return ECORE_CALLBACK_PASS_ON;
+
+   wdata->wm_rot.request = 1;
+   wdata->wm_rot.done = 0;
+
+   if ((ee->w != ev->w) || (ee->h != ev->h))
+     {
+        _ecore_evas_wl_common_resize(ee, ev->w , ev->h);
+     }
+
+   if (ee->prop.wm_rot.manual_mode.set)
+     {
+        ee->prop.wm_rot.manual_mode.wait_for_done = EINA_TRUE;
+        _ecore_evas_wl_common_wm_rot_manual_rotation_done_timeout_update(ee);
+     }
 
    if (!strcmp(ee->driver, "wayland_shm"))
      {
 #ifdef BUILD_ECORE_EVAS_WAYLAND_SHM
-        _ecore_evas_wayland_shm_window_rotate(ee, ev->angle, resize);
+        _ecore_evas_wayland_shm_window_rotate(ee, ev->angle, 1);
 #endif
      }
    else if (!strcmp(ee->driver, "wayland_egl"))
      {
 #ifdef BUILD_ECORE_EVAS_WAYLAND_EGL
-        _ecore_evas_wayland_egl_window_rotate(ee, ev->angle, resize);
+        _ecore_evas_wayland_egl_window_rotate(ee, ev->angle, 1);
 #endif
      }
 
+   wdata->wm_rot.done = 1;
+
+   /* Fixme: rotation done send move to render flush */
+   if (!ee->prop.wm_rot.manual_mode.set)
+     {
+        wdata->wm_rot.request = 0;
+        wdata->wm_rot.done = 0;
+        ecore_wl_window_rotation_change_done_send(wdata->win);
+     }
+
    return ECORE_CALLBACK_PASS_ON;
 }
 
@@ -1195,6 +1224,40 @@ _ecore_evas_wl_common_wm_rot_available_rotations_set(Ecore_Evas *ee, const int *
      }
 }
 
+static void
+_ecore_evas_wl_common_wm_rot_manual_rotation_done_job(void *data)
+{
+   Ecore_Evas *ee = (Ecore_Evas *)data;
+   Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
+
+   wdata->wm_rot.manual_mode_job = NULL;
+   ee->prop.wm_rot.manual_mode.wait_for_done = EINA_FALSE;
+
+   ecore_wl_window_rotation_change_done_send(wdata->win);
+
+   wdata->wm_rot.done = 0;
+}
+
+static Eina_Bool
+_ecore_evas_wl_common_wm_rot_manual_rotation_done_timeout(void *data)
+{
+   Ecore_Evas *ee = data;
+
+   ee->prop.wm_rot.manual_mode.timer = NULL;
+   _ecore_evas_wl_common_wm_rot_manual_rotation_done(ee);
+   return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+_ecore_evas_wl_common_wm_rot_manual_rotation_done_timeout_update(Ecore_Evas *ee)
+{
+   if (ee->prop.wm_rot.manual_mode.timer)
+     ecore_timer_del(ee->prop.wm_rot.manual_mode.timer);
+
+   ee->prop.wm_rot.manual_mode.timer = ecore_timer_add
+     (4.0f, _ecore_evas_wl_common_wm_rot_manual_rotation_done_timeout, ee);
+}
+
 void
 _ecore_evas_wl_common_wm_rot_manual_rotation_done_set(Ecore_Evas *ee, Eina_Bool set)
 {
@@ -1215,7 +1278,11 @@ _ecore_evas_wl_common_wm_rot_manual_rotation_done(Ecore_Evas *ee)
              if (ee->prop.wm_rot.manual_mode.timer)
                ecore_timer_del(ee->prop.wm_rot.manual_mode.timer);
              ee->prop.wm_rot.manual_mode.timer = NULL;
-             //Fixme: Add wayland rotation done timer
+
+             if (wdata->wm_rot.manual_mode_job)
+               ecore_job_del(wdata->wm_rot.manual_mode_job);
+             wdata->wm_rot.manual_mode_job = ecore_job_add
+               (_ecore_evas_wl_common_wm_rot_manual_rotation_done_job, ee);
           }
      }
 }
index f0e0f40..4edf74e 100644 (file)
@@ -208,6 +208,7 @@ ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
         if (!strcmp(global->interface, "tizen_policy_ext"))
           {
              ee->prop.wm_rot.supported = 1;
+             wdata->wm_rot.supported = 1;
              break;
           }
      }
index 357aa3c..2f8585d 100644 (file)
@@ -44,6 +44,13 @@ struct _Ecore_Evas_Engine_Wl_Data
 #endif
    Eina_Bool frame_pending : 1;
    struct wl_callback *frame_callback;
+   struct
+     {
+        unsigned char supported: 1;
+        unsigned char request : 1;
+        unsigned char done : 1;
+        Ecore_Job    *manual_mode_job;
+     } wm_rot;
 };
 
 Ecore_Evas_Interface_Wayland *_ecore_evas_wl_interface_new(void);
index cd9da2c..b04c7e1 100644 (file)
@@ -203,6 +203,7 @@ ecore_evas_wayland_shm_new_internal(const char *disp_name, unsigned int parent,
         if (!strcmp(global->interface, "tizen_policy_ext"))
          {
             ee->prop.wm_rot.supported = 1;
+            wdata->wm_rot.supported = 1;
             break;
          }
      }