e_client: refactor e_client_focus_calculate function 38/296738/2
authorJunseok Kim <juns.kim@samsung.com>
Wed, 2 Aug 2023 09:21:16 +0000 (18:21 +0900)
committerJunSeok Kim <juns.kim@samsung.com>
Fri, 4 Aug 2023 00:36:25 +0000 (00:36 +0000)
Change-Id: I5c04b0c0c8418eab7b0b409fd5d268437479b32d

src/bin/e_client.c

index 432b146..c1a5db5 100644 (file)
@@ -3730,48 +3730,15 @@ end:
    return;
 }
 
-EINTERN void
-e_client_focus_calculate(E_Zone *zone)
+static E_Client *
+_e_client_candidate_focus(E_Zone *zone, E_Client *reverted_focus_ec)
 {
-   E_Client *defered_focus_ec = NULL, *reverted_focus_ec = NULL;
-   E_Client *ec = NULL, *old_focused = NULL, *cec = NULL;
+   E_Client *ec, *cec;
+   E_Client *defered_focus_ec = NULL;
    Eina_List *child_list = NULL;
    Eina_List *l = NULL;
    Eina_Bool child_deferred;
 
-   EINA_SAFETY_ON_NULL_RETURN(zone);
-   if (!e_zone_is_displaying(zone)) return;
-
-   if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK)
-     {
-        ec = _e_client_focus_topmost_focusable_get();
-
-        if (ec != focused)
-          {
-             if (!ec) ELOGF("FOCUS", "focus unset | No focusable ec", focused);
-             e_client_frame_focus_set(focused, EINA_FALSE);
-
-             if (ec)
-               {
-                  ELOGF("FOCUS", "focus set | topmost focus calculate", ec);
-                  e_client_frame_focus_set(ec, EINA_TRUE);
-               }
-          }
-        return;
-     }
-
-   if ((!focused) ||
-       (focused != eina_list_data_get(focus_stack)) ||
-       (!_e_client_focus_can_take(focused)))
-     {
-        reverted_focus_ec = _e_client_revert_focus_get(focused);
-        if (!reverted_focus_ec && focused)
-          {
-             e_client_focus_defer_unset(focused);
-             old_focused = focused;
-          }
-     }
-
    E_CLIENT_REVERSE_FOREACH(ec)
      {
         if (!eina_list_data_find(defer_focus_stack, ec)) continue;
@@ -3817,6 +3784,49 @@ e_client_focus_calculate(E_Zone *zone)
         defered_focus_ec = ec;
         break;
      }
+   return defered_focus_ec;
+}
+
+EINTERN void
+e_client_focus_calculate(E_Zone *zone)
+{
+   E_Client *defered_focus_ec = NULL, *reverted_focus_ec = NULL;
+   E_Client *ec = NULL, *old_focused = NULL;
+
+   EINA_SAFETY_ON_NULL_RETURN(zone);
+   if (!e_zone_is_displaying(zone)) return;
+
+   if (e_config->focus_policy_ext == E_FOCUS_EXT_TOP_STACK)
+     {
+        ec = _e_client_focus_topmost_focusable_get();
+
+        if (ec != focused)
+          {
+             if (!ec) ELOGF("FOCUS", "focus unset | No focusable ec", focused);
+             e_client_frame_focus_set(focused, EINA_FALSE);
+
+             if (ec)
+               {
+                  ELOGF("FOCUS", "focus set | topmost focus calculate", ec);
+                  e_client_frame_focus_set(ec, EINA_TRUE);
+               }
+          }
+        return;
+     }
+
+   if ((!focused) ||
+       (focused != eina_list_data_get(focus_stack)) ||
+       (!_e_client_focus_can_take(focused)))
+     {
+        reverted_focus_ec = _e_client_revert_focus_get(focused);
+        if (!reverted_focus_ec && focused)
+          {
+             e_client_focus_defer_unset(focused);
+             old_focused = focused;
+          }
+     }
+
+   defered_focus_ec = _e_client_candidate_focus(zone, reverted_focus_ec);
 
    if (defered_focus_ec)
      {