change uicb_focus_history() to use focus_get_latest_client_for_tags() which now takes an index as arg

This commit is contained in:
Julien Danjou 2007-12-28 14:27:15 +01:00
parent 4e45103537
commit 48f92f60d1
1 changed files with 17 additions and 13 deletions

24
focus.c
View File

@ -96,15 +96,22 @@ focus_delete_client(Client *c)
} }
static Client * static Client *
focus_get_latest_client_for_tags(Tag **t) focus_get_latest_client_for_tags(Tag **t, int nindex)
{ {
FocusList *fl; FocusList *fl;
Tag **tags; Tag **tags;
int i = 0;
for(fl = globalconf.focus; fl; fl = fl->prev) for(fl = globalconf.focus; fl; fl = fl->prev)
if(fl->client && !fl->client->skip)
for(tags = t; *tags; tags++) for(tags = t; *tags; tags++)
if(is_client_tagged(fl->client, *t)) if(is_client_tagged(fl->client, *t))
{
if(i == nindex)
return fl->client; return fl->client;
else
i--;
}
return NULL; return NULL;
} }
@ -113,7 +120,7 @@ Client *
focus_get_current_client(int screen) focus_get_current_client(int screen)
{ {
Tag **curtags = get_current_tags(screen); Tag **curtags = get_current_tags(screen);
Client *sel = focus_get_latest_client_for_tags(curtags); Client *sel = focus_get_latest_client_for_tags(curtags, 0);
p_delete(&curtags); p_delete(&curtags);
return sel; return sel;
@ -128,8 +135,8 @@ void
uicb_focus_history(int screen, char *arg) uicb_focus_history(int screen, char *arg)
{ {
int i; int i;
FocusList *fl = globalconf.focus; Tag **curtags;
Tag **curtags, **tag; Client *c;
if(arg) if(arg)
{ {
@ -138,13 +145,10 @@ uicb_focus_history(int screen, char *arg)
if(i < 0) if(i < 0)
{ {
curtags = get_current_tags(screen); curtags = get_current_tags(screen);
for(; fl && i < 0; fl = fl->prev) c = focus_get_latest_client_for_tags(curtags, i);
for(tag = curtags; *tag; tag++)
if(is_client_tagged(fl->client, *tag))
i++;
p_delete(&curtags); p_delete(&curtags);
if(fl) if(c)
focus(fl->client, True, screen); focus(c, True, screen);
} }
} }
} }