From 43b0b7b3ad8d2ea8c9c47b85c451b4be89c56d61 Mon Sep 17 00:00:00 2001 From: Junseok Kim Date: Wed, 2 Aug 2023 18:21:16 +0900 Subject: [PATCH] e_client: refactor e_client_focus_calculate function Change-Id: I5c04b0c0c8418eab7b0b409fd5d268437479b32d --- src/bin/e_client.c | 84 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/src/bin/e_client.c b/src/bin/e_client.c index 432b146..c1a5db5 100644 --- a/src/bin/e_client.c +++ b/src/bin/e_client.c @@ -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) { -- 2.7.4