move elemupdate flag in scr33n struct

This commit is contained in:
Martin Duquesnoy 2011-08-30 15:15:37 +02:00
parent 434666421e
commit f2d67a8ace
4 changed files with 47 additions and 36 deletions

View File

@ -3,6 +3,8 @@
* For license, see COPYING. * For license, see COPYING.
*/ */
#include <math.h>
#include "wmfs.h" #include "wmfs.h"
#include "draw.h" #include "draw.h"
#include "infobar.h" #include "infobar.h"
@ -10,9 +12,6 @@
#include "util.h" #include "util.h"
#include "tag.h" #include "tag.h"
#define INFOBAR_DEF_W (14)
#define ELEM_TAG_BORDER (1)
static void infobar_elem_tag_init(Element *e); static void infobar_elem_tag_init(Element *e);
static void infobar_elem_tag_update(Element *e); static void infobar_elem_tag_update(Element *e);
@ -32,17 +31,6 @@ const struct elem_funcs
{ '\0', NULL, NULL } { '\0', NULL, NULL }
}; };
/* Basic placement of elements */
static inline void
infobar_elem_placement(Element *e)
{
Element *p = TAILQ_PREV(e, esub, next);
e->geo.y = e->geo.w = 0;
e->geo.h = e->infobar->geo.h;
e->geo.x = (p ? p->geo.x + p->geo.w + PAD : 0);
}
static void static void
infobar_elem_tag_init(Element *e) infobar_elem_tag_init(Element *e)
{ {
@ -160,10 +148,8 @@ infobar_elem_update(Infobar *i)
Element *e; Element *e;
TAILQ_FOREACH(e, &i->elements, next) TAILQ_FOREACH(e, &i->elements, next)
if(i->elemupdate & FLAGINT(e->type)) if(i->screen->elemupdate & FLAGINT(e->type))
e->func_update(e); e->func_update(e);
i->elemupdate = 0;
} }
void void
@ -181,16 +167,6 @@ infobar_elem_remove(Element *e)
} }
} }
static inline void
infobar_placement(Infobar *i)
{
Infobar *h = SLIST_FIRST(&i->screen->infobars);
i->geo = i->screen->geo;
i->geo.h = INFOBAR_DEF_W;
i->geo.y += (h ? h->geo.y + h->geo.h : i->screen->geo.y);
}
Infobar* Infobar*
infobar_new(Scr33n *s, const char *elem) infobar_new(Scr33n *s, const char *elem)
{ {
@ -201,9 +177,8 @@ infobar_new(Scr33n *s, const char *elem)
i->screen = s; i->screen = s;
i->elemorder = xstrdup(elem); i->elemorder = xstrdup(elem);
/* Active all flag for first refresh */ /* Active all flags for first refresh */
/* TODO: Find something else */ s->elemupdate |= (1<<0) | (1<<1) /*pow(ElemLast, 2) - 1*/;
for(n = 0; n < ElemLast; i->elemupdate |= FLAGINT(n++));
/* TODO: Position top/bottom */ /* TODO: Position top/bottom */
infobar_placement(i); infobar_placement(i);

View File

@ -7,6 +7,11 @@
#define INFOBAR_H #define INFOBAR_H
#include "wmfs.h" #include "wmfs.h"
#include "util.h"
#include "draw.h"
#define INFOBAR_DEF_W (14)
#define ELEM_TAG_BORDER (1)
enum { ElemTag = 0, ElemLayout, ElemSelbar, ElemStatus, ElemCustom, ElemLast }; enum { ElemTag = 0, ElemLayout, ElemSelbar, ElemStatus, ElemCustom, ElemLast };
@ -16,4 +21,38 @@ void infobar_refresh(Infobar *i);
void infobar_remove(Infobar *i); void infobar_remove(Infobar *i);
void infobar_free(Scr33n *s); void infobar_free(Scr33n *s);
/* Basic placement of elements */
static inline void
infobar_elem_placement(Element *e)
{
Element *p = TAILQ_PREV(e, esub, next);
e->geo.y = e->geo.w = 0;
e->geo.h = e->infobar->geo.h;
e->geo.x = (p ? p->geo.x + p->geo.w + PAD : 0);
}
static inline void
infobar_placement(Infobar *i)
{
Infobar *h = SLIST_FIRST(&i->screen->infobars);
i->geo = i->screen->geo;
i->geo.h = INFOBAR_DEF_W;
i->geo.y += (h ? h->geo.y + h->geo.h : i->screen->geo.y);
}
static inline void
infobar_elem_screen_update(Scr33n *s, int addf)
{
Infobar *i;
s->elemupdate |= FLAGINT(addf);
SLIST_FOREACH(i, &s->infobars, next)
infobar_elem_update(i);
s->elemupdate &= ~FLAGINT(addf);
}
#endif /* INFOBAR_H */ #endif /* INFOBAR_H */

View File

@ -31,13 +31,10 @@ tag_screen(Scr33n *s, Tag *t)
s->seltag = t; s->seltag = t;
SLIST_FOREACH(i, &s->infobars, next) infobar_elem_screen_update(s, ElemTag);
{
i->elemupdate |= FLAGINT(ElemTag);
infobar_elem_update(i);
}
} }
void void
uicb_tag_set(Uicb cmd) uicb_tag_set(Uicb cmd)
{ {

View File

@ -82,7 +82,6 @@ struct Infobar
Geo geo; Geo geo;
Scr33n *screen; Scr33n *screen;
char *elemorder; char *elemorder;
Flags elemupdate;
TAILQ_HEAD(esub, Element) elements; TAILQ_HEAD(esub, Element) elements;
SLIST_ENTRY(Infobar) next; SLIST_ENTRY(Infobar) next;
}; };
@ -93,6 +92,7 @@ struct Scr33n
Geo geo; Geo geo;
Tag *seltag; Tag *seltag;
int id; int id;
Flags elemupdate;
TAILQ_HEAD(tsub, Tag) tags; TAILQ_HEAD(tsub, Tag) tags;
SLIST_HEAD(, Infobar) infobars; SLIST_HEAD(, Infobar) infobars;
SLIST_ENTRY(Scr33n) next; SLIST_ENTRY(Scr33n) next;