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 */
|
/** Next and previous clients */
|
||||||
client_t *prev, *next;
|
client_t *prev, *next;
|
||||||
};
|
};
|
||||||
|
DO_ARRAY(client_t *, client, DO_NOTHING);
|
||||||
|
|
||||||
struct client_node_t
|
struct client_node_t
|
||||||
{
|
{
|
||||||
|
@ -346,18 +347,11 @@ struct _tag_t
|
||||||
int nmaster;
|
int nmaster;
|
||||||
/** Number of columns in tile layout */
|
/** Number of columns in tile layout */
|
||||||
int ncol;
|
int ncol;
|
||||||
|
/** clients in this tag */
|
||||||
|
client_array_t clients;
|
||||||
};
|
};
|
||||||
ARRAY_TYPE(tag_t *, tag);
|
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 */
|
/** Padding type */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -431,8 +425,6 @@ struct awesome_t
|
||||||
client_node_t *focus;
|
client_node_t *focus;
|
||||||
/** Stack client history */
|
/** Stack client history */
|
||||||
client_node_t *stack;
|
client_node_t *stack;
|
||||||
/** Link between tags and clients */
|
|
||||||
tag_client_node_t *tclink;
|
|
||||||
/** Command line passed to awesome */
|
/** Command line passed to awesome */
|
||||||
char *argv;
|
char *argv;
|
||||||
/** Last XMotionEvent coords */
|
/** Last XMotionEvent coords */
|
||||||
|
|
30
tag.c
30
tag.c
|
@ -109,17 +109,11 @@ tag_append_to_screen(tag_t *tag, int screen)
|
||||||
void
|
void
|
||||||
tag_client(client_t *c, tag_t *t)
|
tag_client(client_t *c, tag_t *t)
|
||||||
{
|
{
|
||||||
tag_client_node_t *tc;
|
|
||||||
|
|
||||||
/* don't tag twice */
|
/* don't tag twice */
|
||||||
if(is_client_tagged(c, t))
|
if(is_client_tagged(c, t))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tc = p_new(tag_client_node_t, 1);
|
client_array_append(&t->clients, c);
|
||||||
tc->client = c;
|
|
||||||
tc->tag = t;
|
|
||||||
tag_client_node_list_push(&globalconf.tclink, tc);
|
|
||||||
|
|
||||||
client_saveprops(c);
|
client_saveprops(c);
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
globalconf.screens[c->screen].need_arrange = true;
|
globalconf.screens[c->screen].need_arrange = true;
|
||||||
|
@ -132,17 +126,14 @@ tag_client(client_t *c, tag_t *t)
|
||||||
void
|
void
|
||||||
untag_client(client_t *c, tag_t *t)
|
untag_client(client_t *c, tag_t *t)
|
||||||
{
|
{
|
||||||
tag_client_node_t *tc;
|
for(int i = 0; i < t->clients.len; i++)
|
||||||
|
if(t->clients.tab[i] == c)
|
||||||
for(tc = globalconf.tclink; tc; tc = tc->next)
|
|
||||||
if(tc->client == c && tc->tag == t)
|
|
||||||
{
|
{
|
||||||
tag_client_node_list_detach(&globalconf.tclink, tc);
|
client_array_take(&t->clients, i);
|
||||||
p_delete(&tc);
|
|
||||||
client_saveprops(c);
|
client_saveprops(c);
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
globalconf.screens[c->screen].need_arrange = True;
|
globalconf.screens[c->screen].need_arrange = true;
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,13 +145,8 @@ untag_client(client_t *c, tag_t *t)
|
||||||
bool
|
bool
|
||||||
is_client_tagged(client_t *c, tag_t *t)
|
is_client_tagged(client_t *c, tag_t *t)
|
||||||
{
|
{
|
||||||
tag_client_node_t *tc;
|
for(int i = 0; i < t->clients.len; i++)
|
||||||
|
if (t->clients.tab[i] == c)
|
||||||
if(!c)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for(tc = globalconf.tclink; tc; tc = tc->next)
|
|
||||||
if(tc->client == c && tc->tag == t)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
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
|
static inline void
|
||||||
tag_delete(tag_t **tag)
|
tag_delete(tag_t **tag)
|
||||||
{
|
{
|
||||||
|
client_array_wipe(&(*tag)->clients);
|
||||||
p_delete(&(*tag)->name);
|
p_delete(&(*tag)->name);
|
||||||
p_delete(tag);
|
p_delete(tag);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +51,5 @@ int luaA_tag_userdata_new(lua_State *, tag_t *);
|
||||||
DO_RCNT(tag_t, tag, tag_delete)
|
DO_RCNT(tag_t, tag, tag_delete)
|
||||||
ARRAY_FUNCS(tag_t *, tag, tag_unref);
|
ARRAY_FUNCS(tag_t *, tag, tag_unref);
|
||||||
|
|
||||||
DO_SLIST(tag_client_node_t, tag_client_node, p_delete)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue