e_client: refactor focus_can_take function 37/296737/2
authorJunseok Kim <juns.kim@samsung.com>
Wed, 2 Aug 2023 09:20:56 +0000 (18:20 +0900)
committerJunSeok Kim <juns.kim@samsung.com>
Fri, 4 Aug 2023 00:36:21 +0000 (00:36 +0000)
Change-Id: Ic7af3d36865265b8614df726fb22a927ed3bad39

src/bin/e_client.c

index cec8c5d..432b146 100644 (file)
@@ -847,6 +847,43 @@ _e_client_check_really_iconified(E_Client *ec)
 }
 
 static Eina_Bool
+_e_client_focus_can_take_by_vis_obscured(E_Client *ec)
+{
+   switch (ec->visibility.obscured)
+     {
+       case E_VISIBILITY_UNKNOWN:
+           if (_e_client_check_really_iconified(ec))
+             return EINA_FALSE;
+
+           if (!evas_object_visible_get(ec->frame) &&
+               !eina_list_data_find(defer_focus_stack, ec))
+             return EINA_FALSE;
+           break;
+
+       case E_VISIBILITY_FULLY_OBSCURED:
+           if (_e_client_check_really_iconified(ec))
+             return EINA_FALSE;
+
+           if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK)
+             {
+                if (!evas_object_visible_get(ec->frame))
+                  {
+                     ELOGF("FOCUS", "client is hidden, skip focus", ec);
+                     return EINA_FALSE;
+                  }
+             }
+           break;
+
+       case E_VISIBILITY_UNOBSCURED:
+       case E_VISIBILITY_PARTIALLY_OBSCURED:
+       case E_VISIBILITY_PRE_UNOBSCURED:
+       default:
+           break;
+     }
+   return EINA_TRUE;
+}
+
+static Eina_Bool
 _e_client_focus_can_take(E_Client *ec)
 {
    E_Zone *zone = NULL;
@@ -857,65 +894,40 @@ _e_client_focus_can_take(E_Client *ec)
    if (!ec) return EINA_FALSE;
    if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
    if (e_client_util_ignored_get(ec)) return EINA_FALSE;
+
    if (!(ec->icccm.accepts_focus || ec->icccm.take_focus)) return EINA_FALSE;
    if (ec->lock_focus_in || ec->lock_focus_out) return EINA_FALSE;
+
    if (!ec->visible) return EINA_FALSE;
    if (ec->bg_state) return EINA_FALSE;
    if (ec->visibility.force_obscured) return EINA_FALSE;
-   if (ec->visibility.obscured != E_VISIBILITY_UNOBSCURED)
-     {
-        if (_e_client_check_really_iconified(ec))
-          return EINA_FALSE;
-
-        if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK)
-          {
-             if ((ec->visibility.obscured == E_VISIBILITY_FULLY_OBSCURED) &&
-                !evas_object_visible_get(ec->frame))
-               {
-                  ELOGF("FOCUS", "client is hidden, skip focus", ec);
-                  return EINA_FALSE;
-               }
-          }
+   if (!_e_client_focus_can_take_by_vis_obscured(ec)) return EINA_FALSE;
 
-        if (ec->visibility.obscured == E_VISIBILITY_UNKNOWN)
-          {
-             if (!evas_object_visible_get(ec->frame) &&
-                 !eina_list_data_find(defer_focus_stack, ec))
-               return EINA_FALSE;
-          }
-     }
    zone = ec->zone;
    if (zone)
      {
         e_client_geometry_get(ec, &x, &y, &w, &h);
         if (!E_INTERSECTS(zone->x, zone->y, zone->w, zone->h, x, y, w, h))
-          {
-             return EINA_FALSE;
-          }
+          return EINA_FALSE;
      }
 
    above_ec = _e_client_check_fully_contain_by_above(ec, EINA_FALSE);
-   if (!above_ec) return EINA_TRUE;
-
-   if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK)
+   if (above_ec)
      {
-        if (!evas_object_visible_get(above_ec->frame))
-          return EINA_TRUE;
-     }
-
-   child_ec = _e_client_check_obscured_by_children_group(ec);
-   if (!child_ec) return EINA_FALSE;
+        if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK)
+          {
+             if (!evas_object_visible_get(above_ec->frame))
+               return EINA_TRUE;
+          }
 
-   if (above_ec != child_ec)
-     return EINA_FALSE;
+        child_ec = _e_client_check_obscured_by_children_group(ec);
+        if (!child_ec) return EINA_FALSE;
+        if (above_ec != child_ec) return EINA_FALSE;
 
-   if (_e_client_focus_can_take(child_ec))
-     {
-        return EINA_FALSE;
-     }
-   else if (_e_client_check_fully_contain_by_above(child_ec, EINA_FALSE))
-     {
-        return EINA_FALSE;
+        if (_e_client_focus_can_take(child_ec))
+          return EINA_FALSE;
+        else if (_e_client_check_fully_contain_by_above(child_ec, EINA_FALSE))
+          return EINA_FALSE;
      }
 
    return EINA_TRUE;