Support floating mode 93/66693/5
authorMinJeong Kim <minjjj.kim@samsung.com>
Wed, 20 Apr 2016 10:08:11 +0000 (19:08 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Tue, 26 Apr 2016 05:35:27 +0000 (22:35 -0700)
Change-Id: I25bd56766f867a43aadb1fc516642911f5ff939d

src/e_mod_main.c
src/e_mod_main.h
src/e_mod_wl.c

index 3b37d0d..d025187 100644 (file)
@@ -26,6 +26,8 @@ static void        _pol_client_del(Pol_Client *pc);
 static Eina_Bool   _pol_client_normal_check(E_Client *ec);
 static void        _pol_client_maximize_policy_apply(Pol_Client *pc);
 static void        _pol_client_maximize_policy_cancel(Pol_Client *pc);
+static void        _pol_client_floating_policy_apply(Pol_Client *pc);
+static void        _pol_client_floating_policy_cancel(Pol_Client *pc);
 static void        _pol_client_launcher_set(Pol_Client *pc);
 
 static void        _pol_cb_hook_client_eval_pre_new_client(void *d EINA_UNUSED, E_Client *ec);
@@ -137,6 +139,13 @@ _pol_client_normal_check(E_Client *ec)
      goto cancel_max;
    else if (!e_util_strcmp("e_demo", ec->icccm.window_role))
      goto cancel_max;
+   else if (e_mod_pol_client_is_floating(ec))
+     {
+        pc = eina_hash_find(hash_pol_clients, &ec);
+        _pol_client_maximize_policy_cancel(pc);
+        _pol_client_floating_policy_apply(pc);
+        return EINA_FALSE;
+     }
 #ifdef HAVE_WAYLAND_ONLY
    else if (e_mod_pol_client_is_subsurface(ec))
      goto cancel_max;
@@ -320,6 +329,84 @@ _pol_client_maximize_policy_cancel(Pol_Client *pc)
 }
 
 static void
+_pol_client_floating_policy_apply(Pol_Client *pc)
+{
+   E_Client *ec;
+
+   if (pc->flt_policy_state) return;
+
+   pc->flt_policy_state = EINA_TRUE;
+   ec = pc->ec;
+
+#undef _SET
+# define _SET(a) pc->orig.a = pc->ec->a
+   _SET(fullscreen);
+   _SET(lock_client_stacking);
+   _SET(lock_user_shade);
+   _SET(lock_client_shade);
+   _SET(lock_user_maximize);
+   _SET(lock_client_maximize);
+   _SET(lock_user_fullscreen);
+   _SET(lock_client_fullscreen);
+#undef _SET
+
+   ec->skip_fullscreen = 1;
+   ec->lock_client_stacking = 1;
+   ec->lock_user_shade = 1;
+   ec->lock_client_shade = 1;
+   ec->lock_user_maximize = 1;
+   ec->lock_client_maximize = 1;
+   ec->lock_user_fullscreen = 1;
+   ec->lock_client_fullscreen = 1;
+}
+
+static void
+_pol_client_floating_policy_cancel(Pol_Client *pc)
+{
+   E_Client *ec;
+   Eina_Bool changed = EINA_FALSE;
+
+   if (!pc->flt_policy_state) return;
+
+   pc->flt_policy_state = EINA_FALSE;
+   ec = pc->ec;
+
+   if ((pc->orig.fullscreen != ec->fullscreen) &&
+       (pc->orig.fullscreen))
+     {
+        ec->need_fullscreen = 1;
+        changed = EINA_TRUE;
+     }
+
+   if (pc->orig.maximized != ec->maximized)
+     {
+        if (pc->orig.maximized)
+          ec->changes.need_maximize = 1;
+        else
+          e_client_unmaximize(ec, ec->maximized);
+
+        changed = EINA_TRUE;
+     }
+
+   ec->skip_fullscreen = 0;
+
+#undef _SET
+# define _SET(a) ec->a = pc->orig.a
+   _SET(fullscreen);
+   _SET(lock_client_stacking);
+   _SET(lock_user_shade);
+   _SET(lock_client_shade);
+   _SET(lock_user_maximize);
+   _SET(lock_client_maximize);
+   _SET(lock_user_fullscreen);
+   _SET(lock_client_fullscreen);
+#undef _SET
+
+   if (changed)
+     EC_CHANGED(pc->ec);
+}
+
+static void
 _pol_cb_hook_client_new(void *d EINA_UNUSED, E_Client *ec)
 {
    if (EINA_UNLIKELY(!ec))
@@ -378,6 +465,14 @@ _pol_cb_hook_client_eval_pre_new_client(void *d EINA_UNUSED, E_Client *ec)
                evas_object_layer_set(ec->frame, ec->layer);
           }
      }
