Add position in [bar]: top (0) bottom (1) and hide (2) possible
This commit is contained in:
parent
893666f1d3
commit
c1727da152
24
wmfs2/TODO
24
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?
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -3,8 +3,6 @@
|
||||
* For license, see COPYING.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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))
|
||||
{
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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]
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user