From 1f7f9a417d6c2cb73b1aef0c6b655a432ec9c358 Mon Sep 17 00:00:00 2001 From: Junseok Kim Date: Wed, 2 Aug 2023 18:20:56 +0900 Subject: [PATCH] e_client: refactor focus_can_take function Change-Id: Ic7af3d36865265b8614df726fb22a927ed3bad39 --- src/bin/e_client.c | 96 ++++++++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 42 deletions(-) diff --git a/src/bin/e_client.c b/src/bin/e_client.c index cec8c5da8a..432b146341 100644 --- a/src/bin/e_client.c +++ b/src/bin/e_client.c @@ -846,6 +846,43 @@ _e_client_check_really_iconified(E_Client *ec) return EINA_FALSE; } +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) { @@ -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; -- 2.34.1