From 2d86d75139c40e7365e34880b0e3b56f248b0e41 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Thu, 6 Jan 2022 20:57:38 +0100 Subject: e_client: revert focus instead of setting it to NULL When closing a client a few different things can happen: 1. Client hides, this will destroy the e_client object, which will reverts focus to another client. 2. Client hook del, this will recover focus to the root window if no e_client is focused. 3. Client unfocus event, setted the focused to NULL and sets the focus field to 0. when first 1 happens then 2 or 3 everything is fine. However, it seems that sometimes first 3 happend, then 2, then 1. Which results in focus beeing first NULL, then recovered to the root window, resulting in the wrong things happening. --- src/bin/e_client.c | 10 +++++----- src/bin/e_comp_object.c | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/bin/e_client.c b/src/bin/e_client.c index 6e605a3393..85f5504a73 100644 --- a/src/bin/e_client.c +++ b/src/bin/e_client.c @@ -400,8 +400,8 @@ _e_client_mouse_action_end(E_Client *ec) E_FREE_FUNC(ec->cur_mouse_action, e_object_unref); } -static void -_e_client_revert_focus(E_Client *ec) +E_API void +e_client_revert_focus(E_Client *ec) { E_Client *pec; E_Desk *desk; @@ -644,7 +644,7 @@ _e_client_del(E_Client *ec) evas_object_hide(ec->internal_elm_win); if (ec->focused) - _e_client_revert_focus(ec); + e_client_revert_focus(ec); if (ec->frame) evas_object_focus_set(ec->frame, 0); E_FREE_FUNC(ec->ping_poller, ecore_poller_del); @@ -1560,7 +1560,7 @@ _e_client_cb_evas_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UN if (!ec->hidden) { if (ec->focused) - _e_client_revert_focus(ec); + e_client_revert_focus(ec); } ec->want_focus = ec->take_focus = 0; @@ -4642,7 +4642,7 @@ e_client_iconify(E_Client *ec) { if (!ec->new_client) { - _e_client_revert_focus(ec); + e_client_revert_focus(ec); evas_object_hide(ec->frame); } e_client_urgent_set(ec, ec->icccm.urgent); diff --git a/src/bin/e_comp_object.c b/src/bin/e_comp_object.c index 04b0bd3301..77720aa19c 100644 --- a/src/bin/e_comp_object.c +++ b/src/bin/e_comp_object.c @@ -1877,8 +1877,9 @@ _e_comp_intercept_focus(void *data, Evas_Object *obj, Eina_Bool focus) } else { - if (e_client_focused_get() == ec) - e_client_focused_set(NULL); + if (e_client_focused_get() == ec) { + e_client_revert_focus(ec); + } } evas_object_focus_set(obj, focus); } -- cgit v1.2.1