use list functions for TagClientLink

This commit is contained in:
Julien Danjou 2008-01-12 22:00:36 +01:00
parent 99e54ef971
commit 628ce3e7ad
2 changed files with 9 additions and 30 deletions

View File

@ -243,6 +243,8 @@ struct TagClientLink
TagClientLink *next; TagClientLink *next;
}; };
DO_SLIST(TagClientLink, tcl, p_delete);
/** Padding type */ /** Padding type */
typedef struct typedef struct
{ {

37
tag.c
View File

@ -32,43 +32,19 @@
extern AwesomeConf globalconf; extern AwesomeConf globalconf;
static void
detach_tagclientlink(TagClientLink *tc)
{
TagClientLink *tmp;
if(globalconf.tclink == tc)
globalconf.tclink = tc->next;
else
{
for(tmp = globalconf.tclink; tmp && tmp->next != tc; tmp = tmp->next);
tmp->next = tc->next;
}
p_delete(&tc);
}
void void
tag_client(Client *c, Tag *t) tag_client(Client *c, Tag *t)
{ {
TagClientLink *tc, *new_tc; TagClientLink *tc;
/* don't tag twice */ /* don't tag twice */
if(is_client_tagged(c, t)) if(is_client_tagged(c, t))
return; return;
new_tc = p_new(TagClientLink, 1); tc = p_new(TagClientLink, 1);
tc->client = c;
if(!globalconf.tclink) tc->tag = t;
globalconf.tclink = new_tc; tcl_list_push(&globalconf.tclink, tc);
else
{
for(tc = globalconf.tclink; tc->next; tc = tc->next);
tc->next = new_tc;
}
new_tc->client = c;
new_tc->tag = t;
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
} }
@ -81,7 +57,8 @@ untag_client(Client *c, Tag *t)
for(tc = globalconf.tclink; tc; tc = tc->next) for(tc = globalconf.tclink; tc; tc = tc->next)
if(tc->client == c && tc->tag == t) if(tc->client == c && tc->tag == t)
{ {
detach_tagclientlink(tc); tcl_list_detach(&globalconf.tclink, tc);
p_delete(&tc);
break; break;
} }