[ecore_evas][ecore_x] added the window manager rotation feature
authorGwanglim Lee <gl77.lee@samsung.com>
Tue, 19 Mar 2013 17:54:43 +0000 (02:54 +0900)
committerSungho Kwak <sungho1.kwak@samsung.com>
Thu, 21 Mar 2013 08:19:24 +0000 (17:19 +0900)
Change-Id: I73e927118bab72b9f0f71a3986ce5fe522060369

20 files changed:
src/lib/ecore_evas/Ecore_Evas.h
src/lib/ecore_evas/ecore_evas.c
src/lib/ecore_evas/ecore_evas_buffer.c
src/lib/ecore_evas/ecore_evas_cocoa.c
src/lib/ecore_evas/ecore_evas_directfb.c
src/lib/ecore_evas/ecore_evas_ews.c
src/lib/ecore_evas/ecore_evas_extn.c
src/lib/ecore_evas/ecore_evas_fb.c
src/lib/ecore_evas/ecore_evas_private.h
src/lib/ecore_evas/ecore_evas_psl1ght.c
src/lib/ecore_evas/ecore_evas_sdl.c
src/lib/ecore_evas/ecore_evas_wayland_egl.c
src/lib/ecore_evas/ecore_evas_wayland_shm.c
src/lib/ecore_evas/ecore_evas_win32.c
src/lib/ecore_evas/ecore_evas_wince.c
src/lib/ecore_evas/ecore_evas_x.c
src/lib/ecore_x/Ecore_X.h
src/lib/ecore_x/Ecore_X_Atoms.h
src/lib/ecore_x/ecore_x_atoms_decl.h
src/lib/ecore_x/xlib/ecore_x_e.c

