From f2d67a8aceceaecb0b9b35d33dda9d5ed75e96c8 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Tue, 30 Aug 2011 15:15:37 +0200 Subject: [PATCH] move elemupdate flag in scr33n struct --- wmfs2/src/infobar.c | 35 +++++------------------------------ wmfs2/src/infobar.h | 39 +++++++++++++++++++++++++++++++++++++++ wmfs2/src/tag.c | 7 ++----- wmfs2/src/wmfs.h | 2 +- 4 files changed, 47 insertions(+), 36 deletions(-) diff --git a/wmfs2/src/infobar.c b/wmfs2/src/infobar.c index ec74c9d..d31338e 100755 --- a/wmfs2/src/infobar.c +++ b/wmfs2/src/infobar.c @@ -3,6 +3,8 @@ * For license, see COPYING. */ +#include + #include "wmfs.h" #include "draw.h" #include "infobar.h" @@ -10,9 +12,6 @@ #include "util.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_update(Element *e); @@ -32,17 +31,6 @@ const struct elem_funcs { '\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 infobar_elem_tag_init(Element *e) { @@ -160,10 +148,8 @@ infobar_elem_update(Infobar *i) Element *e; TAILQ_FOREACH(e, &i->elements, next) - if(i->elemupdate & FLAGINT(e->type)) + if(i->screen->elemupdate & FLAGINT(e->type)) e->func_update(e); - - i->elemupdate = 0; } 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_new(Scr33n *s, const char *elem) { @@ -201,9 +177,8 @@ infobar_new(Scr33n *s, const char *elem) i->screen = s; i->elemorder = xstrdup(elem); - /* Active all flag for first refresh */ - /* TODO: Find something else */ - for(n = 0; n < ElemLast; i->elemupdate |= FLAGINT(n++)); + /* Active all flags for first refresh */ + s->elemupdate |= (1<<0) | (1<<1) /*pow(ElemLast, 2) - 1*/; /* TODO: Position top/bottom */ infobar_placement(i); diff --git a/wmfs2/src/infobar.h b/wmfs2/src/infobar.h index b8db6d2..429be18 100755 --- a/wmfs2/src/infobar.h +++ b/wmfs2/src/infobar.h @@ -7,6 +7,11 @@ #define INFOBAR_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 }; @@ -16,4 +21,38 @@ void infobar_refresh(Infobar *i); void infobar_remove(Infobar *i); 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 */ diff --git a/wmfs2/src/tag.c b/wmfs2/src/tag.c index 6493c21..36a3d18 100755 --- a/wmfs2/src/tag.c +++ b/wmfs2/src/tag.c @@ -31,13 +31,10 @@ tag_screen(Scr33n *s, Tag *t) s->seltag = t; - SLIST_FOREACH(i, &s->infobars, next) - { - i->elemupdate |= FLAGINT(ElemTag); - infobar_elem_update(i); - } + infobar_elem_screen_update(s, ElemTag); } + void uicb_tag_set(Uicb cmd) { diff --git a/wmfs2/src/wmfs.h b/wmfs2/src/wmfs.h index 4f50803..83a80d7 100755 --- a/wmfs2/src/wmfs.h +++ b/wmfs2/src/wmfs.h @@ -82,7 +82,6 @@ struct Infobar Geo geo; Scr33n *screen; char *elemorder; - Flags elemupdate; TAILQ_HEAD(esub, Element) elements; SLIST_ENTRY(Infobar) next; }; @@ -93,6 +92,7 @@ struct Scr33n Geo geo; Tag *seltag; int id; + Flags elemupdate; TAILQ_HEAD(tsub, Tag) tags; SLIST_HEAD(, Infobar) infobars; SLIST_ENTRY(Scr33n) next;