e_client: Move e_policy_client_find to e_client 96/302996/1
authorJunseok Kim <juns.kim@samsung.com>
Mon, 18 Dec 2023 10:46:05 +0000 (19:46 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Mon, 18 Dec 2023 11:21:11 +0000 (20:21 +0900)
move _e_policy_client_find_above/below to e_client and rename it.

Change-Id: I167e0adbea87214bac6fcb978cf4f8f47c0e84a8

src/bin/e_client.c
src/bin/e_client.h
src/bin/e_policy.c

index 404e0cf..ca178df 100644 (file)
@@ -3862,6 +3862,112 @@ e_client_below_get(const E_Client *ec)
    return NULL;
 }
 
+EINTERN E_Client *
+e_client_visible_above_get(E_Client *ec)
+{
+   unsigned int x;
+   E_Client *ec2;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
+   if (EINA_INLIST_GET(ec)->next) //check current layer
+     {
+        EINA_INLIST_FOREACH(EINA_INLIST_GET(ec)->next, ec2)
+          {
+             if (ec == ec2) continue;
+             if ((!e_object_is_del(E_OBJECT(ec2))) &&
+                 (!e_client_util_ignored_get(ec2)) &&
+                 (ec2->visible) &&
+                 (ec2->frame))
+               return ec2;
+          }
+     }
+
+   if (ec->layer == E_LAYER_CLIENT_CURSOR) return NULL;
+   if (e_comp_canvas_client_layer_map(ec->layer) == 9999) return NULL;
+
+   /* go up the layers until we find one */
+   for (x = e_comp_canvas_layer_map(ec->layer) + 1; x <= e_comp_canvas_layer_map(E_LAYER_CLIENT_CURSOR); x++)
+     {
+        if (!e_comp->layers[x].clients) continue;
+        EINA_INLIST_FOREACH(e_comp->layers[x].clients, ec2)
+          {
+             if (ec == ec2) continue;
+             if ((!e_object_is_del(E_OBJECT(ec2))) &&
+                 (!e_client_util_ignored_get(ec2)) &&
+                 (ec2->visible) &&
+                 (ec2->frame))
+               return ec2;
+          }
+     }
+
+   return NULL;
+}
+
+EINTERN E_Client *
+e_client_visible_below_get(E_Client *ec)
+{
+   unsigned int x;
+   E_Client *ec2;
+   Eina_Inlist *l;
+   E_Layer ec_layer, ec_layer_cw;
+   int cw_layer;
+
+   E_OBJECT_CHECK_RETURN(ec, NULL);
+   E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, NULL);
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
+   if (EINA_INLIST_GET(ec)->prev) //check current layer
+     {
+        for (l = EINA_INLIST_GET(ec)->prev; l; l = l->prev)
+          {
+             ec2 = EINA_INLIST_CONTAINER_GET(l, E_Client);
+             if (ec == ec2) continue;
+             if ((!e_object_is_del(E_OBJECT(ec2))) &&
+                 (!e_client_util_ignored_get(ec2)) &&
+                 (ec2->visible) &&
+                 (ec2->frame))
+               return ec2;
+          }
+     }
+
+   // check layer validation
+   ec_layer = ec->layer;
+   if (ec->layer_block || ec->layer_pending)
+     {
+        cw_layer = e_comp_object_layer_get(ec->frame);
+        if (cw_layer >= 0)
+          {
+             ec_layer_cw = e_comp_canvas_layer_map_to(cw_layer);
+             if (ec_layer != ec_layer_cw)
+               {
+                  ELOGF("COMP", "LAYER is not same. USE obj layer! (ec->layer:%d, obj:%d). block:%d, pending:%d)", ec, ec_layer, ec_layer_cw, ec->layer_block, ec->layer_pending);
+                  ec_layer = ec_layer_cw;
+               }
+          }
+     }
+
+   /* go down the layers until we find one */
+   if (e_comp_canvas_layer_map(ec->layer) > e_comp_canvas_layer_map(E_LAYER_MAX)) return NULL;
+   x = e_comp_canvas_layer_map(ec->layer);
+   if (x > 0) x--;
+
+   for (; x >= e_comp_canvas_layer_map(E_LAYER_CLIENT_DESKTOP); x--)
+     {
+        if (!e_comp->layers[x].clients) continue;
+        EINA_INLIST_REVERSE_FOREACH(e_comp->layers[x].clients, ec2)
+          {
+             if (ec == ec2) continue;
+             if ((!e_object_is_del(E_OBJECT(ec2))) &&
+                 (!e_client_util_ignored_get(ec2)) &&
+                 (ec2->visible) &&
+                 (ec2->frame))
+               return ec2;
+          }
+     }
+
+   return NULL;
+}
+
 E_API E_Client *
 e_client_bottom_get(void)
 {
index 325c2ab..1e27016 100644 (file)
@@ -1112,6 +1112,8 @@ E_API void e_client_size_get(E_Client *ec, int *w, int *h);
 E_API void e_client_geometry_get(E_Client *ec, int *x, int *y, int *w, int *h);
 E_API E_Client *e_client_above_get(const E_Client *ec);
 E_API E_Client *e_client_below_get(const E_Client *ec);
+EINTERN E_Client *e_client_visible_above_get(E_Client *ec);
+EINTERN E_Client *e_client_visible_below_get(E_Client *ec);
 E_API E_Client *e_client_bottom_get(void);
 E_API E_Client *e_client_top_get(void);
 EINTERN unsigned int e_clients_count(void);
index 3e9e26e..b52af6a 100644 (file)
@@ -1171,89 +1171,6 @@ _e_policy_cb_client_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *e
    return ECORE_CALLBACK_PASS_ON;
 }
 