index dd6e55b..2483da1 100644 (file)
@@ -682,8 +682,12 @@ EAPI void        ecore_evas_profiles_set(Ecore_Evas *ee, const char **profiles,
  */
 EAPI const char *ecore_evas_profile_get(const Ecore_Evas *ee);
 
-EAPI Eina_Bool   ecore_evas_wm_rotation_supported_get(const Ecore_Evas *ee);
-EAPI int         ecore_evas_wm_rotation_get(const Ecore_Evas *ee);
+EAPI Eina_Bool        ecore_evas_wm_rotation_supported_get(const Ecore_Evas *ee);
+EAPI void             ecore_evas_wm_rotation_preferred_rotation_set(Ecore_Evas *ee, int rotation);
+EAPI int              ecore_evas_wm_rotation_preferred_rotation_get(const Ecore_Evas *ee);
+EAPI void             ecore_evas_wm_rotation_available_rotations_set(Ecore_Evas *ee, const int *rotations, unsigned int count);
+EAPI Eina_Bool        ecore_evas_wm_rotation_available_rotations_get(const Ecore_Evas *ee, int **rotations, unsigned int *count);
+
 /**
  * @brief Send message to parent ecore
  *
index 2bb9235..02a8a35 100644 (file)
@@ -1973,16 +1973,83 @@ ecore_evas_wm_rotation_supported_get(const Ecore_Evas *ee)
    return ee->prop.wm_rot.supported;
 }
 
+EAPI void
+ecore_evas_wm_rotation_preferred_rotation_set(Ecore_Evas *ee, int rotation)
+{
+   if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
+     {
+        ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
+                         "ecore_evas_wm_rotation_preferred_rotation_set");
+        return;
+     }
+   if (rotation != -1)
+     {
+        if (ee->prop.wm_rot.available_rots)
+          {
+             Eina_Bool found = EINA_FALSE;
+             unsigned int i;
+             for (i = 0; i < ee->prop.wm_rot.count; i++)
+               {
+                  if (ee->prop.wm_rot.available_rots[i] == rotation)
+                    {
+                       found = EINA_TRUE;
+                       break;
+                    }
+               }
+             if (!found) return;
+          }
+     }
+   IFC(ee, fn_wm_rot_preferred_rotation_set) (ee, rotation);
+   IFE;
+}
+
 EAPI int
-ecore_evas_wm_rotation_get(const Ecore_Evas *ee)
+ecore_evas_wm_rotation_preferred_rotation_get(const Ecore_Evas *ee)
 {
    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
      {
         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
-                         "ecore_evas_wm_rotation_get");
+                         "ecore_evas_wm_rotation_preferred_rotation_get");
         return 0;
      }
-   return ee->prop.wm_rot.angle;
+   return ee->prop.wm_rot.rot;
+}
+
+EAPI void
+ecore_evas_wm_rotation_available_rotations_set(Ecore_Evas *ee, const int *rotations, unsigned int count)
+{
+   if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
+     {
+        ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
+                         "ecore_evas_wm_rotation_available_rotations_set");
+        return;
+     }
+   IFC(ee, fn_wm_rot_available_rotations_set) (ee, rotations, count);
+   IFE;
+}
+
+EAPI Eina_Bool
+ecore_evas_wm_rotation_available_rotations_get(const Ecore_Evas *ee, int **rotations, unsigned int *count)
+{
+   if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
+     {
+        ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
+                         "ecore_evas_wm_rotation_available_rotations_get");
+        return EINA_FALSE;
+     }
+   if ((!rotations) || (!count))
+     return EINA_FALSE;
+
+   if ((!ee->prop.wm_rot.available_rots) || (ee->prop.wm_rot.count == 0))
+     return EINA_FALSE;
+
+   *rotations = calloc(ee->prop.wm_rot.count, sizeof(int));
+   if (!*rotations) return EINA_FALSE;
+
+   memcpy(*rotations, ee->prop.wm_rot.available_rots, sizeof(int) * ee->prop.wm_rot.count);
+   *count = ee->prop.wm_rot.count;
+
+   return EINA_TRUE;
 }
 
 EAPI void
@@ -2613,6 +2680,8 @@ _ecore_evas_free(Ecore_Evas *ee)
    ee->prop.name = NULL;
    if (ee->prop.clas) free(ee->prop.clas);
    ee->prop.clas = NULL;
+   if (ee->prop.wm_rot.available_rots) free(ee->prop.wm_rot.available_rots);
+   ee->prop.wm_rot.available_rots = NULL;
    if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
    ee->prop.cursor.object = NULL;
    if (ee->evas) evas_free(ee->evas);
index 7a5bed3..cd6a7e4 100644 (file)
@@ -564,7 +564,10 @@ static Ecore_Evas_Engine_Func _ecore_buffer_engine_func =
      NULL, // screen_geometry_get
      NULL,  // screen_dpi_get
      _ecore_evas_buffer_msg_parent_send,
-     _ecore_evas_buffer_msg_send
+     _ecore_evas_buffer_msg_send,
+
+     NULL, // wm_rot_preferred_rotation_set
+     NULL  // wm_rot_available_rotations_set
 };
 #endif
 
index 62f9c2d..ca3d8d8 100644 (file)
@@ -476,7 +476,10 @@ static Ecore_Evas_Engine_Func _ecore_cocoa_engine_func =
      NULL,
      NULL, // screen_dpi_get
      NULL,
-     NULL  // msg_send
+     NULL, // msg_send
+
+     NULL, // wm_rot_preferred_rotation_set
+     NULL // wm_rot_available_rotations_set
   };
 #endif
 
index d9fb237..b5104c6 100644 (file)
@@ -500,7 +500,10 @@ static Ecore_Evas_Engine_Func _ecore_directfb_engine_func =
 
      NULL, // render
      NULL, // screen_geometry_get
-     NULL  // screen_dpi_get
+     NULL, // screen_dpi_get
+
+     NULL, // wm_rot_preferred_rotation_set
+     NULL  // wm_rot_available_rotations_set
 };
 #endif
 
index db2204e..0d05e69 100644 (file)
@@ -696,7 +696,10 @@ static const Ecore_Evas_Engine_Func _ecore_ews_engine_func =
      _ecore_evas_ews_screen_geometry_get,
      NULL,  // screen_dpi_get
      NULL,
-     NULL   // msg_send
+     NULL,  // msg_send
+
+     NULL, // wm_rot_preferred_rotation_set
+     NULL  // wm_rot_available_rotations_set
 };
 
 void
index 317c576..52204e7 100644 (file)
@@ -1220,7 +1220,10 @@ static const Ecore_Evas_Engine_Func _ecore_extn_plug_engine_func =
    NULL, // screen_geometry_get
    NULL, // screen_dpi_get
    _ecore_evas_extn_plug_msg_parent_send,
-   NULL   // msg_send
+   NULL, // msg_send
+
+   NULL, // wm_rot_preferred_rotation_set
+   NULL  // wm_rot_available_rotations_set
 };
 
 static Eina_Bool
index 259297d..c9de1e1 100644 (file)
@@ -564,7 +564,10 @@ static Ecore_Evas_Engine_Func _ecore_fb_engine_func =
      NULL, // screen_geometry_get
      NULL, // screen_dpi_get
      NULL,
-     NULL   // msg_send
+     NULL, // msg_send
+
+     NULL, // wm_rot_preferred_rotation_set
+     NULL  // wm_rot_available_rotations_set
 };
 #endif
 
index aa74009..646c9f8 100644 (file)
@@ -193,6 +193,9 @@ struct _Ecore_Evas_Engine_Func
    void (*fn_screen_dpi_get) (const Ecore_Evas *ee, int *xdpi, int *ydpi);
    void (*fn_msg_parent_send) (Ecore_Evas *ee, int maj, int min, void *data, int size);
    void (*fn_msg_send) (Ecore_Evas *ee, int maj, int min, void *data, int size);
+
+   void (*fn_wm_rot_preferred_rotation_set) (Ecore_Evas *ee, int rot);
+   void (*fn_wm_rot_available_rotations_set) (Ecore_Evas *ee, const int *rots, unsigned int count);
 };
 
 struct _Ecore_Evas_Engine
@@ -346,9 +349,15 @@ struct _Ecore_Evas
       char           *profile;
       struct {
          Eina_Bool    supported;
-         int          angle;
-         Eina_Bool    win_resize;
-         int          w, h;
+         int          angle;         // v0
+         Eina_Bool    win_resize;    // v0
+         int          w, h;          // v0
+         // added for the window manager rotation protocol
+         Eina_Bool    app_set;       // v1: app wants to communicate with the window manager to rotate
+         int          rot;           // v1: decided rotation by the window manager
+         int          preferred_rot; // v1: app specified rotation
+         int         *available_rots;// v1: app specified available rotations
+         unsigned int count;         // v1: number of elements of available rotations
       } wm_rot;
       struct {
         int          w, h;
index f2740f1..754f5d7 100644 (file)
@@ -408,7 +408,10 @@ static Ecore_Evas_Engine_Func _ecore_psl1ght_engine_func =
    _ecore_evas_screen_geometry_get, // screen_geometry_get
    NULL, // screen_dpi_get
    NULL,
-   NULL  //msg_send
+   NULL, //msg_send
+
+   NULL, // wm_rot_preferred_rotation_set
+   NULL  // wm_rot_available_rotations_set
 };
 
 EAPI Ecore_Evas *
index 154e07d..5eb12f8 100644 (file)
@@ -450,7 +450,10 @@ static Ecore_Evas_Engine_Func _ecore_sdl_engine_func =
    NULL, // screen_geometry_get
    NULL, // screen_dpi_get
    NULL,
-   NULL   // msg_send
+   NULL, // msg_send
+
+   NULL, // wm_rot_preferred_rotation_set
+   NULL  // wm_rot_available_rotations_set
 };
 
 static Ecore_Evas*
index 8b36be7..71999cb 100644 (file)
@@ -121,7 +121,9 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
    _ecore_evas_wl_common_screen_geometry_get,
    _ecore_evas_wl_common_screen_dpi_get,
    NULL,
-   NULL   // msg_send
+   NULL, // msg_send
+   NULL, // wm_rot_preferred_rotation_set
+   NULL  // wm_rot_available_rotations_set
 };
 
 /* external variables */
index faf24f1..e99830f 100644 (file)
@@ -135,7 +135,9 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
    NULL, // focus skip set
    _ecore_evas_wl_render,
    _ecore_evas_wl_common_screen_geometry_get,
-   _ecore_evas_wl_common_screen_dpi_get
+   _ecore_evas_wl_common_screen_dpi_get,
+   NULL, // wm_rot_preferred_rotation_set
+   NULL  // wm_rot_available_rotations_set
 };
 
 /* external variables */
