diff --git a/wmfs2/TODO b/wmfs2/TODO index 7658783..8b13789 100644 --- a/wmfs2/TODO +++ b/wmfs2/TODO @@ -1,25 +1 @@ -WMFS's Infobar/Element low-level structure -[ ] -[ SCR33N ] => [ Infobar ] -[ ] [ (head) ] => [ Element ] - | [ (head) ] => [ SLIST_HEAD(Barwin) bars; - | | [ ElemTypes type; { ElemTag, ElemLayout, ElemSelbar, ElemStatus, (ElemSystray?) } - ... | [ Geo geo; - ... [ STAILQ_ENTRY(Elements) next; - | - ... - -This will be used with some functions, depending of element type : - -Element* elem_tag_init(Infobar *i) - layout - selbar - statustext - systray? - -void element_tag_update(Element *e) - layout - selbar - statustext - systray? diff --git a/wmfs2/src/config.c b/wmfs2/src/config.c index 62fcdb2..9093f06 100644 --- a/wmfs2/src/config.c +++ b/wmfs2/src/config.c @@ -69,6 +69,7 @@ config_bars(void) struct conf_sec *sec, **ks; int screenid; char *elem; + Barpos pos = BarTop; /* [bars] */ sec = fetch_section_first(NULL, "bars"); @@ -81,10 +82,11 @@ config_bars(void) elem = fetch_opt_first(ks[i], "", "elements").str; screenid = fetch_opt_first(ks[i], "-1", "screen").num; t = name_to_theme(fetch_opt_first(ks[i], "default", "theme").str); + pos = fetch_opt_first(ks[i], "0", "position").num; SLIST_FOREACH(s, &W->h.screen, next) if(screenid == s->id || screenid == -1) - (Infobar*)infobar_new(s, t, elem); + (Infobar*)infobar_new(s, t, pos, elem); } free(ks); @@ -133,6 +135,7 @@ config_keybind(void) size_t j, n; struct conf_sec *sec, **ks; struct opt_type *opt; + char *cmd; Keybind *k; /* [keys] */ @@ -145,17 +148,20 @@ config_keybind(void) /* [key] */ for(i = 0; i < n; ++i) { - opt = fetch_opt(ks[i], "", "mod"); - k = (Keybind*)xcalloc(1, sizeof(Keybind)); + /* mod = {} */ + opt = fetch_opt(ks[i], "", "mod"); + for(j = 0; j < fetch_opt_count(opt); ++j) k->mod |= modkey_keysym(opt[j].str); free(opt); + /* key = */ k->keysym = XStringToKeysym(fetch_opt_first(ks[i], "None", "key").str); + /* func = */ if(!(k->func = uicb_name_func(fetch_opt_first(ks[i], "", "func").str))) { warnx("configuration: Unknown Function \"%s\".", @@ -163,7 +169,9 @@ config_keybind(void) k->func = uicb_spawn; } - k->cmd = fetch_opt_first(ks[i], "", "cmd").str; + /* cmd = */ + if((cmd = fetch_opt_first(ks[i], "", "cmd").str)) + k->cmd = xstrdup(cmd); SLIST_INSERT_HEAD(&W->h.keybind, k, next); } @@ -187,4 +195,5 @@ config_init(void) config_bars(); free(path); + free_conf(); } diff --git a/wmfs2/src/infobar.c b/wmfs2/src/infobar.c index 5f60a05..91f19ef 100644 --- a/wmfs2/src/infobar.c +++ b/wmfs2/src/infobar.c @@ -3,8 +3,6 @@ * For license, see COPYING. */ -#include - #include "wmfs.h" #include "draw.h" #include "infobar.h" @@ -171,8 +169,9 @@ infobar_elem_remove(Element *e) } Infobar* -infobar_new(Scr33n *s, Theme *theme, const char *elem) +infobar_new(Scr33n *s, Theme *theme, Barpos pos, const char *elem) { + bool map; int n; Infobar *i = (Infobar*)xcalloc(1, sizeof(Infobar)); @@ -181,24 +180,25 @@ infobar_new(Scr33n *s, Theme *theme, const char *elem) i->theme = theme; i->elemorder = xstrdup(elem); - /* TODO: Position top/bottom */ - infobar_placement(i); + map = infobar_placement(i, (i->pos = pos)); /* Barwin create */ i->bar = barwin_new(W->root, i->geo.x, i->geo.y, i->geo.w, i->geo.h, theme->bars.fg, theme->bars.bg, false); - /* Render */ - barwin_map(i->bar); - barwin_map_subwin(i->bar); - barwin_refresh_color(i->bar); + SLIST_INSERT_HEAD(&s->infobars, i, next); /* Elements */ infobar_elem_init(i); - infobar_refresh(i); + /* Render, only if pos is Top or Bottom */ + if(!map) + return i; - SLIST_INSERT_HEAD(&s->infobars, i, next); + barwin_map(i->bar); + barwin_map_subwin(i->bar); + barwin_refresh_color(i->bar); + infobar_refresh(i); return i; } diff --git a/wmfs2/src/infobar.h b/wmfs2/src/infobar.h index 728cd2d..66b4eb5 100644 --- a/wmfs2/src/infobar.h +++ b/wmfs2/src/infobar.h @@ -12,7 +12,7 @@ enum { ElemTag = 0, ElemLayout, ElemSelbar, ElemStatus, ElemCustom, ElemLast }; -Infobar *infobar_new(Scr33n *s, Theme *theme, const char *elem); +Infobar *infobar_new(Scr33n *s, Theme *theme, Barpos pos, const char *elem); void infobar_elem_update(Infobar *i); void infobar_refresh(Infobar *i); void infobar_remove(Infobar *i); @@ -29,14 +29,30 @@ infobar_elem_placement(Element *e) e->geo.x = (p ? p->geo.x + p->geo.w + PAD : 0); } -static inline void -infobar_placement(Infobar *i) +/* Bars placement management and usable space management */ +static inline bool +infobar_placement(Infobar *i, Barpos p) { - Infobar *h = SLIST_FIRST(&i->screen->infobars); - - i->geo = i->screen->geo; + i->geo = i->screen->ugeo; i->geo.h = i->theme->bars_width; - i->geo.y += (h ? h->geo.y + h->geo.h : i->screen->geo.y); + + /* Top */ + switch(p) + { + case BarTop: + i->screen->ugeo.y += i->geo.h; + i->screen->ugeo.h -= i->geo.h; + break; + case BarBottom: + i->geo.y = (i->screen->ugeo.y + i->screen->ugeo.h) - i->geo.h; + i->screen->ugeo.h -= i->geo.h; + break; + default: + case BarHide: + return false; + } + + return true; } static inline void diff --git a/wmfs2/src/screen.c b/wmfs2/src/screen.c index 74e2074..49c3351 100644 --- a/wmfs2/src/screen.c +++ b/wmfs2/src/screen.c @@ -19,7 +19,7 @@ screen_new(Geo *g, int id) { Scr33n *s = (Scr33n*)xcalloc(1, sizeof(Scr33n)); - s->geo = *g; + s->geo = s->ugeo = *g; s->seltag = NULL; s->id = id; diff --git a/wmfs2/src/tag.c b/wmfs2/src/tag.c index c395318..a51a5a0 100644 --- a/wmfs2/src/tag.c +++ b/wmfs2/src/tag.c @@ -15,7 +15,7 @@ tag_new(Scr33n *s, char *name) t = xcalloc(1, sizeof(Tag)); t->screen = s; - t->name = name; + t->name = xstrdup(name); t->flags = 0; t->sel = NULL; @@ -93,6 +93,7 @@ tag_free(Scr33n *s) TAILQ_FOREACH(t, &s->tags, next) { TAILQ_REMOVE(&s->tags, t, next); + free(t->name); free(t); } } diff --git a/wmfs2/src/wmfs.c b/wmfs2/src/wmfs.c index 488936d..9f86f4b 100644 --- a/wmfs2/src/wmfs.c +++ b/wmfs2/src/wmfs.c @@ -240,6 +240,7 @@ wmfs_init(void) void wmfs_quit(void) { + Keybind *k; Theme *t; /* Will free: @@ -252,7 +253,13 @@ wmfs_quit(void) XCloseDisplay(W->dpy); /* Conf stuffs */ - FREE_LIST(Keybind, W->h.keybind); + while(!SLIST_EMPTY(&W->h.keybind)) + { + k = SLIST_FIRST(&W->h.keybind); + SLIST_REMOVE_HEAD(&W->h.keybind, next); + free((void*)k->cmd); + free(k); + } while(!SLIST_EMPTY(&W->h.theme)) { diff --git a/wmfs2/src/wmfs.h b/wmfs2/src/wmfs.h index cbc75fd..fb730f4 100644 --- a/wmfs2/src/wmfs.h +++ b/wmfs2/src/wmfs.h @@ -30,6 +30,8 @@ typedef unsigned int Flags; typedef unsigned int Color; typedef const char* Uicb; +typedef enum { BarTop = 0, BarBottom, BarHide, BarLast } Barpos; +typedef enum { Right = 0, Left, Top, Bottom, Center, PositionLast } Position; /* * Structures @@ -81,6 +83,7 @@ struct Infobar { Barwin *bar; Geo geo; + Barpos pos; Scr33n *screen; Theme *theme; char *elemorder; @@ -91,7 +94,7 @@ struct Infobar /* Screen */ struct Scr33n { - Geo geo; + Geo geo, ugeo; Tag *seltag; int id; Flags elemupdate; @@ -171,18 +174,6 @@ struct Theme SLIST_ENTRY(Theme) next; }; -struct Config -{ - /* Misc section */ - struct - { - char *font; - bool focus_follow_mouse; - bool focus_follow_movement; - bool focus_pointer_click; - } misc; -}; - /* Global struct */ struct Wmfs { @@ -205,9 +196,6 @@ struct Wmfs SLIST_HEAD(, Theme) theme; } h; - /* Config options */ - struct Config conf; - /* * Selected screen, from what you go everywhere; selected tag, * and then selected client. diff --git a/wmfs2/wmfsrc2 b/wmfs2/wmfsrc2 index befdc05..8697d4d 100644 --- a/wmfs2/wmfsrc2 +++ b/wmfs2/wmfsrc2 @@ -25,16 +25,16 @@ [/theme] [theme] - name = "perso" + name = "perso" - font = "-*-fixed-bold" + font = "-*-fixed-bold" - bars_width = 20 - bars_fg = "#222222" - bars_bg = "#CCCCCC" + bars_width = 20 + bars_fg = "#222222" + bars_bg = "#CCCCCC" - tags_sel_bg = "#33AA33" - tags_normal_fg = "#AA3333" + tags_sel_bg = "#33AA33" + tags_normal_fg = "#AA3333" [/theme] @@ -42,11 +42,24 @@ [bars] - # element type: + # Position: + # 0 Top + # 1 Bottom + # 2 Hide + + # Element type: # t Tags # S Statustext [bar] + position = 1 + screen = 0 + elements = "t" + theme = "perso" + [/bar] + + [bar] + position = 1 screen = 0 elements = "t" theme = "default" @@ -57,6 +70,12 @@ elements = "t" theme = "perso" [/bar] + [bar] + screen = 1 + elements = "t" + theme = "default" + [/bar] + [/bars]