ecore_wl2_window: support tizen rotation protocol v2
authorDoyoun Kang <doyoun.kang@samsung.com>
Mon, 13 Nov 2017 06:55:06 +0000 (15:55 +0900)
committerJiyoun Park <jy0703.park@samsung.com>
Tue, 19 Dec 2017 07:30:03 +0000 (16:30 +0900)
@tizen_feature

Change-Id: I4a669d76a3f1b5daa51f6d7e725095c044442021

src/lib/ecore_wl2/Ecore_Wl2.h
src/lib/ecore_wl2/ecore_wl2_private.h
src/lib/ecore_wl2/ecore_wl2_window.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c

index fa0a7e2..9248e7d 100644 (file)
@@ -1413,6 +1413,7 @@ EAPI void ecore_wl2_window_rotation_change_done_send(Ecore_Wl2_Window *window, i
 
 // TIZEN_ONLY
 EAPI void ecore_wl2_window_rotation_geometry_set(Ecore_Wl2_Window *win, int rot, int x, int y, int w, int h);
+EAPI void ecore_wl2_window_rotation_changed_callback_set(Ecore_Wl2_Window *win, void *data, void (*func)(Ecore_Wl2_Window *win, int rot, Eina_Bool resize, int w, int h, void *data));
 //
 
 /**
index 6cff34a..cc7cfed 100644 (file)
@@ -334,6 +334,11 @@ struct _Ecore_Wl2_Window
         Ecore_Wl2_Virtual_Keyboard_State state;
      } keyboard;
    //
+
+   // TIZEN_ONLY(20161228) : tizen_rotation v2
+   void (*cb_rot_changed)(Ecore_Wl2_Window *win, int rot, Eina_Bool resize, int w, int h, void *data);
+   void *cb_rot_changed_data;
+   //
 };
 
 struct _Ecore_Wl2_Output
index ce24d98..d6a703d 100644 (file)
@@ -515,11 +515,37 @@ _ecore_wl_window_cb_angle_change(void *data, struct tizen_rotation *tizen_rotati
    ecore_wl2_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_Wl2_Window *win = (Ecore_Wl2_Window *)data;
+   int rot = 0;
+
+   EINA_SAFETY_ON_NULL_RETURN(win);
+   EINA_SAFETY_ON_NULL_RETURN(win->cb_rot_changed);
+
+   win->wm_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_wl2_window_rotation_set(win, rot);
+
+   win->cb_rot_changed(win, rot, 0, width, height, win->cb_rot_changed_data);
+}
+
 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 void
@@ -1988,6 +2014,15 @@ ecore_wl2_window_rotation_geometry_set(Ecore_Wl2_Window *win, int rot, int x, in
                                          win->maximized);
      }
 }
+
+EAPI void
+ecore_wl2_window_rotation_changed_callback_set(Ecore_Wl2_Window *win, void *data, void (*func)(Ecore_Wl2_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;
+}
 //
 
 EAPI Eina_List *
index 767e049..084b25a 100644 (file)
@@ -1727,6 +1727,109 @@ _ecore_evas_wl_common_activate(Ecore_Evas *ee)
 }
 //
 
+// TIZEN_ONLY(20161228) : tizen_rotation v2
+void
+_ecore_evas_wl_common_wm_rot_cb_angle_changed(Ecore_Wl2_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;
+
+   /* reset min, max, base, & step sizes */
+   ecore_evas_size_min_set(ee, minw, minh);
+   ecore_evas_size_max_set(ee, maxw, maxh);
+   ecore_evas_size_base_set(ee, basew, baseh);
+   ecore_evas_size_step_set(ee, stepw, steph);
+
+   _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);
+
+   /* 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. */
+   _mouse_move_dispatch(ee);
+
+   if (!strcmp(ee->driver, "wayland_shm"))
+     {
+#ifdef BUILD_ECORE_EVAS_WAYLAND_SHM
+        Evas_Engine_Info_Wayland *einfo;
+        einfo = (Evas_Engine_Info_Wayland *)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 *einfo;
+        einfo = (Evas_Engine_Info_Wayland *)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 (!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;
+}
+//
+
 static void
 _ecore_evas_wl_common_title_set(Ecore_Evas *ee, const char *title)
 {
@@ -2839,6 +2942,12 @@ _ecore_evas_wl_common_new_internal(const char *disp_name, unsigned int parent, i
 
    _ecore_evas_wl_common_wm_rotation_protocol_set(ee);
 
+// TIZEN_ONLY(20161228) : tizen_rotation v2
+   if (wdata->win)
+     ecore_wl2_window_rotation_changed_callback_set
+       (wdata->win, ee, _ecore_evas_wl_common_wm_rot_cb_angle_changed);
+//
+
    _ecore_evas_register(ee);
    ecore_evas_input_event_register(ee);