Avoid lists of tag/client pairs, use an array per tag.
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
1f4e55e432
commit
f84e66ddc6
14
structs.h
14
structs.h
|
@ -318,6 +318,7 @@ struct client_t
|
|||
/** Next and previous clients */
|
||||
client_t *prev, *next;
|
||||
};
|
||||
DO_ARRAY(client_t *, client, DO_NOTHING);
|
||||
|
||||
struct client_node_t
|
||||
{
|
||||
|
@ -346,18 +347,11 @@ struct _tag_t
|
|||
int nmaster;
|
||||
/** Number of columns in tile layout */
|
||||
int ncol;
|
||||
/** clients in this tag */
|
||||
client_array_t clients;
|
||||
};
|
||||
ARRAY_TYPE(tag_t *, tag);
|
||||
|
||||
/** Tag client link type */
|
||||
struct tag_client_node_t
|
||||
{
|
||||
tag_t *tag;
|
||||
client_t *client;
|
||||
/** Next and previous tag_client_nodes */
|
||||
tag_client_node_t *prev, *next;
|
||||
};
|
||||
|
||||
/** Padding type */
|
||||
typedef struct
|
||||
{
|
||||
|
@ -431,8 +425,6 @@ struct awesome_t
|
|||
client_node_t *focus;
|
||||
/** Stack client history */
|
||||
client_node_t *stack;
|
||||
/** Link between tags and clients */
|
||||
tag_client_node_t *tclink;
|
||||
/** Command line passed to awesome */
|
||||
char *argv;
|
||||
/** Last XMotionEvent coords */
|
||||
|
|
30
tag.c
30
tag.c
|
@ -109,17 +109,11 @@ tag_append_to_screen(tag_t *tag, int screen)
|
|||
void
|
||||
tag_client(client_t *c, tag_t *t)
|
||||
{
|
||||
tag_client_node_t *tc;
|
||||
|
||||
/* don't tag twice */
|
||||
if(is_client_tagged(c, t))
|
||||
return;
|
||||
|
||||
tc = p_new(tag_client_node_t, 1);
|
||||
tc->client = c;
|
||||
tc->tag = t;
|
||||
tag_client_node_list_push(&globalconf.tclink, tc);
|
||||
|
||||
client_array_append(&t->clients, c);
|
||||
client_saveprops(c);
|
||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||
globalconf.screens[c->screen].need_arrange = true;
|
||||
|
@ -132,17 +126,14 @@ tag_client(client_t *c, tag_t *t)
|
|||
void
|
||||
untag_client(client_t *c, tag_t *t)
|
||||
{
|
||||
tag_client_node_t *tc;
|
||||
|
||||
for(tc = globalconf.tclink; tc; tc = tc->next)
|
||||
if(tc->client == c && tc->tag == t)
|
||||
for(int i = 0; i < t->clients.len; i++)
|
||||
if(t->clients.tab[i] == c)
|
||||
{
|
||||
tag_client_node_list_detach(&globalconf.tclink, tc);
|
||||
p_delete(&tc);
|
||||
client_array_take(&t->clients, i);
|
||||
client_saveprops(c);
|
||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||
globalconf.screens[c->screen].need_arrange = True;
|
||||
break;
|
||||
globalconf.screens[c->screen].need_arrange = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,13 +145,8 @@ untag_client(client_t *c, tag_t *t)
|
|||
bool
|
||||
is_client_tagged(client_t *c, tag_t *t)
|
||||
{
|
||||
tag_client_node_t *tc;
|
||||
|
||||
if(!c)
|
||||
return false;
|
||||
|
||||
for(tc = globalconf.tclink; tc; tc = tc->next)
|
||||
if(tc->client == c && tc->tag == t)
|
||||
for(int i = 0; i < t->clients.len; i++)
|
||||
if (t->clients.tab[i] == c)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
3
tag.h
3
tag.h
|
@ -34,6 +34,7 @@ tag_t *tag_new(const char *, layout_t *, double, int, int);
|
|||
static inline void
|
||||
tag_delete(tag_t **tag)
|
||||
{
|
||||
client_array_wipe(&(*tag)->clients);
|
||||
p_delete(&(*tag)->name);
|
||||
p_delete(tag);
|
||||
}
|
||||
|
@ -50,7 +51,5 @@ int luaA_tag_userdata_new(lua_State *, tag_t *);
|
|||
DO_RCNT(tag_t, tag, tag_delete)
|
||||
ARRAY_FUNCS(tag_t *, tag, tag_unref);
|
||||
|
||||
DO_SLIST(tag_client_node_t, tag_client_node, p_delete)
|
||||
|
||||
#endif
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
Loading…
Reference in New Issue