+   if (e_mod_pol_client_is_floating(ec))
+     {
+        if (ec->frame)
+          {
+             if (ec->layer != E_LAYER_CLIENT_ABOVE)
+               evas_object_layer_set(ec->frame, E_LAYER_CLIENT_ABOVE);
+          }
+     }
 }
 
 static void
@@ -436,6 +531,15 @@ _pol_cb_hook_client_eval_post_fetch(void *d EINA_UNUSED, E_Client *ec)
         return;
      }
 
+   if (e_mod_pol_client_is_floating(ec))
+     {
+        Pol_Client *pc;
+        pc = eina_hash_find(hash_pol_clients, &ec);
+        _pol_client_maximize_policy_cancel(pc);
+        _pol_client_floating_policy_apply(pc);
+        return;
+     }
+
    if (e_mod_pol_client_is_noti(ec))
      e_client_util_move_without_frame(ec, 0, 0);
 
@@ -445,6 +549,10 @@ _pol_cb_hook_client_eval_post_fetch(void *d EINA_UNUSED, E_Client *ec)
    if (!pd) return;
 
    pc = eina_hash_find(hash_pol_clients, &ec);
+
+   if (pc->flt_policy_state)
+     _pol_client_floating_policy_cancel(pc);
+
    _pol_client_maximize_policy_apply(pc);
 }
 
@@ -1144,6 +1252,20 @@ e_mod_pol_client_is_subsurface(E_Client *ec)
 }
 #endif
 
+Eina_Bool
+e_mod_pol_client_is_floating(E_Client *ec)
+{
+   Pol_Client *pc;
+
+   E_OBJECT_CHECK_RETURN(ec, EINA_FALSE);
+   E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, EINA_FALSE);
+
+   if (EINA_UNLIKELY(!ec))
+     return EINA_FALSE;
+
+   return ec->floating;
+}
+
 static Eina_Bool
 _pol_cb_module_defer_job(void *data EINA_UNUSED)
 {
index 7239ee6..e4eacd7 100644 (file)
@@ -53,6 +53,7 @@ struct _Pol_Client
    } changes;
 
    Eina_Bool max_policy_state;
+   Eina_Bool flt_policy_state;
    Eina_Bool allow_user_geom;
    int       user_geom_ref;
 };
@@ -151,6 +152,7 @@ EINTERN Eina_Bool        e_mod_pol_client_is_conformant(E_Client *ec);
 EINTERN Eina_Bool        e_mod_pol_client_is_volume(E_Client *ec);
 EINTERN Eina_Bool        e_mod_pol_client_is_volume_tv(E_Client *ec);
 EINTERN Eina_Bool        e_mod_pol_client_is_noti(E_Client *ec);
+EINTERN Eina_Bool        e_mod_pol_client_is_floating(E_Client *ec);
 #ifdef HAVE_WAYLAND_ONLY
 EINTERN Eina_Bool        e_mod_pol_client_is_subsurface(E_Client *ec);
 #endif
index cbabec3..0627692 100644 (file)
@@ -2282,6 +2282,50 @@ _tzpol_iface_cb_background_state_unset(struct wl_client *client EINA_UNUSED, str
      }
 }
 
+static void
+_pol_wl_floating_mode_apply(E_Client *ec, Eina_Bool floating)
+{
+   if (ec->floating == floating) return;
+
+   ec->floating = floating;
+
+   if (ec->frame)
+     {
+        if (floating)
+          evas_object_layer_set(ec->frame, E_LAYER_CLIENT_ABOVE);
+        else
+          evas_object_layer_set(ec->frame, E_LAYER_CLIENT_NORMAL);
+     }
+
+   EC_CHANGED(ec);
+}
+
+static void
+_tzpol_iface_cb_floating_mode_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
+{
+   E_Client *ec;
+
+   ec = wl_resource_get_user_data(surf);
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+
+   ELOGF("TZPOL", "FLOATING Set", ec, ec->pixmap);
+
+   _pol_wl_floating_mode_apply(ec, EINA_TRUE);
+}
+
+static void
+_tzpol_iface_cb_floating_mode_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
+{
+   E_Client *ec;
+
+   ec = wl_resource_get_user_data(surf);
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+
+   ELOGF("TZPOL", "FLOATING Unset", ec, ec->pixmap);
+
+   _pol_wl_floating_mode_apply(ec, EINA_FALSE);
+}
+
 // --------------------------------------------------------
 // Pol_Wl_Tz_Dpy_Pol
 // --------------------------------------------------------
@@ -2619,6 +2663,8 @@ static const struct tizen_policy_interface _tzpol_iface =
    _tzpol_iface_cb_supported_aux_hints_get,
    _tzpol_iface_cb_background_state_set,
    _tzpol_iface_cb_background_state_unset,
+   _tzpol_iface_cb_floating_mode_set,
+   _tzpol_iface_cb_floating_mode_unset,
 };
 
 static void