index f480b6e..51d3118 100644 (file)
@@ -1123,7 +1123,10 @@ static Ecore_Evas_Engine_Func _ecore_win32_engine_func =
      NULL, // screen_geometry_get
      _ecore_evas_win32_screen_dpi_get,
      NULL,
-     NULL   // msg_send
+     NULL, // msg_send
+
+     NULL, // wm_rot_preferred_rotation_set
+     NULL  // wm_rot_available_rotations_set
 };
 
 #endif /* BUILD_ECORE_EVAS_WIN32 */
index fe0054a..d69e483 100644 (file)
@@ -802,7 +802,10 @@ static Ecore_Evas_Engine_Func _ecore_wince_engine_func =
 
    NULL, // render
    NULL, // screen_geometry_get
-   _ecore_evas_wince_screen_dpi_get
+   _ecore_evas_wince_screen_dpi_get,
+
+   NULL, // wm_rot_preferred_rotation_set
+   NULL  // wm_rot_available_rotations_set
 };
 
 /* API */
index d491917..9f6e03b 100644 (file)
@@ -832,15 +832,32 @@ _ecore_evas_x_event_client_message(void *data __UNUSED__, int type __UNUSED__, v
           return ECORE_CALLBACK_PASS_ON;
         if (ee->prop.wm_rot.supported)
           {
-             ee->prop.wm_rot.angle = (int)e->data.l[1];
-             ee->prop.wm_rot.win_resize = (int)e->data.l[2];
-             ee->prop.wm_rot.w = (int)e->data.l[3];
-             ee->prop.wm_rot.h = (int)e->data.l[4];
-             if (ee->prop.wm_rot.win_resize)
-               ee->engine.x.wm_rot.configure_coming = 1;
-             ee->engine.x.wm_rot.prepare = 1;
-             ee->engine.x.wm_rot.request = 0;
-             ee->engine.x.wm_rot.done = 0;
+             if (ee->prop.wm_rot.app_set)
+               {
+                  // v1
+                  ee->prop.wm_rot.angle = (int)e->data.l[1];
+                  ee->prop.wm_rot.win_resize = (int)e->data.l[2];
+                  ee->prop.wm_rot.w = (int)e->data.l[3];
+                  ee->prop.wm_rot.h = (int)e->data.l[4];
+                  if (ee->prop.wm_rot.win_resize)
+                    ee->engine.x.wm_rot.configure_coming = 1;
+                  ee->engine.x.wm_rot.prepare = 1;
+                  ee->engine.x.wm_rot.request = 0;
+                  ee->engine.x.wm_rot.done = 0;
+               }
+             else
+               {
+                  // v0
+                  ee->prop.wm_rot.angle = (int)e->data.l[1];
+                  ee->prop.wm_rot.win_resize = (int)e->data.l[2];
+                  ee->prop.wm_rot.w = (int)e->data.l[3];
+                  ee->prop.wm_rot.h = (int)e->data.l[4];
+                  if (ee->prop.wm_rot.win_resize)
+                    ee->engine.x.wm_rot.configure_coming = 1;
+                  ee->engine.x.wm_rot.prepare = 1;
+                  ee->engine.x.wm_rot.request = 0;
+                  ee->engine.x.wm_rot.done = 0;
+               }
           }
      }
    else if (e->message_type == ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_REQUEST)