-static E_Client *
-_e_policy_client_find_above(const E_Client *ec)
-{
-   unsigned int x;
-   E_Client *ec2;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
-   if (EINA_INLIST_GET(ec)->next) //check current layer
-     {
-        EINA_INLIST_FOREACH(EINA_INLIST_GET(ec)->next, ec2)
-          {
-             if ((!e_object_is_del(E_OBJECT(ec2))) &&
-                 (!e_client_util_ignored_get(ec2)) &&
-                 (ec2->visible) &&
-                 (ec2->frame))
-               return ec2;
-          }
-     }
-   if (ec->layer == E_LAYER_CLIENT_ALERT) return NULL;
-   if (e_comp_canvas_client_layer_map(ec->layer) == 9999) return NULL;
-
-   /* go up the layers until we find one */
-   for (x = e_comp_canvas_layer_map(ec->layer) + 1; x <= e_comp_canvas_layer_map(E_LAYER_CLIENT_ALERT); x++)
-     {
-        if (!e_comp->layers[x].clients) continue;
-        EINA_INLIST_FOREACH(e_comp->layers[x].clients, ec2)
-          {
-             if (ec2 == ec) continue;
-             if ((!e_object_is_del(E_OBJECT(ec2))) &&
-                 (!e_client_util_ignored_get(ec2)) &&
-                 (ec2->visible) &&
-                 (ec2->frame))
-               return ec2;
-          }
-     }
-   return NULL;
-}
-
-static E_Client *
-_e_policy_client_find_below(const E_Client *ec)
-{
-   unsigned int x;
-   E_Client *ec2;
-   Eina_Inlist *l;
-
-   E_OBJECT_CHECK_RETURN(ec, NULL);
-   E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, NULL);
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
-   if (EINA_INLIST_GET(ec)->prev) //check current layer
-     {
-        for (l = EINA_INLIST_GET(ec)->prev; l; l = l->prev)
-          {
-             ec2 = EINA_INLIST_CONTAINER_GET(l, E_Client);
-             if ((!e_object_is_del(E_OBJECT(ec2))) &&
-                 (!e_client_util_ignored_get(ec2)) &&
-                 (ec2->visible) &&
-                 (ec2->frame))
-               return ec2;
-          }
-     }
-
-   /* go down the layers until we find one */
-   if (e_comp_canvas_layer_map(ec->layer) > e_comp_canvas_layer_map(E_LAYER_MAX)) return NULL;
-   x = e_comp_canvas_layer_map(ec->layer);
-   if (x > 0) x--;
-
-   for (; x >= e_comp_canvas_layer_map(E_LAYER_CLIENT_DESKTOP); x--)
-     {
-        if (!e_comp->layers[x].clients) continue;
-        EINA_INLIST_REVERSE_FOREACH(e_comp->layers[x].clients, ec2)
-          {
-             if (ec2 == ec) continue;
-             if ((!e_object_is_del(E_OBJECT(ec2))) &&
-                 (!e_client_util_ignored_get(ec2)) &&
-                 (ec2->visible) &&
-                 (ec2->frame))
-               return ec2;
-          }
-     }
-   return NULL;
-}
-
 static void
 _e_policy_client_stack_change_send(E_Client *ec)
 {
@@ -1262,8 +1179,8 @@ _e_policy_client_stack_change_send(E_Client *ec)
    int above_pid = -1;
    int below_pid = -1;
 
-   above = _e_policy_client_find_above(ec);
-   below = _e_policy_client_find_below(ec);
+   above = e_client_visible_above_get(ec);
+   below = e_client_visible_below_get(ec);
 
    if (above) above_pid = above->netwm.pid;
    if (below) below_pid = below->netwm.pid;