e_policy_stack: [2nd] apply stack policy for transient below 08/259808/7 accepted/tizen/unified/20210709.081232 submit/tizen/20210709.022325
authorDoyoun Kang <doyoun.kang@samsung.com>
Tue, 15 Jun 2021 03:20:55 +0000 (12:20 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Fri, 9 Jul 2021 02:07:15 +0000 (02:07 +0000)
There was a case that the transient_below did not work.
This change will fix it.

This change is dependent on the below change.
- policy: apply stack policy for transient below

Change-Id: I3948a0b7948588ee3349e1c7f09099ae65de291e

src/bin/e_policy_stack.c

index 4ec752a67757f1cec429cdf978bf7a8203a0f553..7ff05eddc8c290874243a1fb66d225917c108b61 100644 (file)
@@ -1,18 +1,22 @@
 #include "e.h"
 
 Eina_Bool
-_e_policy_stack_transient_for_check_descendant(E_Client *ec, E_Client *ancestor)
+_e_policy_stack_transient_for_check_descendant(E_Client *ec, E_Client *ancestor, E_Transient policy)
 {
    E_Client *parent = NULL;
    Eina_Bool is_descendant = EINA_FALSE;
 
    if (!ec) return EINA_FALSE;
    if (!ancestor) return EINA_FALSE;
+   if (ec->transient_policy != policy) return EINA_FALSE;
 
    parent = ec->parent;
    while (parent)
      {
-        if (parent && (eina_list_data_find(ancestor->transients, parent)))
+        if (parent->transient_policy != policy)
+          return EINA_FALSE;
+
+        if (eina_list_data_find(ancestor->transients, parent))
           {
              is_descendant = EINA_TRUE;
              break;
@@ -27,7 +31,7 @@ void
 _e_policy_stack_transient_for_apply(E_Client *ec)
 {
    int raise;
-   E_Client *child, *top;
+   E_Client *child, *top, *bottom;
    Eina_List *l;
    Eina_Bool intercepted = EINA_FALSE;
 
@@ -117,10 +121,13 @@ _e_policy_stack_transient_for_apply(E_Client *ec)
                }
              if ((top != ec) && (eina_list_data_find(ec->parent->transients, top)))
                {
-                  if (!e_client_mapped_get(top))
+                  if (!e_client_is_internal(top))
                     {
-                       top = e_client_below_get(top);
-                       continue;
+                       if (!e_client_mapped_get(top))
+                         {
+                            top = e_client_below_get(top);
+                            continue;
+                         }
                     }
                   if (top->transient_for_always_on_top)
                     {
@@ -136,7 +143,8 @@ _e_policy_stack_transient_for_apply(E_Client *ec)
                   else
                     break;
                }
-             if (_e_policy_stack_transient_for_check_descendant(top, ec->parent))
+
+             if (_e_policy_stack_transient_for_check_descendant(top, ec->parent, E_TRANSIENT_ABOVE))
                break;
 
              top = e_client_below_get(top);
@@ -149,7 +157,42 @@ _e_policy_stack_transient_for_apply(E_Client *ec)
      }
    else if (ec->transient_policy == E_TRANSIENT_BELOW)
      {
-        e_client_stack_below(ec, ec->parent);
+        if (eina_list_count(ec->parent->transients) <= 1)
+          e_client_stack_below(ec, ec->parent);
+        else
+          {
+             bottom = e_client_bottom_get();
+             while (bottom)
+               {
+                  if (bottom == ec->parent)
+                    break;
+
+                  if ((bottom != ec) && (eina_list_data_find(ec->parent->transients, bottom)))
+                    {
+                       if (!e_client_is_internal(bottom))
+                         {
+                            if (!e_client_mapped_get(bottom))
+                              {
+                                 bottom = e_client_above_get(bottom);
+                                 continue;
+                              }
+                         }
+
+                       if (bottom->transient_policy == E_TRANSIENT_BELOW)
+                         break;
+                    }
+
+                  if (_e_policy_stack_transient_for_check_descendant(bottom, ec->parent, E_TRANSIENT_BELOW))
+                    break;
+
+                  bottom = e_client_above_get(bottom);
+               }
+
+             if (bottom)
+               e_client_stack_below(ec, bottom);
+             else
+               e_client_stack_below(ec, ec->parent);
+          }
      }
 }
 
@@ -241,8 +284,8 @@ _e_policy_stack_transient_for_set(E_Client *ec, E_Client *parent, Eina_Bool tran
 
    EINA_SAFETY_ON_NULL_RETURN(ec);
 
-   ELOGF("POL", "Set Transient_stack. parent(win:%zx, ec:%p), is_transient_for:%d",
-         ec, e_client_util_win_get(parent), parent, transient);
+   ELOGF("POL", "Set Transient_stack. new parent(win:%zx, ec:%p) old parent(win:%zx, ec:%p), is_transient_for:%d",
+         ec, e_client_util_win_get(parent), parent, e_client_util_win_get(ec->parent), ec->parent, transient);
 
    if (!parent)
      {