tag: make struct tag private

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-07-29 17:38:48 +02:00
parent 376c0daaaf
commit 0eb0c49592
5 changed files with 34 additions and 21 deletions

View File

@ -105,7 +105,7 @@ client_maybevisible(client_t *c, screen_t *screen)
return true;
foreach(tag, screen->tags)
if((*tag)->selected && is_client_tagged(c, *tag))
if(tag_get_selected(*tag) && is_client_tagged(c, *tag))
return true;
}
return false;

5
ewmh.c
View File

@ -197,14 +197,13 @@ ewmh_update_net_current_desktop(int phys_screen)
void
ewmh_update_net_desktop_names(int phys_screen)
{
tag_array_t *tags = &globalconf.screens.tab[phys_screen].tags;
buffer_t buf;
buffer_inita(&buf, BUFSIZ);
for(int i = 0; i < tags->len; i++)
foreach(tag, globalconf.screens.tab[phys_screen].tags)
{
buffer_adds(&buf, tags->tab[i]->name);
buffer_adds(&buf, tag_get_name(*tag));
buffer_addc(&buf, '\0');
}

View File

@ -274,7 +274,7 @@ screen_client_moveto(client_t *c, screen_t *new_screen, bool dotag, bool doresiz
if(!c->issticky)
/* add new tags */
foreach(new_tag, new_screen->tags)
if((*new_tag)->selected)
if(tag_get_selected(*new_tag))
{
luaA_object_push(globalconf.L, *new_tag);
tag_client(c);
@ -383,8 +383,8 @@ luaA_screen_tags(lua_State *L)
luaA_checktable(L, 2);
/* remove current tags */
for(i = 0; i < s->tags.len; i++)
s->tags.tab[i]->screen = NULL;
foreach(tag, s->tags)
tag_set_screen(*tag, NULL);
tag_array_wipe(&s->tags);
tag_array_init(&s->tags);

24
tag.c
View File

@ -25,9 +25,24 @@
#include "ewmh.h"
#include "widget.h"
/** Tag type */
struct tag
{
LUA_OBJECT_HEADER
/** Tag name */
char *name;
/** Screen */
screen_t *screen;
/** true if selected */
bool selected;
/** clients in this tag */
client_array_t clients;
};
static lua_class_t tag_class;
LUA_OBJECT_FUNCS(tag_class, tag_t, tag)
void
tag_unref_simplified(tag_t **tag)
{
@ -47,6 +62,15 @@ luaA_tag_gc(lua_State *L)
return luaA_object_gc(L);
}
OBJECT_EXPORT_PROPERTY(tag, tag_t, selected)
OBJECT_EXPORT_PROPERTY(tag, tag_t, name)
void
tag_set_screen(tag_t *tag, screen_t *s)
{
tag->screen = s;
}
/** View or unview a tag.
* \param L The Lua VM state.
* \param udx The index of the tag on the stack.

18
tag.h
View File

@ -24,20 +24,6 @@
#include "client.h"
/** Tag type */
struct tag
{
LUA_OBJECT_HEADER
/** Tag name */
char *name;
/** Screen */
screen_t *screen;
/** true if selected */
bool selected;
/** clients in this tag */
client_array_t clients;
};
int tags_get_first_selected_index(screen_t *);
void tag_client(client_t *);
void untag_client(client_t *, tag_t *);
@ -50,5 +36,9 @@ ARRAY_FUNCS(tag_t *, tag, tag_unref_simplified)
void tag_class_setup(lua_State *);
bool tag_get_selected(tag_t *);
char *tag_get_name(tag_t *);
void tag_set_screen(tag_t *, screen_t *);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80