@@ -851,24 +868,44 @@ _ecore_evas_x_event_client_message(void *data __UNUSED__, int type __UNUSED__, v
           return ECORE_CALLBACK_PASS_ON;
         if (ee->prop.wm_rot.supported)
           {
-             ee->engine.x.wm_rot.prepare = 0;
-             ee->engine.x.wm_rot.request = 1;
-             ee->engine.x.wm_rot.done = 0;
-             if (ee->prop.wm_rot.win_resize)
+             if (ee->prop.wm_rot.app_set)
                {
-                  if ((ee->w == ee->prop.wm_rot.w) &&
-                      (ee->h == ee->prop.wm_rot.h))
+                  // v1
+                  ee->engine.x.wm_rot.prepare = 0;
+                  ee->engine.x.wm_rot.request = 1;
+                  ee->engine.x.wm_rot.done = 0;
+                  if (ee->prop.wm_rot.win_resize)
                     {
-                       ee->engine.x.wm_rot.configure_coming = 0;
+                       if ((ee->w == ee->prop.wm_rot.w) &&
+                           (ee->h == ee->prop.wm_rot.h))
+                         {
+                            ee->engine.x.wm_rot.configure_coming = 0;
+                         }
                     }
+                  if (!ee->engine.x.wm_rot.configure_coming)
+                    _ecore_evas_x_rotation_set(ee, ee->prop.wm_rot.angle, 1);
                }
-             if (!ee->engine.x.wm_rot.configure_coming)
+             else
                {
-                  if (ee->prop.wm_rot.angle == ee->rotation)
+                  ee->engine.x.wm_rot.prepare = 0;
+                  ee->engine.x.wm_rot.request = 1;
+                  ee->engine.x.wm_rot.done = 0;
+                  if (ee->prop.wm_rot.win_resize)
                     {
-                       if (ee->func.fn_state_change) ee->func.fn_state_change(ee);
-                       ee->engine.x.wm_rot.request = 0;
-                       ee->engine.x.wm_rot.done = 1;
+                       if ((ee->w == ee->prop.wm_rot.w) &&
+                           (ee->h == ee->prop.wm_rot.h))
+                         {
+                            ee->engine.x.wm_rot.configure_coming = 0;
+                         }
+                    }
+                  if (!ee->engine.x.wm_rot.configure_coming)
+                    {
+                       if (ee->prop.wm_rot.angle == ee->rotation)
+                         {
+                            if (ee->func.fn_state_change) ee->func.fn_state_change(ee);
+                            ee->engine.x.wm_rot.request = 0;
+                            ee->engine.x.wm_rot.done = 1;
+                         }
                     }
                }
           }
@@ -1819,16 +1856,35 @@ _ecore_evas_x_wm_rotation_check(Ecore_Evas *ee)
 {
    if (ee->prop.wm_rot.supported)
      {
-        if (ee->engine.x.wm_rot.request)
+        if (ee->prop.wm_rot.app_set)
           {
-             if (ee->prop.wm_rot.win_resize)
+             // v1
+             if (ee->engine.x.wm_rot.request)
                {
-                  if (!((ee->w == ee->prop.wm_rot.w) && (ee->h == ee->prop.wm_rot.h)))
+                  if (ee->prop.wm_rot.win_resize)
                     {
-                       return EINA_FALSE;
+                       if (!((ee->w == ee->prop.wm_rot.w) && (ee->h == ee->prop.wm_rot.h)))
+                         {
+                            return EINA_FALSE;
+                         }
+                       else
+                         ee->engine.x.wm_rot.configure_coming = 0;
+                    }
+               }
+          }
+        else
+          {
+             if (ee->engine.x.wm_rot.request)
+               {
+                  if (ee->prop.wm_rot.win_resize)
+                    {
+                       if (!((ee->w == ee->prop.wm_rot.w) && (ee->h == ee->prop.wm_rot.h)))
+                         {
+                            return EINA_FALSE;
+                         }
+                       else
+                         ee->engine.x.wm_rot.configure_coming = 0;
                     }
-                  else
-                    ee->engine.x.wm_rot.configure_coming = 0;
                }
           }
      }
@@ -1906,11 +1962,25 @@ _ecore_evas_x_rotation_set(Ecore_Evas *ee, int rotation, int resize)
      {
         if (ee->prop.wm_rot.supported)
           {
-             if (ee->engine.x.wm_rot.request)
+             // v1
+             if (ee->prop.wm_rot.app_set)
                {
-                  if (ee->func.fn_state_change) ee->func.fn_state_change(ee);
-                  ee->engine.x.wm_rot.request = 0;
-                  ee->engine.x.wm_rot.done = 1;
+                  if (ee->engine.x.wm_rot.request)
+                    {
+                       if (ee->func.fn_state_change) ee->func.fn_state_change(ee);
+                       ee->engine.x.wm_rot.request = 0;
+                       ee->engine.x.wm_rot.done = 1;
+                    }
+               }
+             // v0
+             else
+               {
+                  if (ee->engine.x.wm_rot.request)
+                    {
+                       if (ee->func.fn_state_change) ee->func.fn_state_change(ee);
+                       ee->engine.x.wm_rot.request = 0;
+                       ee->engine.x.wm_rot.done = 1;
+                    }
                }
           }
         int angles[2] = { rotation, rotation };
@@ -2877,6 +2947,54 @@ _ecore_evas_x_profiles_set(Ecore_Evas *ee, const char **plist, int n)
 }
 
 static void
+_ecore_evas_x_wm_rot_preferred_rotation_set(Ecore_Evas *ee, int rot)
+{
+   if (ee->prop.wm_rot.supported)
+     {
+        if (!ee->prop.wm_rot.app_set)
+          {
+             ecore_x_e_window_rotation_app_set(ee->prop.window, EINA_TRUE);
+             ee->prop.wm_rot.app_set = EINA_TRUE;
+          }
+        ecore_x_e_window_rotation_preferred_rotation_set(ee->prop.window, rot);
+        ee->prop.wm_rot.preferred_rot = rot;
+     }
+}
+
+static void
+_ecore_evas_x_wm_rot_available_rotations_set(Ecore_Evas *ee, const int *rots, unsigned int count)
+{
+   if (ee->prop.wm_rot.supported)
+     {
+        if (!ee->prop.wm_rot.app_set)
+          {
+             ecore_x_e_window_rotation_app_set(ee->prop.window, EINA_TRUE);
+             ee->prop.wm_rot.app_set = EINA_TRUE;
+          }
+
+        if (ee->prop.wm_rot.available_rots)
+          {
+             free(ee->prop.wm_rot.available_rots);
+             ee->prop.wm_rot.available_rots = NULL;
+          }
+
+        ee->prop.wm_rot.count = 0;
+
+        if (count > 0)
+          {
+             ee->prop.wm_rot.available_rots = calloc(count, sizeof(int));
+             if (!ee->prop.wm_rot.available_rots) return;
+
+             memcpy(ee->prop.wm_rot.available_rots, rots, sizeof(int) * count);
+          }
+
+        ee->prop.wm_rot.count = count;
+
+        ecore_x_e_window_rotation_available_rotations_set(ee->prop.window, rots, count);
+     }
+}
+
+static void
 _ecore_evas_x_avoid_damage_set(Ecore_Evas *ee, int on)
 {
    if (ee->prop.avoid_damage == on) return;
@@ -3201,7 +3319,10 @@ static Ecore_Evas_Engine_Func _ecore_x_engine_func =
      _ecore_evas_x_screen_geometry_get,
      _ecore_evas_x_screen_dpi_get,
      NULL,
-     NULL //fn_msg_send
+     NULL, //fn_msg_send
+
+     _ecore_evas_x_wm_rot_preferred_rotation_set,
+     _ecore_evas_x_wm_rot_available_rotations_set
 };
 #endif /* BUILD_ECORE_EVAS_X11 */
 
index 386122c..13436b4 100644 (file)
@@ -1697,10 +1697,12 @@ EAPI Eina_Bool                        ecore_x_e_window_profile_list_get(Ecore_X_
 
 EAPI void                            ecore_x_e_window_rotation_supported_set(Ecore_X_Window root, Eina_Bool enabled);
 EAPI Eina_Bool                       ecore_x_e_window_rotation_supported_get(Ecore_X_Window root);
-EAPI void                            ecore_x_e_window_available_rotations_set(Ecore_X_Window win, const int *rots, unsigned int count);
-EAPI Eina_Bool                       ecore_x_e_window_available_rotations_get(Ecore_X_Window win, int **rots, unsigned int *count);
-EAPI void                            ecore_x_e_window_preferred_rotation_set(Ecore_X_Window win, const int rot);
-EAPI Eina_Bool                       ecore_x_e_window_preferred_rotation_get(Ecore_X_Window win, int *rot);
+EAPI void                            ecore_x_e_window_rotation_app_set(Ecore_X_Window win, Eina_Bool set);
+EAPI Eina_Bool                       ecore_x_e_window_rotation_app_get(Ecore_X_Window win);
+EAPI void                            ecore_x_e_window_rotation_preferred_rotation_set(Ecore_X_Window win, int rot);
+EAPI Eina_Bool                       ecore_x_e_window_rotation_preferred_rotation_get(Ecore_X_Window win, int *rot);
+EAPI void                            ecore_x_e_window_rotation_available_rotations_set(Ecore_X_Window win, const int *rots, unsigned int count);
+EAPI Eina_Bool                       ecore_x_e_window_rotation_available_rotations_get(Ecore_X_Window win, int **rots, unsigned int *count);
 EAPI void                            ecore_x_e_window_rotation_change_prepare_send(Ecore_X_Window win, int rot, Eina_Bool resize, int w, int h);
 EAPI void                            ecore_x_e_window_rotation_change_prepare_done_send(Ecore_X_Window root, Ecore_X_Window win, int rot);
 EAPI void                            ecore_x_e_window_rotation_change_request_send(Ecore_X_Window win, int rot);
index d4fe513..ac05e54 100644 (file)
@@ -295,8 +295,9 @@ EAPI extern Ecore_X_Atom ECORE_X_ATOM_SDB_SERVER_DISCONNECT;
 
 /* E window rotation extension */
 EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_SUPPORTED;
+EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_APP_SUPPORTED;
 EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_AVAILABLE_LIST;
-EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_PREFERRED_MODE;
+EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_PREFERRED_ROTATION;
 EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_PREPARE;
 EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_PREPARE_DONE;
 EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_REQUEST;
index e38f937..89f3155 100644 (file)
@@ -323,8 +323,9 @@ EAPI Ecore_X_Atom ECORE_X_ATOM_E_PROFILE_LIST = 0;
 
 /* E window rotation extension */
 EAPI Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_SUPPORTED = 0;
+EAPI Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_APP_SUPPORTED = 0;
 EAPI Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_AVAILABLE_LIST = 0;
-EAPI Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_PREFERRED_MODE = 0;
+EAPI Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_PREFERRED_ROTATION = 0;
 EAPI Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_PREPARE = 0;
 EAPI Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_PREPARE_DONE = 0;
 EAPI Ecore_X_Atom ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_REQUEST = 0;
@@ -630,8 +631,9 @@ const Atom_Item atom_items[] =
    { "_E_PROFILE_LIST", &ECORE_X_ATOM_E_PROFILE_LIST },
 
    { "_E_WINDOW_ROTATION_SUPPORTED", &ECORE_X_ATOM_E_WINDOW_ROTATION_SUPPORTED },
+   { "_E_WINDOW_ROTATION_APP_SUPPORTED", &ECORE_X_ATOM_E_WINDOW_ROTATION_APP_SUPPORTED },
    { "_E_WINDOW_ROTATION_AVAILABLE_LIST", &ECORE_X_ATOM_E_WINDOW_ROTATION_AVAILABLE_LIST },
-   { "_E_WINDOW_ROTATION_PREFERRED_MODE", &ECORE_X_ATOM_E_WINDOW_ROTATION_PREFERRED_MODE },
+   { "_E_WINDOW_ROTATION_PREFERRED_ROTATION", &ECORE_X_ATOM_E_WINDOW_ROTATION_PREFERRED_ROTATION },
    { "_E_WINDOW_ROTATION_CHANGE_PREPARE", &ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_PREPARE },
    { "_E_WINDOW_ROTATION_CHANGE_PREPARE_DONE", &ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_PREPARE_DONE },
    { "_E_WINDOW_ROTATION_CHANGE_REQUEST", &ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_REQUEST },
index 0dffa27..e1317a2 100644 (file)
@@ -1203,83 +1203,130 @@ ecore_x_e_window_rotation_supported_get(Ecore_X_Window root)
 }
 
 EAPI void
-ecore_x_e_window_available_rotations_set(Ecore_X_Window win,
-                                         const int     *rots,
-                                         unsigned int   count)
+ecore_x_e_window_rotation_app_set(Ecore_X_Window win,
+                                  Eina_Bool      set)
 {
+   unsigned int val = 0;
+
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
+   if (set) val = 1;
+
    ecore_x_window_prop_card32_set(win,
-                                  ECORE_X_ATOM_E_WINDOW_ROTATION_AVAILABLE_LIST,
-                                  (unsigned int *)rots, count);
+                                  ECORE_X_ATOM_E_WINDOW_ROTATION_APP_SUPPORTED,
+                                  &val, 1);
 }
 
 EAPI Eina_Bool
-ecore_x_e_window_available_rotations_get(Ecore_X_Window  win,
-                                         int           **rots,
-                                         unsigned int   *count)
+ecore_x_e_window_rotation_app_get(Ecore_X_Window win)
 {
-   unsigned char *data;
-   int num;
+   unsigned int val = 0;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   if (!ecore_x_window_prop_card32_get(win,
+                                       ECORE_X_ATOM_E_WINDOW_ROTATION_APP_SUPPORTED,
+                                       &val, 1))
+     return EINA_FALSE;
 
-   if (count) *count = 0;
-   if (rots) *rots = NULL;
-   if (!win) return EINA_FALSE;
+   return val ? EINA_TRUE : EINA_FALSE;
+}
 
-   if (!ecore_x_window_prop_property_get(win,
-                                         ECORE_X_ATOM_E_WINDOW_ROTATION_AVAILABLE_LIST,
-                                         XA_CARDINAL, 32, &data, &num))
-     return EINA_FALSE;
+EAPI void
+ecore_x_e_window_rotation_preferred_rotation_set(Ecore_X_Window win,
+                                                 int            rot)
+{
+   unsigned int val = 0;
 
-   if (count) *count = num;
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-   if (rots)
+   if (rot != -1)
      {
-        (*rots) = calloc(num, sizeof(int));
-        if (!(*rots))
-          {
-             if (count) *count = 0;
-             if (data) free(data);
-             return EINA_FALSE;
-          }
-
-        memcpy(*rots, (int *)data, sizeof(int) * num);
+        val = (unsigned int)rot;
+        ecore_x_window_prop_card32_set(win,
+                                       ECORE_X_ATOM_E_WINDOW_ROTATION_PREFERRED_ROTATION,
+                                       &val, 1);
+     }
+   else
+     {
+        ecore_x_window_prop_property_del(win,
+                                         ECORE_X_ATOM_E_WINDOW_ROTATION_PREFERRED_ROTATION);
      }
+}
 
-   if (data) XFree(data);
-   return EINA_TRUE;
+EAPI Eina_Bool
+ecore_x_e_window_rotation_preferred_rotation_get(Ecore_X_Window win,
+                                                 int           *rot)
+{
+   unsigned int val = 0;
+   int ret = 0;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   ret = ecore_x_window_prop_card32_get(win,
+                                        ECORE_X_ATOM_E_WINDOW_ROTATION_PREFERRED_ROTATION,
+                                        &val, 1);
+   if (ret == 1)
+     {
+        if (rot) *rot = (int)val;
+        return EINA_TRUE;
+     }
+   return EINA_FALSE;
 }
 
 EAPI void
-ecore_x_e_window_preferred_rotation_set(Ecore_X_Window win,
-                                        int            rot)
+ecore_x_e_window_rotation_available_rotations_set(Ecore_X_Window win,
+                                                  const int     *rots,
+                                                  unsigned int   count)
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-   ecore_x_window_prop_property_set(win,
-                                    ECORE_X_ATOM_E_WINDOW_ROTATION_PREFERRED_MODE,
-                                    XA_CARDINAL, 32, (void *)&rot, 1);
+   if (!win) return;
+
+   if ((rots) && (count > 0))
+     ecore_x_window_prop_card32_set(win,
+                                    ECORE_X_ATOM_E_WINDOW_ROTATION_AVAILABLE_LIST,
+                                    (unsigned int *)rots, count);
+   else
+     ecore_x_window_prop_property_del(win,
+                                      ECORE_X_ATOM_E_WINDOW_ROTATION_AVAILABLE_LIST);
 }
 
 EAPI Eina_Bool
