Focus stealing prevention - should fix FS#497

We should prevent focus stealing, in case when there are e.g. 2 clients
on separate tags, first client has focus, and we receive FocusIn event
for second (invisible) client.

This patch adds prevention in the focus update handler. It sets focus
on previously focused client, when FocusIn event destination is
invisible(untagged) client.

This should fix FS#497.

Signed-off-by: Mariusz Ceier <mceier@gmail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Mariusz Ceier 2009-04-23 18:05:30 +02:00 committed by Julien Danjou
parent a91e31dbe6
commit e8de7a4605
2 changed files with 13 additions and 0 deletions

View File

@ -217,6 +217,9 @@ client_ban(client_t *c)
if(client_hasstrut(c)) if(client_hasstrut(c))
wibox_update_positions(); wibox_update_positions();
if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
/* Wait until the last moment to take away the focus from the window. */ /* Wait until the last moment to take away the focus from the window. */
if(globalconf.screens.tab[c->phys_screen].client_focus == c) if(globalconf.screens.tab[c->phys_screen].client_focus == c)
client_unfocus(c); client_unfocus(c);
@ -230,7 +233,11 @@ void
client_focus_update(client_t *c) client_focus_update(client_t *c)
{ {
if(!client_maybevisible(c, c->screen)) if(!client_maybevisible(c, c->screen))
{
/* Focus previously focused client */
client_focus(globalconf.screen_focus->prev_client_focus);
return; return;
}
/* stop hiding client */ /* stop hiding client */
c->ishidden = false; c->ishidden = false;
@ -240,6 +247,7 @@ client_focus_update(client_t *c)
client_unban(c); client_unban(c);
globalconf.screen_focus = &globalconf.screens.tab[c->phys_screen]; globalconf.screen_focus = &globalconf.screens.tab[c->phys_screen];
globalconf.screen_focus->prev_client_focus = c;
globalconf.screen_focus->client_focus = c; globalconf.screen_focus->client_focus = c;
/* Some layouts use focused client differently, so call them back. /* Some layouts use focused client differently, so call them back.
@ -1224,6 +1232,9 @@ client_unmanage(client_t *c)
tc->transient_for = NULL; tc->transient_for = NULL;
} }
if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
if(globalconf.screens.tab[c->phys_screen].client_focus == c) if(globalconf.screens.tab[c->phys_screen].client_focus == c)
client_unfocus(c); client_unfocus(c);

View File

@ -43,6 +43,8 @@ struct a_screen
/** Systray window parent */ /** Systray window parent */
xcb_window_t parent; xcb_window_t parent;
} systray; } systray;
/** Previously focused client */
client_t *prev_client_focus;
/** Focused client */ /** Focused client */
client_t *client_focus; client_t *client_focus;
/** The monitor of startup notifications */ /** The monitor of startup notifications */