rotation: added support of camera rotation according to the UX guide. 83/109083/2
authorGwanglim Lee <gl77.lee@samsung.com>
Sun, 8 Jan 2017 12:46:22 +0000 (21:46 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Sun, 8 Jan 2017 14:07:10 +0000 (23:07 +0900)
The camera rotation feature always makes it possible for the camera
application to be rotated even if the system auto-rotation configuration
is disabled. Even though rotation configuration of the enlightenment
is disabled for the 180 degrees, it allows the camera application to
be rotated.

Change-Id: I6e258ac0b3e3a693a122a08e9925bc9f2e6cd9b1

src/rotation/e_mod_rotation.c
src/rotation/e_mod_rotation.h
src/rotation/e_mod_rotation_settings.c
src/rotation/e_mod_rotation_wl.c
src/rotation/e_mod_rotation_wl.h
src/rotation/e_mod_sensord.c

index 07cef77..1d7a380 100644 (file)
@@ -47,30 +47,6 @@ e_client_rotation_curr_angle_get(const E_Client *ec)
    return ec->e.state.rot.ang.curr;
 }
 
-#ifndef HAVE_WAYLAND_ONLY
-#undef E_CLIENT_HOOK_APPEND
-#define E_CLIENT_HOOK_APPEND(l, t, cb, d) \
-  do                                      \
-    {                                     \
-       E_Client_Hook *_h;                 \
-       _h = e_client_hook_add(t, cb, d);  \
-       assert(_h);                        \
-       l = eina_list_append(l, _h);       \
-    }                                     \
-  while (0)
-
-#undef E_COMP_OBJECT_INTERCEPT_HOOK_APPEND
-#define E_COMP_OBJECT_INTERCEPT_HOOK_APPEND(l, t, cb, d) \
-  do                                                     \
-    {                                                    \
-       E_Comp_Object_Intercept_Hook *_h;                 \
-       _h = e_comp_object_intercept_hook_add(t, cb, d);  \
-       assert(_h);                                       \
-       l = eina_list_append(l, _h);                      \
-    }                                                    \
-  while (0)
-#endif
-
 static Eina_Bool
 _e_mod_pol_rotation_cb_info_rotation_message(void *data EINA_UNUSED, int ev_type EINA_UNUSED, E_Event_Info_Rotation_Message *ev)
 {
@@ -127,9 +103,7 @@ e_mod_pol_rotation_init(void)
 #ifdef HAVE_AUTO_ROTATION
    e_mod_sensord_init();
 #endif
-#ifdef HAVE_WAYLAND_ONLY
    e_mod_rot_wl_init();
-#endif
 
    EINA_LIST_FOREACH(e_comp->zones, l, zone)
      {
@@ -166,9 +140,7 @@ e_mod_pol_rotation_shutdown(void)
 #ifdef HAVE_AUTO_ROTATION
   e_mod_sensord_deinit();
 #endif
-#ifdef HAVE_WAYLAND_ONLY
   e_mod_rot_wl_shutdown();
-#endif
 
   E_FREE_LIST(_event_handlers, ecore_event_handler_del);
 
index 5834827..ba8a40e 100644 (file)
@@ -11,28 +11,13 @@ typedef enum
    ROT_IDX_NUM
 } Rot_Idx;
 
-#ifdef HAVE_WAYLAND_ONLY
 #include "e_mod_rotation_wl.h"
-#else /* HAVE_WAYLAND_ONLY */
-static inline void
-e_zone_rotation_set(E_Zone *zone EINA_UNUSED, int rot EINA_UNUSED)
-{
-   return;
-}
-
-static inline Eina_Bool
-e_zone_rotation_block_set(E_Zone *zone EINA_UNUSED, const char *name_hint EINA_UNUSED, Eina_Bool set EINA_UNUSED)
-{
-   return EINA_FALSE;
-}
-#endif /* HAVE_WAYLAND_ONLY */
 
-EINTERN Eina_Bool e_zone_rotation_block_set(E_Zone *zone, const char *name_hint, Eina_Bool set);
-EINTERN int e_client_rotation_curr_angle_get(const E_Client *ec);
-EINTERN void e_mod_pol_rotation_init(void);
-EINTERN void e_mod_pol_rotation_shutdown(void);
-EINTERN void e_mod_pol_rotation_force_update_add(E_Zone *zone, E_Client *ec);
-EINTERN void e_mod_pol_rotation_force_update_del(E_Zone *zone, E_Client *ec);
+EINTERN int       e_client_rotation_curr_angle_get(const E_Client *ec);
+EINTERN void      e_mod_pol_rotation_init(void);
+EINTERN void      e_mod_pol_rotation_shutdown(void);
+EINTERN void      e_mod_pol_rotation_force_update_add(E_Zone *zone, E_Client *ec);
+EINTERN void      e_mod_pol_rotation_force_update_del(E_Zone *zone, E_Client *ec);
 
 #include "e_mod_rotation.x"
 #endif
index 39448f7..3cb2798 100644 (file)
 #include "e_mod_sensord.h"
 #endif
 
-static Eina_Bool rot_lock = EINA_FALSE;
-
 static void
-_e_mod_rot_settings_lock(int rot)
+_e_mod_rot_settings_lock(int auto_rot)
 {
    E_Zone *zone;
    Eina_List *l;
    const char *name_hint = "vconf";
-   Eina_Bool lock = !rot;
-
-   if (lock == rot_lock)  return;
+   Eina_Bool lock = !auto_rot;
 
    EINA_LIST_FOREACH(e_comp->zones, l, zone)
      {
-        if (lock) e_zone_rotation_set(zone, 0);
-#ifdef HAVE_AUTO_ROTATION
-        else e_zone_rotation_set(zone, e_mod_sensord_cur_angle_get());
-#endif
-        e_zone_rotation_block_set(zone, name_hint, lock);
+        if (lock)
+          {
+             e_zone_rotation_set(zone, 0);
+             e_zone_rotation_block_type_set(zone,
+                                            E_ZONE_ROT_BLOCK_TYPE_SYSTEM_AUTO_ROTATION,
+                                            name_hint,
+                                            EINA_TRUE);
+          }
+        else
+          {
+             e_zone_rotation_block_type_set(zone,
+                                            E_ZONE_ROT_BLOCK_TYPE_SYSTEM_AUTO_ROTATION,
+                                            name_hint,
+                                            EINA_FALSE);
+             e_zone_rotation_set(zone,
+                                 e_mod_sensord_cur_angle_get());
+          }
      }
-   rot_lock = lock;
 }
 
 static void
 _e_mod_rot_settings_cb_autorotate(keynode_t *node, void *data)
 {
-   int rot;
-
-   rot = vconf_keynode_get_bool(node);
-   if (rot < 0) return;
+   int auto_rot = vconf_keynode_get_bool(node);
+   EINA_SAFETY_ON_FALSE_RETURN(auto_rot >= 0);
 
-   _e_mod_rot_settings_lock(rot);
+   _e_mod_rot_settings_lock(auto_rot);
 }
 
 /* externally accessible functions */
@@ -77,5 +82,5 @@ e_mod_rot_settings_init(void)
 EINTERN void
 e_mod_rot_settings_shutdown(void)
 {
-   rot_lock = EINA_FALSE;
+   ;
 }
index 5a121dc..1e5460d 100644 (file)
 #include "e_mod_main.h"
 #include "e_mod_rotation_wl.h"
 #include "e_mod_rotation_private.h"
-
-#ifdef HAVE_WAYLAND_ONLY
-
 #include <wayland-server.h>
 #include "tizen_policy_ext-server-protocol.h"
 
+#ifdef HAVE_AUTO_ROTATION
+#include "e_mod_sensord.h"
+#endif
+
 #define TIZEN_ROTATION_ANGLE_TO_INT(angle) ((angle == TIZEN_ROTATION_ANGLE_0) ? 0 :        \
                                             (angle == TIZEN_ROTATION_ANGLE_90) ? 90 :      \
                                             (angle == TIZEN_ROTATION_ANGLE_180) ? 180 :    \
@@ -77,10 +78,10 @@ static E_Client_Rotation rot =
       NULL,
    }
 };