-ecore_x_e_window_preferred_rotation_get(Ecore_X_Window win,
-                                        int           *rot)
+ecore_x_e_window_rotation_available_rotations_get(Ecore_X_Window  win,
+                                                  int           **rots,
+                                                  unsigned int   *count)
 {
    unsigned char *data = NULL;
-   int num;
+   int num, i;
+   int *val = NULL;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   if ((!win) || (!rots) || (!count))
+     return EINA_FALSE;
+
+   *rots = NULL;
+   *count = 0;
+
    if (!ecore_x_window_prop_property_get(win,
-                                         ECORE_X_ATOM_E_WINDOW_ROTATION_PREFERRED_MODE,
+                                         ECORE_X_ATOM_E_WINDOW_ROTATION_AVAILABLE_LIST,
                                          XA_CARDINAL, 32, &data, &num))
      return EINA_FALSE;
 
-   if ((data) && (num == 1) && (rot))
+   *count = num;
+
+   if ((num >= 1) && (data))
      {
-        *rot = (int)(*data);
+        val = calloc(num, sizeof(int));
+        if (!val)
+          {
+             if (data) XFree(data);
+             return EINA_FALSE;
+          }
+        for (i = 0; i < num; i++)
+          val[i] = ((int *)data)[i];
         if (data) XFree(data);
+        *rots = val;
         return EINA_TRUE;
      }
    if (data) XFree(data);