ecore_wayland, ecore_evas_wayland: add support for tizen_rotation v2 23/108223/1
authorGwanglim Lee <gl77.lee@samsung.com>
Wed, 28 Dec 2016 11:55:48 +0000 (20:55 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Tue, 3 Jan 2017 11:08:09 +0000 (20:08 +0900)
angle_change_with_resize event which is newly added to tizen_rotation
v2 clarifies the semantics of changing size of window while rotation.
The clients that receive this event can know exactly how much their
window size should be changed while rotating.

Change-Id: I6dcd0c7222b008b129ef174264c755de1dd42d44

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-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 d570519ca0b60f8ba1430cb34deaf58b5ae4e8b8..ec2be58e985eddbe3b959b38cb0945b28a095a70 100644 (file)
@@ -1615,6 +1615,7 @@ EAPI void ecore_wl_window_rotation_preferred_rotation_set(Ecore_Wl_Window *win,
 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);
+EAPI void ecore_wl_window_rotation_changed_callback_set(Ecore_Wl_Window *win, void *data, void (*func)(Ecore_Wl_Window *win, int rot, Eina_Bool resize, int w, int h, void *data));
 
 EAPI Eina_List * ecore_wl_window_aux_hints_supported_get(Ecore_Wl_Window *win);
 EAPI void ecore_wl_window_aux_hint_add(Ecore_Wl_Window *win, int id, const char *hint, const char *val);
index 9934fe3aaba1a98f7a6138dfb3c3f55efe30654f..67669b922d8a26d78a18681b6e0f425a1de544e7 100644 (file)
@@ -1003,9 +1003,9 @@ _ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned in
    else if (!strcmp(interface, "tizen_policy_ext"))
      {
         ewd->wl.tz_policy_ext =
-          wl_registry_bind(registry, id, &tizen_policy_ext_interface, 1);
+          wl_registry_bind(registry, id, &tizen_policy_ext_interface, 2);
         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);
+          tizen_policy_ext_add_listener(_ecore_wl_disp->wl.tz_policy_ext, &_ecore_tizen_policy_ext_listener, ewd->wl.display);
      }
    else if (!strcmp(interface, "tizen_surface"))
      {
index dec960ab89c10da8ded539bcc9f5031bb2caf7fe..1cebd81d9e371ba051200fbb67bc7552fba14b69 100644 (file)
@@ -252,6 +252,9 @@ struct _Ecore_Wl_Window
    Ecore_Wl_Subsurf *subsurfs;
 
    void *data;
+
+   void (*cb_rot_changed)(int win_id, int rot, Eina_Bool resize, int w, int h, void *data);
+   void *cb_rot_changed_data;
 };
 
 struct _Ecore_Wl_Input_Device
index bb240953b59443dd67cedfcfb1a9d0efdc3522d0..65f45fa3ac8670b083b98edf5520ce8dfae057e4 100644 (file)
@@ -25,6 +25,7 @@ static void _ecore_wl_window_cb_position_change(void *data, struct tizen_positio
 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_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, uint32_t serial);
+static void _ecore_wl_window_cb_angle_change_with_resize(void *data, struct tizen_rotation *tizen_rotation EINA_UNUSED, uint32_t angle, uint32_t serial, uint32_t width, uint32_t height);
 static void _ecore_wl_window_cb_resource_id(void *data, struct tizen_resource *tizen_resource, uint32_t id);
 static void _ecore_wl_window_iconified_set(Ecore_Wl_Window *win, Eina_Bool iconified, Eina_Bool send_event);
 
@@ -65,6 +66,7 @@ static const struct tizen_rotation_listener _ecore_tizen_rotation_listener =
    _ecore_wl_window_cb_available_angles_done,
    _ecore_wl_window_cb_preferred_angle_done,
    _ecore_wl_window_cb_angle_change,
+   _ecore_wl_window_cb_angle_change_with_resize,
 };
 
 static const struct tizen_resource_listener _ecore_tizen_resource_listener =
@@ -1465,6 +1467,14 @@ ecore_wl_window_rotation_geometry_set(Ecore_Wl_Window *win, int rot, int x, int
      }
 }
 
+EAPI void
+ecore_wl_window_rotation_changed_callback_set(Ecore_Wl_Window *win, void *data, void (*func)(Ecore_Wl_Window *win, int rot, Eina_Bool resize, int w, int h, void *data))
+{
+   if (!win) return;
+   win->cb_rot_changed = func;
+   win->cb_rot_changed_data = data;
+}
+
 /* local functions */
 static void
 _ecore_wl_window_cb_ping(void *data EINA_UNUSED, struct wl_shell_surface *shell_surface, unsigned int serial)
@@ -1641,6 +1651,33 @@ _ecore_wl_window_cb_angle_change(void *data, struct tizen_rotation *tizen_rotati
    ecore_wl_window_rotation_set(win, ev->angle);
 }
 
