simplify tag_client() and untag_client() proto

This commit is contained in:
Julien Danjou 2007-12-27 22:43:59 +01:00
parent 2287c0ff7c
commit e95dc4b4cd
5 changed files with 28 additions and 28 deletions

View File

@ -63,11 +63,11 @@ client_loadprops(Client * c, int screen)
for(i = 0, tag = globalconf.screens[screen].tags; tag && i < ntags && prop[i]; i++, tag = tag->next) for(i = 0, tag = globalconf.screens[screen].tags; tag && i < ntags && prop[i]; i++, tag = tag->next)
if(prop[i] == '1') if(prop[i] == '1')
{ {
tag_client(c, tag, screen); tag_client(c, tag);
result = True; result = True;
} }
else else
untag_client(c, tag, screen); untag_client(c, tag);
if(i <= ntags && prop[i]) if(i <= ntags && prop[i])
c->isfloating = prop[i] == '1'; c->isfloating = prop[i] == '1';
@ -351,7 +351,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
&& (t = get_client_bywin(globalconf.clients, trans))) && (t = get_client_bywin(globalconf.clients, trans)))
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
if(is_client_tagged(t, tag, c->screen)) if(is_client_tagged(t, tag, c->screen))
tag_client(c, tag, c->screen); tag_client(c, tag);
/* should be floating if transsient or fixed) */ /* should be floating if transsient or fixed) */
if(!c->isfloating) if(!c->isfloating)
@ -516,7 +516,7 @@ client_unmanage(Client *c, long state)
focus(NULL, True, c->screen); focus(NULL, True, c->screen);
focus_delete_client(c); focus_delete_client(c);
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
untag_client(c, tag, c->screen); untag_client(c, tag);
XUngrabButton(c->display, AnyButton, AnyModifier, c->win); XUngrabButton(c->display, AnyButton, AnyModifier, c->win);
window_setstate(c->display, c->win, state); window_setstate(c->display, c->win, state);
XSync(c->display, False); XSync(c->display, False);

2
ewmh.c
View File

@ -203,7 +203,7 @@ ewmh_process_state_atom(Client *c, Atom state)
{ {
Tag *tag; Tag *tag;
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
tag_client(c, tag, c->screen); tag_client(c, tag);
} }
} }

View File

@ -186,7 +186,7 @@ move_client_to_screen(Client *c, int new_screen, Bool doresize)
Area from, to; Area from, to;
for(tag = globalconf.screens[old_screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[old_screen].tags; tag; tag = tag->next)
untag_client(c, tag, old_screen); untag_client(c, tag);
c->screen = new_screen; c->screen = new_screen;

40
tag.c
View File

@ -48,21 +48,21 @@ detach_tagclientlink(int screen, TagClientLink *tc)
} }
void void
tag_client(Client *c, Tag *t, int screen) tag_client(Client *c, Tag *t)
{ {
TagClientLink *tc, *new_tc; TagClientLink *tc, *new_tc;
/* don't tag twice */ /* don't tag twice */
if(is_client_tagged(c, t, screen)) if(is_client_tagged(c, t, c->screen))
return; return;
new_tc = p_new(TagClientLink, 1); new_tc = p_new(TagClientLink, 1);
if(!globalconf.screens[screen].tclink) if(!globalconf.screens[c->screen].tclink)
globalconf.screens[screen].tclink = new_tc; globalconf.screens[c->screen].tclink = new_tc;
else else
{ {
for(tc = globalconf.screens[screen].tclink; tc->next; tc = tc->next); for(tc = globalconf.screens[c->screen].tclink; tc->next; tc = tc->next);
tc->next = new_tc; tc->next = new_tc;
} }
@ -71,13 +71,13 @@ tag_client(Client *c, Tag *t, int screen)
} }
void void
untag_client(Client *c, Tag *t, int screen) untag_client(Client *c, Tag *t)
{ {
TagClientLink *tc; TagClientLink *tc;
for(tc = globalconf.screens[screen].tclink; tc; tc = tc->next) for(tc = globalconf.screens[c->screen].tclink; tc; tc = tc->next)
if(tc->client == c && tc->tag == t) if(tc->client == c && tc->tag == t)
detach_tagclientlink(screen, tc); detach_tagclientlink(c->screen, tc);
} }
Bool Bool
@ -102,9 +102,9 @@ tag_client_with_current_selected(Client *c)
for(tag = vscreen.tags; tag; tag = tag->next) for(tag = vscreen.tags; tag; tag = tag->next)
if(tag->selected) if(tag->selected)
tag_client(c, tag, c->screen); tag_client(c, tag);
else else
untag_client(c, tag, c->screen); untag_client(c, tag);
} }
void void
@ -126,10 +126,10 @@ tag_client_with_rules(Client *c)
if(is_tag_match_rules(tag, r)) if(is_tag_match_rules(tag, r))
{ {
matched = True; matched = True;
tag_client(c, tag, c->screen); tag_client(c, tag);
} }
else else
untag_client(c, tag, c->screen); untag_client(c, tag);
if(!matched) if(!matched)
tag_client_with_current_selected(c); tag_client_with_current_selected(c);
@ -183,14 +183,14 @@ uicb_client_tag(int screen, char *arg)
if(target_tag) if(target_tag)
{ {
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
untag_client(sel, tag, screen); untag_client(sel, tag);
tag_client(sel, target_tag, screen); tag_client(sel, target_tag);
} }
} }
} }
else else
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
tag_client(sel, tag, screen); tag_client(sel, tag);
client_saveprops(sel, screen); client_saveprops(sel, screen);
arrange(screen); arrange(screen);
@ -243,9 +243,9 @@ uicb_client_toggletag(int screen, char *arg)
if(target_tag) if(target_tag)
{ {
if(is_client_tagged(sel, target_tag, screen)) if(is_client_tagged(sel, target_tag, screen))
untag_client(sel, target_tag, screen); untag_client(sel, target_tag);
else else
tag_client(sel, target_tag, screen); tag_client(sel, target_tag);
} }
/* check that there's at least one tag selected for this client*/ /* check that there's at least one tag selected for this client*/
@ -253,14 +253,14 @@ uicb_client_toggletag(int screen, char *arg)
&& !is_client_tagged(sel, tag, screen); tag = tag->next) && !is_client_tagged(sel, tag, screen); tag = tag->next)
if(!tag) if(!tag)
tag_client(sel, target_tag, screen); tag_client(sel, target_tag);
} }
else else
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
if(is_client_tagged(sel, tag, screen)) if(is_client_tagged(sel, tag, screen))
tag_client(sel, tag, screen); tag_client(sel, tag);
else else
untag_client(sel, tag, screen); untag_client(sel, tag);
client_saveprops(sel, screen); client_saveprops(sel, screen);
arrange(screen); arrange(screen);

4
tag.h
View File

@ -28,8 +28,8 @@
#define IS_TILED(client, screen) (client && !client->isfloating && client_isvisible(client, screen)) #define IS_TILED(client, screen) (client && !client->isfloating && client_isvisible(client, screen))
Tag ** get_current_tags(int ); Tag ** get_current_tags(int );
void tag_client(Client *, Tag *, int); void tag_client(Client *, Tag *);
void untag_client(Client *, Tag *, int); void untag_client(Client *, Tag *);
Bool is_client_tagged(Client *, Tag *, int); Bool is_client_tagged(Client *, Tag *, int);
void tag_client_with_current_selected(Client *); void tag_client_with_current_selected(Client *);
void tag_client_with_rules(Client *); void tag_client_with_rules(Client *);