-static Eina_Hash *hash_policy_ext_rotation = NULL;
-static Eina_List *rot_handlers = NULL;
-static Eina_List *rot_hooks = NULL;
-static Eina_List *rot_intercept_hooks = NULL;
+static Eina_Hash *rot_hash = NULL;
+static Eina_List *rot_cbs = NULL;
+static Eina_List *rot_ec_hooks = NULL;
+static Eina_List *rot_obj_hooks = NULL;
 static Ecore_Idle_Enterer *rot_idle_enterer = NULL;
 static E_Client *fg_ec = NULL;
 
@@ -153,6 +154,43 @@ static Eina_Bool _rot_intercept_hook_show_helper(void *d EINA_UNUSED, E_Client *
 static Eina_Bool _rot_intercept_hook_hide(void *d EINA_UNUSED, E_Client *ec);
 static Eina_Bool _rot_cb_idle_enterer(void *data EINA_UNUSED);
 
+static Eina_Bool
+_camera_check(E_Client *ec)
+{
+   const char *name = e_client_util_name_get(ec);
+   if (!name) return EINA_FALSE;
+   if (!strncmp(name, "camera-app", 10)) return EINA_TRUE;
+   if (!strncmp(name, "com.samsung.camera-app-lite", 27)) return EINA_TRUE;
+   return EINA_FALSE;
+}
+
+static void
+_unlock_rot_for_fg_app(E_Zone *zone)
+{
+   ELOGF("ROTATION", "UNLOCK for app-hint", NULL, NULL);
+
+   e_zone_rotation_unblock_type_set(zone,
+                                    E_ZONE_ROT_UNBLOCK_TYPE_APP_HINT,
+                                    "camera",
+                                    EINA_TRUE);
+
+   e_zone_rotation_set(zone, e_mod_sensord_cur_angle_get());
+}
+
+static void
+_try_lock_rot_for_fg_app(E_Zone *zone)
+{
+   ELOGF("ROTATION", "LOCK for app-hint", NULL, NULL);
+
+   if (zone->rot.block.sys_auto_rot)
+     e_zone_rotation_set(zone, 0);
+
+   e_zone_rotation_unblock_type_set(zone,
+                                    E_ZONE_ROT_UNBLOCK_TYPE_APP_HINT,
+                                    "camera",
+                                    EINA_FALSE);
+}
+
 static void
 _rot_client_cb_vis_prepare_foreground(void *data, Evas_Object *obj, void *event_info)
 {
@@ -167,6 +205,11 @@ _rot_client_cb_vis_prepare_foreground(void *data, Evas_Object *obj, void *event_
      {
         EDBG(ec, "Set the fg_ec to %x", e_client_util_win_get(ec));
         fg_ec = ec;
+
+        if (_camera_check(ec))
+          _unlock_rot_for_fg_app(ec->zone);
+        else
+          _try_lock_rot_for_fg_app(ec->zone);
      }
 
    _e_client_rotation_zone_set(ec->zone, ec, NULL);
@@ -205,9 +248,9 @@ _policy_ext_rotation_get(E_Client *ec)
 {
    Policy_Ext_Rotation *rot;
 
-   EINA_SAFETY_ON_NULL_RETURN_VAL(hash_policy_ext_rotation, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(rot_hash, NULL);
 
-   rot = eina_hash_find(hash_policy_ext_rotation, &ec);
+   rot = eina_hash_find(rot_hash, &ec);
    if (!rot)
      {
         rot = E_NEW(Policy_Ext_Rotation, 1);
@@ -215,7 +258,7 @@ _policy_ext_rotation_get(E_Client *ec)
 
         rot->ec = ec;
         rot->angle_change_done = EINA_TRUE;
-        eina_hash_add(hash_policy_ext_rotation, &ec, rot);
+        eina_hash_add(rot_hash, &ec, rot);
         evas_object_smart_callback_add(ec->frame,
                                        "e,visibility,prepare,foreground",
                                        _rot_client_cb_vis_prepare_foreground,
@@ -489,9 +532,9 @@ _e_tizen_rotation_send_angle_change(E_Client *ec, int angle)
    int ver;
 
    EINA_SAFETY_ON_NULL_RETURN(ec);
-   EINA_SAFETY_ON_NULL_RETURN(hash_policy_ext_rotation);
+   EINA_SAFETY_ON_NULL_RETURN(rot_hash);
 
-   rot = eina_hash_find(hash_policy_ext_rotation, &ec);
+   rot = eina_hash_find(rot_hash, &ec);
    if (!rot) return;
 
    switch (angle)
@@ -643,7 +686,20 @@ _e_client_rotation_zone_set(E_Zone *zone, E_Client *include_ec, E_Client *exclud
                {
                   /* if this client don't have parent, rotate */
                   if (!ec->parent)
-                    e_client_rotation_set(ec, zone->rot.curr);
+                    {
+                       /* rotate window only if auto-rotation is enabled.
+                        * it can show wrong rotated window if we don't check auto-rot value.
+                        *
+                        * assuming that auto-rotation is disabled and window A is 0 degree.
+                        * in this case, when we attempt to run the camera-app which can be
+                        * always rotated, window A is changed to 270 degrees before showing
+                        * camera-app window. to prevent this we should check whether auto
+                        * rotation is enabled.
+                        */
+                       if ((!zone->rot.block.sys_auto_rot) &&
+                           (e_mod_pol_conf_rot_enable_get(zone->rot.curr)))
+                         e_client_rotation_set(ec, zone->rot.curr);
+                    }
                   continue;
                }
              /*
@@ -666,6 +722,11 @@ _e_client_rotation_zone_set(E_Zone *zone, E_Client *include_ec, E_Client *exclud
                     }
                }
 
+             /* TODO: Fix me. To prevent rotation of 180 degrees for normal app */
+             if ((!_camera_check(ec)) &&
+                 (!e_mod_pol_conf_rot_enable_get(zone->rot.curr)))
+               continue;
+
              EDBG(ec, "Append Rotation List '%s'(%p)", ec->icccm.name, ec);
              target_list = eina_list_append(target_list, ec);
              if (ec == fg_ec)
@@ -785,7 +846,7 @@ _e_client_rotation_change_done(void)
              evas_object_show(ec->frame); // e_client_show(ec);
              e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
           }
-        er = eina_hash_find(hash_policy_ext_rotation, &ec);
+        er = eina_hash_find(rot_hash, &ec);
         if ((er) && (er->show_grab))
           E_FREE_FUNC(er->show_grab, e_policy_visibility_client_grab_release);
         ec->e.state.rot.ang.next = -1;
@@ -1251,21 +1312,20 @@ _e_zone_rotation_set_internal(E_Zone *zone, int rot)
    E_OBJECT_CHECK(zone);
    E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE);
 
-   if (!e_config->wm_win_rotation) return;
-
-   ELOGF("ROTATION", "ZONE_ROT |zone:%d|rot curr:%d, rot:%d",
-         NULL, NULL, zone->num, zone->rot.curr, rot);
-
-   if ((zone->rot.wait_for_done) ||
-       (zone->rot.block_count > 0))
+   if (zone->rot.wait_for_done)
      {
         INF("Pending Zone Rotation: wait_for_done %d block_count %d",
-            zone->rot.wait_for_done, zone->rot.block_count);
+            zone->rot.wait_for_done, zone->rot.block.mod_count);
         zone->rot.next = rot;
         zone->rot.pending = EINA_TRUE;
         return;
      }
 
+   if (!e_config->wm_win_rotation) return;
+
+   ELOGF("ROTATION", "ZONE_ROT |zone:%d|rot curr:%d, rot:%d",
+         NULL, NULL, zone->num, zone->rot.curr, rot);
+
    if (zone->rot.curr == rot) return;
 
    zone->rot.prev = zone->rot.curr;
@@ -1290,15 +1350,33 @@ e_zone_rotation_set(E_Zone *zone, int rotation)
 
    TRACE_DS_BEGIN(ZONE ROTATION SET);
 
+   zone->rot.unknown_state = EINA_TRUE;
+
    if (rotation == -1)
      {
-        zone->rot.unknown_state = EINA_TRUE;
         ELOGF("ROTATION", "ZONE_ROT |UNKOWN SET|zone:%d|rot curr:%d, rot:%d",
               NULL, NULL, zone->num, zone->rot.curr, rotation);
         return;
      }
-   else
-     zone->rot.unknown_state = EINA_FALSE;
+
+   if (e_zone_rotation_block_get(zone, rotation))
+     {
+        if ((zone->rot.wait_for_done) ||
+            (zone->rot.block.mod_count > 0))
+          {
+             INF("Pending Zone Rotation: wait_for_done %d block_count %d",
+                 zone->rot.wait_for_done, zone->rot.block.mod_count);
+             zone->rot.next = rotation;
+             zone->rot.pending = EINA_TRUE;
+             return;
+          }
+
+        ELOGF("ROTATION", "ZONE_ROT |UNKOWN SET|zone:%d|rot curr:%d, rot:%d",
+              NULL, NULL, zone->num, zone->rot.curr, rotation);
+        return;
+     }
+
+   zone->rot.unknown_state = EINA_FALSE;
 
    _e_zone_rotation_set_internal(zone, rotation);
    TRACE_DS_END();
@@ -1320,45 +1398,141 @@ e_zone_rotation_sub_set(E_Zone *zone, int rotation)
      _e_zone_rotation_set_internal(zone, rotation);
 }
 
+/* This function has the policy of window rotation LOCK which is
+ * determined according to the UX or the system order of priority.
+ */
 EINTERN Eina_Bool
-e_zone_rotation_block_set(E_Zone *zone, const char *name_hint, Eina_Bool set)
+e_zone_rotation_block_get(E_Zone *zone, int rot)
 {
-   E_Event_Zone_Rotation_Change_Begin *ev;
+   /* 1. specific app which set special hint such as camera */
+   if (zone->rot.unblock.app_hint)
+     {
+        ELOGF("ROTATION", "BLOCK Get. unblocked by app_hint", NULL, NULL);
+        return EINA_FALSE;
+     }
+
+   /* 2. not supported angle in wm-policy configuration */
+   if (!e_mod_pol_conf_rot_enable_get(rot))
+     {
+        ELOGF("ROTATION", "BLOCK Get. CONF disabled", NULL, NULL);
+        return EINA_TRUE;
+     }
+
+   /* 3. auto-rotation through vconf */
+   if (zone->rot.block.sys_auto_rot)
+     {
+        ELOGF("ROTATION", "BLOCK Get. AUTO_ROT disabled", NULL, NULL);
+        return EINA_TRUE;
+     }
+
+   /* 4. temporary block count for the E sub-modules */
+   if (zone->rot.block.mod_count > 0)
+     {
+        ELOGF("ROTATION", "BLOCK Get. E internal block. %d", NULL, NULL,
+              zone->rot.block.mod_count);
+        return EINA_TRUE;
+     }
 
+   return EINA_FALSE;
+}
+
+EINTERN Eina_Bool
+e_zone_rotation_block_type_set(E_Zone *zone, E_Zone_Rot_Block_Type type, const char *name_hint, Eina_Bool block)
+{
    E_OBJECT_CHECK_RETURN(zone, EINA_FALSE);
    E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, EINA_FALSE);
 
-   if (set) zone->rot.block_count++;
-   else     zone->rot.block_count--;
+   switch (type)
+     {
+      case E_ZONE_ROT_BLOCK_TYPE_SYSTEM_AUTO_ROTATION:
+         zone->rot.block.sys_auto_rot = block;
+         ELOGF("ROTATION", "BLOCK_SET. sys_auto_rot:%s", NULL, NULL,
+               block ? "true" : "false");
+         break;
+      case E_ZONE_ROT_BLOCK_TYPE_E_MODULE:
+         if (block) zone->rot.block.mod_count++;
+         else       zone->rot.block.mod_count--;
+         if (zone->rot.block.mod_count <= 0) zone->rot.block.mod_count = 0;
+         ELOGF("ROTATION", "BLOCK_SET. e modules:%s count:%d", NULL, NULL,
+               block ? "true" : "false", zone->rot.block.mod_count);
+         break;
+      default:
+         break;
+     }
 
-   ELOGF("ROTATION", "ROT_BLOCK|%s|zone:%d|count:%d|from:%s", NULL, NULL,
-         set ? "PAUSE" : "RESUME", zone->num, zone->rot.block_count, name_hint);
+   return EINA_TRUE;
+}
 
-   if (zone->rot.block_count <= 0)
+EINTERN Eina_Bool
+e_zone_rotation_unblock_type_set(E_Zone *zone, E_Zone_Rot_Unblock_Type type, const char *name_hint, Eina_Bool unblock)
+{
+   E_OBJECT_CHECK_RETURN(zone, EINA_FALSE);
+   E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, EINA_FALSE);
+
+   switch (type)
      {
-        zone->rot.block_count = 0;
+      case E_ZONE_ROT_UNBLOCK_TYPE_APP_HINT:
+         zone->rot.unblock.app_hint = unblock;
+         ELOGF("ROTATION", "UnBLOCK_SET app hint:%s", NULL, NULL,
+               unblock ? "true" : "false");
+         break;
+      default:
+         break;
+     }
+
+   return EINA_TRUE;
+}
+
+EINTERN Eina_Bool
+e_zone_rotation_block_set(E_Zone *zone, const char *name_hint, Eina_Bool block)
+{
+   E_Event_Zone_Rotation_Change_Begin *ev;
+
+   E_OBJECT_CHECK_RETURN(zone, EINA_FALSE);
+   E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, EINA_FALSE);
+
+   e_zone_rotation_block_type_set(zone,
+                                  E_ZONE_ROT_BLOCK_TYPE_E_MODULE,
+                                  name_hint,
+                                  block);
+   if (block) return EINA_TRUE;
 
-        if (zone->rot.pending)
+   ELOGF("ROTATION", "ROT_BLOCK|RESUME|zone:%d|count:%d|from:%s|rot.pending:%d|next:%d",
+         NULL, NULL,
+         zone->num,
+         zone->rot.block.mod_count,
+         name_hint,
+         zone->rot.pending,
+         zone->rot.next);
+
+   if (zone->rot.pending)
+     {
+        zone->rot.pending = EINA_FALSE;
+        if (zone->rot.curr != zone->rot.next)
           {
-             zone->rot.pending = EINA_FALSE;
-             if (zone->rot.curr != zone->rot.next)
+             if (e_zone_rotation_block_get(zone, zone->rot.next))
                {
-                  zone->rot.prev = zone->rot.curr;
-                  zone->rot.curr = zone->rot.next;
-                  zone->rot.wait_for_done = EINA_TRUE;
-                  zone->rot.pending = EINA_FALSE;
+                  zone->rot.pending = EINA_TRUE;
+                  ELOGF("ROTATION", "ROT_BLOCK|PAUSE|zone:%d|count:%d|from:%s", NULL, NULL,
+                        zone->num, zone->rot.block.mod_count, name_hint);
+                  return EINA_TRUE;
+               }
 
-                  ev = E_NEW(E_Event_Zone_Rotation_Change_Begin, 1);
-                  if (ev)
-                    {
-                       ev->zone = zone;
-                       e_object_ref(E_OBJECT(ev->zone));
-                       ecore_event_add(E_EVENT_ZONE_ROTATION_CHANGE_BEGIN,
-                                       ev, _e_zone_event_rotation_change_begin_free, NULL);
+             zone->rot.prev = zone->rot.curr;
+             zone->rot.curr = zone->rot.next;
+             zone->rot.wait_for_done = EINA_TRUE;
+             zone->rot.pending = EINA_FALSE;
 
-                       ELOGF("ROTATION", "ROT_SET(P|zone:%d|rot:%d",
-                             NULL, NULL, zone->num, zone->rot.curr);
-                    }
+             ev = E_NEW(E_Event_Zone_Rotation_Change_Begin, 1);
+             if (ev)
+               {
+                  ev->zone = zone;
+                  e_object_ref(E_OBJECT(ev->zone));
+                  ecore_event_add(E_EVENT_ZONE_ROTATION_CHANGE_BEGIN,
+                                  ev, _e_zone_event_rotation_change_begin_free, NULL);
+
+                  ELOGF("ROTATION", "ROT_SET(P|zone:%d|rot:%d",
+                        NULL, NULL, zone->num, zone->rot.curr);
                }
           }
      }
@@ -1387,7 +1561,7 @@ e_zone_rotation_update_done(E_Zone *zone)
      }
 
    zone->rot.wait_for_done = EINA_FALSE;
-   if ((zone->rot.block_count == 0) && (zone->rot.pending))
+   if ((zone->rot.block.mod_count == 0) && (zone->rot.pending))
      {
         zone->rot.pending = EINA_FALSE;
         if (zone->rot.curr != zone->rot.next)
@@ -1469,7 +1643,7 @@ _rot_cb_buffer_change(void *data EINA_UNUSED, int ev_type EINA_UNUSED, E_Event_C
    if (EINA_UNLIKELY(!ev->ec))
      goto end;
 
-   rot = eina_hash_find(hash_policy_ext_rotation, &ev->ec);
+   rot = eina_hash_find(rot_hash, &ev->ec);
    if (!rot)
      goto end;
 
@@ -1527,9 +1701,9 @@ _rot_hook_new_client(void *d EINA_UNUSED, E_Client *ec)
    ec->e.state.rot.ang.curr = 0;
    ec->e.state.rot.ang.prev = 0;
 
-   EINA_SAFETY_ON_NULL_RETURN(hash_policy_ext_rotation);
+   EINA_SAFETY_ON_NULL_RETURN(rot_hash);
 
-   rot = eina_hash_find(hash_policy_ext_rotation, &ec);
+   rot = eina_hash_find(rot_hash, &ec);
    if (!rot) return;
 
    if (rot->preferred_angle)
@@ -1553,19 +1727,22 @@ _rot_hook_client_del(void *d EINA_UNUSED, E_Client *ec)
    if (ec->e.state.rot.available_rots)
      E_FREE(ec->e.state.rot.available_rots);
 
-   ext_rot = eina_hash_find(hash_policy_ext_rotation, &ec);
+   ext_rot = eina_hash_find(rot_hash, &ec);
    if (ext_rot)
      {
         EINA_LIST_FREE(ext_rot->rotation_list, res)
            wl_resource_set_user_data(res, NULL);
 
-        eina_hash_del_by_key(hash_policy_ext_rotation, &ec);
+        eina_hash_del_by_key(rot_hash, &ec);
      }
 
    if (fg_ec == ec)
      {
         EDBG(ec, "Set the fg_ec to NULL");
         fg_ec = NULL;
+
+        if (_camera_check(ec))
+          _try_lock_rot_for_fg_app(ec->zone);
      }
 }
 
@@ -1578,7 +1755,7 @@ _rot_hook_eval_end(void *d EINA_UNUSED, E_Client *ec)
 
         if (ec->moving) e_client_act_move_end(ec, NULL);
 
-        if ((!zone->rot.block_count) &&
+        if ((!zone->rot.block.mod_count) &&
             ((!evas_object_visible_get(ec->frame)) ||
              (!E_INTERSECTS(ec->x, ec->y, ec->w, ec->h, zone->x, zone->y, zone->w, zone->h))))
           {
@@ -1603,7 +1780,7 @@ _rot_hook_eval_fetch(void *d EINA_UNUSED, E_Client *ec)
 
    if (!ec) return;
 
-   rot = eina_hash_find(hash_policy_ext_rotation, &ec);
+   rot = eina_hash_find(rot_hash, &ec);
    if (!rot) return;
 
    if(ec->e.fetch.rot.support)
@@ -1777,7 +1954,7 @@ _rot_intercept_hook_show_helper(void *d EINA_UNUSED, E_Client *ec)
 {
    Policy_Ext_Rotation *rot;
 
-   rot = eina_hash_find(hash_policy_ext_rotation, &ec);
+   rot = eina_hash_find(rot_hash, &ec);
    if (!rot)
      return EINA_TRUE;
 
@@ -1799,6 +1976,11 @@ _rot_intercept_hook_show_helper(void *d EINA_UNUSED, E_Client *ec)
      {
         EDBG(ec, "Set the fg_ec to %x", e_client_util_win_get(ec));
         fg_ec = ec;
+
+        if (_camera_check(ec))
+          _unlock_rot_for_fg_app(ec->zone);
+        else
+          _try_lock_rot_for_fg_app(ec->zone);
      }
 
    _e_client_rotation_zone_set(ec->zone, ec, NULL);
@@ -1826,6 +2008,9 @@ _rot_intercept_hook_hide(void *d EINA_UNUSED, E_Client *ec)
      {
         EDBG(ec, "Set the fg_ec to NULL");
         fg_ec = NULL;
+
+        if (_camera_check(ec))
+          _try_lock_rot_for_fg_app(ec->zone);
      }
 
    // for rotating ec in the force_update_list
@@ -1861,7 +2046,7 @@ _rot_cb_idle_enterer(void *data EINA_UNUSED)
              EINA_LIST_FOREACH(rot.list, l, ec)
                {
                   if (!ec->zone) continue;
-                  if (ec->zone->rot.block_count)
+                  if (ec->zone->rot.block.mod_count)
                     {
                        rot_block = EINA_TRUE;
                     }
@@ -1906,12 +2091,9 @@ _rot_cb_idle_enterer(void *data EINA_UNUSED)
    return ECORE_CALLBACK_RENEW;
 }
 
-#endif //#ifdef HAVE_WAYLAND_ONLY
-
 Eina_Bool
 e_mod_rot_wl_init(void)
 {
-#ifdef HAVE_WAYLAND_ONLY
    EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl->wl.disp, EINA_FALSE);
 
@@ -1922,51 +2104,37 @@ e_mod_rot_wl_init(void)
         return EINA_FALSE;
      }
 
-   hash_policy_ext_rotation = eina_hash_pointer_new(_policy_ext_rotation_free);
-
-   E_LIST_HANDLER_APPEND(rot_handlers, E_EVENT_ZONE_ROTATION_CHANGE_BEGIN,
-                         _rot_cb_zone_rotation_change_begin, NULL);
-   E_LIST_HANDLER_APPEND(rot_handlers, E_EVENT_CLIENT_BUFFER_CHANGE,
-                         _rot_cb_buffer_change, NULL);
-
-   E_CLIENT_HOOK_APPEND(rot_hooks, E_CLIENT_HOOK_NEW_CLIENT,
-                        _rot_hook_new_client, NULL);
-   E_CLIENT_HOOK_APPEND(rot_hooks, E_CLIENT_HOOK_DEL,
-                        _rot_hook_client_del, NULL);
-   E_CLIENT_HOOK_APPEND(rot_hooks, E_CLIENT_HOOK_EVAL_END,
-                        _rot_hook_eval_end, NULL);
-   E_CLIENT_HOOK_APPEND(rot_hooks, E_CLIENT_HOOK_EVAL_FETCH,
-                        _rot_hook_eval_fetch, NULL);
+   rot_hash = eina_hash_pointer_new(_policy_ext_rotation_free);
 
-   E_COMP_OBJECT_INTERCEPT_HOOK_APPEND(rot_intercept_hooks,
-                                       E_COMP_OBJECT_INTERCEPT_HOOK_SHOW_HELPER,
-                                       _rot_intercept_hook_show_helper, NULL);
-   E_COMP_OBJECT_INTERCEPT_HOOK_APPEND(rot_intercept_hooks,
-                                       E_COMP_OBJECT_INTERCEPT_HOOK_HIDE,
-                                       _rot_intercept_hook_hide, NULL);
+   E_LIST_HANDLER_APPEND(rot_cbs,     E_EVENT_ZONE_ROTATION_CHANGE_BEGIN, _rot_cb_zone_rotation_change_begin, NULL);
+   E_LIST_HANDLER_APPEND(rot_cbs,     E_EVENT_CLIENT_BUFFER_CHANGE,       _rot_cb_buffer_change,              NULL);
+   E_CLIENT_HOOK_APPEND(rot_ec_hooks, E_CLIENT_HOOK_NEW_CLIENT,           _rot_hook_new_client,               NULL);
+   E_CLIENT_HOOK_APPEND(rot_ec_hooks, E_CLIENT_HOOK_DEL,                  _rot_hook_client_del,               NULL);
+   E_CLIENT_HOOK_APPEND(rot_ec_hooks, E_CLIENT_HOOK_EVAL_END,             _rot_hook_eval_end,                 NULL);
+   E_CLIENT_HOOK_APPEND(rot_ec_hooks, E_CLIENT_HOOK_EVAL_FETCH,           _rot_hook_eval_fetch,               NULL);
+   E_COMP_OBJECT_INTERCEPT_HOOK_APPEND(rot_obj_hooks, E_COMP_OBJECT_INTERCEPT_HOOK_SHOW_HELPER, _rot_intercept_hook_show_helper, NULL);
+   E_COMP_OBJECT_INTERCEPT_HOOK_APPEND(rot_obj_hooks, E_COMP_OBJECT_INTERCEPT_HOOK_HIDE,        _rot_intercept_hook_hide,        NULL);
 
    rot_idle_enterer = ecore_idle_enterer_add(_rot_cb_idle_enterer, NULL);
-#endif
+
    return EINA_TRUE;
 }
 
 void
 e_mod_rot_wl_shutdown(void)
 {
-#ifdef HAVE_WAYLAND_ONLY
-   E_FREE_FUNC(hash_policy_ext_rotation, eina_hash_free);
+   E_FREE_FUNC(rot_hash, eina_hash_free);
    E_FREE_FUNC(rot.force_update_list, eina_list_free);
 
-   E_FREE_LIST(rot_hooks, e_client_hook_del);
-   E_FREE_LIST(rot_handlers, ecore_event_handler_del);
-   E_FREE_LIST(rot_intercept_hooks, e_comp_object_intercept_hook_del);
+   E_FREE_LIST(rot_ec_hooks, e_client_hook_del);
+   E_FREE_LIST(rot_cbs, ecore_event_handler_del);
+   E_FREE_LIST(rot_obj_hooks, e_comp_object_intercept_hook_del);
 
    if (rot_idle_enterer)
      {
          ecore_idle_enterer_del(rot_idle_enterer);
          rot_idle_enterer = NULL;
      }
-#endif
 }
 
 EINTERN void
index ab26cf1..4b5c798 100644 (file)
@@ -2,7 +2,6 @@
 #define E_MOD_ROTATION_WL_H
 
 #include "config.h"
-#ifdef HAVE_WAYLAND_ONLY
 #include <e.h>
 
 #ifdef ENABLE_TTRACE
 # define TRACE_DS_END()
 #endif
 
-Eina_Bool          e_mod_rot_wl_init(void);
-void               e_mod_rot_wl_shutdown(void);
-EINTERN void       e_zone_rotation_set(E_Zone *zone, int rotation);
-EINTERN Eina_Bool  e_zone_rotation_block_set(E_Zone *zone, const char *name_hint, Eina_Bool set);
+typedef enum _E_Zone_Rot_Unblock_Type
+{
+   E_ZONE_ROT_UNBLOCK_TYPE_APP_HINT,           /* true: rotation is NOT blocked for the specific app which set special hint */
+} E_Zone_Rot_Unblock_Type;
+
+typedef enum _E_Zone_Rot_Block_Type
+{
+   E_ZONE_ROT_BLOCK_TYPE_SYSTEM_AUTO_ROTATION, /* true: system auto rotation is disabled */
+   E_ZONE_ROT_BLOCK_TYPE_E_MODULE,             /* true: temporary block for the E sub-modules */
+} E_Zone_Rot_Block_Type;
+
+EINTERN Eina_Bool e_mod_rot_wl_init(void);
+EINTERN void      e_mod_rot_wl_shutdown(void);
+EINTERN void      e_zone_rotation_set(E_Zone *zone, int rotation);
+EINTERN Eina_Bool e_zone_rotation_block_set(E_Zone *zone, const char *name_hint, Eina_Bool block);
+EINTERN Eina_Bool e_zone_rotation_block_type_set(E_Zone *zone, E_Zone_Rot_Block_Type type, const char *name_hint, Eina_Bool block);
+EINTERN Eina_Bool e_zone_rotation_unblock_type_set(E_Zone *zone, E_Zone_Rot_Unblock_Type type, const char *name_hint, Eina_Bool unblock);
+EINTERN Eina_Bool e_zone_rotation_block_get(E_Zone *zone, int rot);
 
-#endif /* HAVE_WAYLAND_ONLY */
 #endif /* E_MOD_ROTATION_WL_H */
index 3c8031c..19df204 100644 (file)
@@ -7,15 +7,15 @@ typedef struct _Pol_Sensord Pol_Sensord;
 
 struct _Pol_Sensord
 {
-   sensor_t                        sensor;
-   int                             handle;
-   Eina_Bool                       started;
-   int                             event;
-   Ecore_Timer                    *retry_timer;
-   int                             retry_count;
-   Eina_Bool                       lock;
-   Eina_Bool                       connected;
-   int                             angle;
+   sensor_t     sensor;
+   int          handle;
+   Eina_Bool    started;
+   int          event;
+   Ecore_Timer *retry_timer;
+   int          retry_count;
+   Eina_Bool    lock;
+   Eina_Bool    connected;
+   int          angle;
 };
 
 /* static global variables */
@@ -31,26 +31,21 @@ _ang_get(int event)
    /* change CW (SensorFW) to CCW(EFL) */
    switch (event)
      {
-      case AUTO_ROTATION_DEGREE_0:     ang = 0; break;
-      case AUTO_ROTATION_DEGREE_90:    ang = 270; break;
-      case AUTO_ROTATION_DEGREE_180:   ang = 180; break;
-      case AUTO_ROTATION_DEGREE_270:   ang = 90; break;
-      default:
-         DBG("Unknown event %d", event);
-        break;
+      case AUTO_ROTATION_DEGREE_0:   ang =   0; break;
+      case AUTO_ROTATION_DEGREE_90:  ang = 270; break;
+      case AUTO_ROTATION_DEGREE_180: ang = 180; break;
+      case AUTO_ROTATION_DEGREE_270: ang =  90; break;
+      default: DBG("Unknown event %d", event);  break;
      }
 
-   if (!e_mod_pol_conf_rot_enable_get(ang))
-     return -1;
-
    return ang;
 }
 
 static void
-_sensor_rotation_changed_cb(sensor_t             sensor,
-                            unsigned int         event_type,
-                            sensor_data_t       *data,
-                            void                *user_data)
+_sensor_rotation_changed_cb(sensor_t       sensor,
+                            unsigned int   event_type,
+                            sensor_data_t *data,
+                            void          *user_data)
 {
     E_Zone *zone = e_zone_current_get();
     int event;
@@ -60,6 +55,8 @@ _sensor_rotation_changed_cb(sensor_t             sensor,
     if (!zone) return;
     if (event_type != AUTO_ROTATION_EVENT_CHANGE_STATE) return;
 
+    ELOGF("ROTATION", "degree:%d", NULL, NULL, _ang_get((int)data->values[0]));
+
     event = (int)data->values[0];
 
     ang = _ang_get(event);