+static void
+_ecore_wl_window_cb_angle_change_with_resize(void *data, struct tizen_rotation *tizen_rotation EINA_UNUSED, uint32_t angle, uint32_t serial, uint32_t width, uint32_t height)
+{
+   Ecore_Wl_Window *win = (Ecore_Wl_Window *)data;
+   int rot = 0;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   EINA_SAFETY_ON_NULL_RETURN(win);
+   EINA_SAFETY_ON_NULL_RETURN(win->cb_rot_changed);
+
+   win->tz_rot.serial = serial;
+
+   switch (angle)
+     {
+       case TIZEN_ROTATION_ANGLE_0:   rot =   0; break;
+       case TIZEN_ROTATION_ANGLE_90:  rot =  90; break;
+       case TIZEN_ROTATION_ANGLE_180: rot = 180; break;
+       case TIZEN_ROTATION_ANGLE_270: rot = 270; break;
+       default:                       rot =   0; break;
+     }
+
+   ecore_wl_window_rotation_set(win, rot);
+
+   win->cb_rot_changed(win, rot, 0, width, height, win->cb_rot_changed_data);
+}
+
 static void
 _ecore_wl_window_cb_resource_id(void *data, struct tizen_resource *tizen_resource EINA_UNUSED, uint32_t id)
 {
index e80a5df2beceaea56b2f6738d6ffbef57c68029f..0a042bb969f7c9e87948fa5ed4a532da20d47244 100644 (file)
@@ -14,6 +14,7 @@ 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;
@@ -39,6 +40,9 @@ tizen_policy_ext_add_listener(struct tizen_policy_ext *tizen_policy_ext,
 #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)
 {
@@ -51,6 +55,12 @@ 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)
 {
@@ -112,6 +122,23 @@ struct tizen_rotation_listener {
                             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
@@ -127,6 +154,11 @@ tizen_rotation_add_listener(struct tizen_rotation *tizen_rotation,
 #define TIZEN_ROTATION_SET_PREFERRED_ANGLE     2
 #define TIZEN_ROTATION_ACK_ANGLE_CHANGE        3
 
+#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)
 {
index cb915f0c5819f4aaa650b91728f9c93d3c742c9f..4c4506c85b2886fac48dd15acb4f170f497292e3 100644 (file)
@@ -6,6 +6,8 @@ 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,
        &tizen_rotation_interface,
@@ -14,8 +16,8 @@ static const struct wl_interface *types[] = {
 };
 
 static const struct wl_message tizen_policy_ext_requests[] = {
-       { "get_rotation", "no", types + 2 },
-       { "get_active_angle", "?o", types + 4 },
+       { "get_rotation", "no", types + 4 },
+       { "get_active_angle", "?o", types + 6 },
 };
 
 static const struct wl_message tizen_policy_ext_events[] = {
@@ -23,7 +25,7 @@ static const struct wl_message tizen_policy_ext_events[] = {
 };
 
 WL_EXPORT const struct wl_interface tizen_policy_ext_interface = {
-       "tizen_policy_ext", 1,
+       "tizen_policy_ext", 2,
        2, tizen_policy_ext_requests,
        1, tizen_policy_ext_events,
 };
@@ -39,11 +41,12 @@ 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", 1,
+       "tizen_rotation", 2,
        4, tizen_rotation_requests,
-       3, tizen_rotation_events,
+       4, tizen_rotation_events,
 };
 
index 1db1661d32ca1b8475881d33313929be5907e091..212cf16cff772f3288e9b7ed81407302cc255a5f 100755 (executable)
@@ -1300,6 +1300,109 @@ _ecore_evas_wl_common_wm_rot_manual_rotation_done(Ecore_Evas *ee)
      }
 }
 
+void
+_ecore_evas_wl_common_wm_rot_cb_angle_changed(Ecore_Wl_Window *win, int rot, Eina_Bool resize, int w, int h, void *data)
+{
+   Ecore_Evas *ee;
+   Ecore_Evas_Engine_Wl_Data *wdata;
+   int minw, minh, maxw, maxh;
+   int basew, baseh, stepw, steph;
+
+   ee = (Ecore_Evas *)data;
+   EINA_SAFETY_ON_NULL_RETURN(ee);
+
+   wdata = ee->engine.data;
+   EINA_SAFETY_ON_NULL_RETURN(wdata);
+
+   EINA_SAFETY_ON_FALSE_RETURN(win == wdata->win);
+
+   if ((!ee->prop.wm_rot.supported) || (!ee->prop.wm_rot.app_set))
+     return;
+
+   /* get min, max, base, & step sizes */
+   ecore_evas_size_min_get(ee, &minw, &minh);
+   ecore_evas_size_max_get(ee, &maxw, &maxh);
+   ecore_evas_size_base_get(ee, &basew, &baseh);
+   ecore_evas_size_step_get(ee, &stepw, &steph);
+
+   wdata->wm_rot.request = 1;
+   wdata->wm_rot.done = 0;
+
+   ee->rotation = rot;
+
+   _ecore_evas_wl_common_resize(ee, w, 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 (ee->in_async_render)
+     {
+        ee->delayed.rotation = rot;
+        ee->delayed.rotation_resize = resize;
+        ee->delayed.rotation_changed = EINA_TRUE;
+        return;
+     }
+
+   if (ECORE_EVAS_PORTRAIT(ee))
+     evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h);
+   else
+     evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.h, ee->req.w);
+
+   /* reset min, max, base, & step sizes */
+   ecore_evas_size_min_set(ee, minh, minw);
+   ecore_evas_size_max_set(ee, maxh, maxw);
+   ecore_evas_size_base_set(ee, baseh, basew);
+   ecore_evas_size_step_set(ee, steph, stepw);
+
+   /* send a mouse_move process
+    *
+    * NB: Is This Really Needed ?
+    * Yes, it's required to update the mouse position, relatively to
+    * widgets. After a rotation change, e.g., the mouse might not be over
+    * a button anymore. */
+   _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y,
+                                  ecore_loop_time_get());
+
+   if (!strcmp(ee->driver, "wayland_shm"))
+     {
+#ifdef BUILD_ECORE_EVAS_WAYLAND_SHM
+        Evas_Engine_Info_Wayland_Shm *einfo;
+        einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas);
+        if (!einfo) return;
+
+        einfo->info.rotation = rot;
+
+        if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
+          ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
+#endif
+     }
+   else if (!strcmp(ee->driver, "wayland_egl"))
+     {
+#ifdef BUILD_ECORE_EVAS_WAYLAND_EGL
+        Evas_Engine_Info_Wayland_Egl *einfo;
+        einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas);
+        if (!einfo) return;
+
+        einfo->info.rotation = rot;
+
+        /* TIZEN_ONLY(20160728):
+           wayland spec is not define whether wl_egl_window_create() can use null surface or not.
+           so current tizen device does not allow to create null surface wayland window.
+         */
+        if ((einfo->info.surface) &&
+            (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)))
+          ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
+#endif
+     }
+
+   _ecore_evas_wl_common_state_update(ee);
+
+   wdata->wm_rot.done = 1;
+}
+
 void
 _ecore_evas_wl_common_raise(Ecore_Evas *ee)
 {
index 71024ec4954528931071e8c5356eb365b25dca80..e9241017a6460e7ee126bcb0ab54f56a2e857a90 100644 (file)
@@ -225,6 +225,10 @@ ecore_evas_wayland_egl_options_new_internal(const char *disp_name, unsigned int
                          ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW);
    ee->prop.window = ecore_wl_window_id_get(wdata->win);
 
+   if (wdata->win)
+     ecore_wl_window_rotation_changed_callback_set
+       (wdata->win, ee, _ecore_evas_wl_common_wm_rot_cb_angle_changed);
+
    EINA_INLIST_FOREACH(globals, global)
      {
         if (!strcmp(global->interface, "tizen_policy_ext"))
index 13107c3df2aafbbff389152ba5d678104074b251..9f3fcaf6b7340cd8a1695b060e31fea9c40106a7 100755 (executable)
@@ -108,6 +108,7 @@ void _ecore_evas_wl_common_wm_rot_preferred_rotation_set(Ecore_Evas *ee, int rot
 void _ecore_evas_wl_common_wm_rot_available_rotations_set(Ecore_Evas *ee, const int *rots, unsigned int count);
 void _ecore_evas_wl_common_wm_rot_manual_rotation_done_set(Ecore_Evas *ee, Eina_Bool set);
 void _ecore_evas_wl_common_wm_rot_manual_rotation_done(Ecore_Evas *ee);
+void _ecore_evas_wl_common_wm_rot_cb_angle_changed(Ecore_Wl_Window *win, int rot, Eina_Bool resize, int w, int h, void *data);
 
 int _ecore_evas_common_init_count_get(void);
 
index 59ec9845da9c92d20d4f5b1ad561e81e5b07d381..c30d79d8d6aa85792732a805d3775264240bdfe3 100644 (file)
@@ -226,6 +226,10 @@ ecore_evas_wayland_shm_new_internal(const char *disp_name, unsigned int parent,
                          ECORE_WL_WINDOW_BUFFER_TYPE_SHM);
    ee->prop.window = ecore_wl_window_id_get(wdata->win);
 
+   if (wdata->win)
+     ecore_wl_window_rotation_changed_callback_set
+       (wdata->win, ee, _ecore_evas_wl_common_wm_rot_cb_angle_changed);
+
    EINA_INLIST_FOREACH(globals, global)
      {
         if (!strcmp(global->interface, "tizen_policy_ext"))