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.
This commit is contained in:
Marcel Hollerbach 2022-01-06 20:57:38 +01:00
parent e2e1b1956d
commit 2d86d75139
2 changed files with 8 additions and 7 deletions

View File

@ -400,8 +400,8 @@ _e_client_mouse_action_end(E_Client *ec)
E_FREE_FUNC(ec->cur_mouse_action, e_object_unref); E_FREE_FUNC(ec->cur_mouse_action, e_object_unref);
} }
static void E_API void
_e_client_revert_focus(E_Client *ec) e_client_revert_focus(E_Client *ec)
{ {
E_Client *pec; E_Client *pec;
E_Desk *desk; E_Desk *desk;
@ -644,7 +644,7 @@ _e_client_del(E_Client *ec)
evas_object_hide(ec->internal_elm_win); evas_object_hide(ec->internal_elm_win);
if (ec->focused) if (ec->focused)
_e_client_revert_focus(ec); e_client_revert_focus(ec);
if (ec->frame) evas_object_focus_set(ec->frame, 0); if (ec->frame) evas_object_focus_set(ec->frame, 0);
E_FREE_FUNC(ec->ping_poller, ecore_poller_del); 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->hidden)
{ {
if (ec->focused) if (ec->focused)
_e_client_revert_focus(ec); e_client_revert_focus(ec);
} }
ec->want_focus = ec->take_focus = 0; ec->want_focus = ec->take_focus = 0;
@ -4642,7 +4642,7 @@ e_client_iconify(E_Client *ec)
{ {
if (!ec->new_client) if (!ec->new_client)
{ {
_e_client_revert_focus(ec); e_client_revert_focus(ec);
evas_object_hide(ec->frame); evas_object_hide(ec->frame);
} }
e_client_urgent_set(ec, ec->icccm.urgent); e_client_urgent_set(ec, ec->icccm.urgent);

View File

@ -1877,8 +1877,9 @@ _e_comp_intercept_focus(void *data, Evas_Object *obj, Eina_Bool focus)
} }
else else
{ {
if (e_client_focused_get() == ec) if (e_client_focused_get() == ec) {
e_client_focused_set(NULL); e_client_revert_focus(ec);
}
} }
evas_object_focus_set(obj, focus); evas_object_focus_set(obj, focus);
} }