Begin to work on tabbing (update commit)

This commit is contained in:
Martin Duquesnoy 2011-11-12 16:51:01 +01:00
parent 770d0dce1f
commit f3d80028a2
6 changed files with 62 additions and 9 deletions

View File

@ -319,6 +319,31 @@ client_grabbuttons(struct client *c, bool focused)
ButtonMask, GrabModeAsync, GrabModeSync, None, None); ButtonMask, GrabModeAsync, GrabModeSync, None, None);
} }
static void
client_tab_etablish(struct client *c)
{
struct chead cs;
struct client *cc, *prev = c;
if(c->tabhead != NULL)
while(!SLIST_EMPTY(c->tabhead))
SLIST_REMOVE_HEAD(c->tabhead, tbnext);
SLIST_INIT(&cs);
SLIST_INSERT_HEAD(&cs, c, tbnext);
SLIST_FOREACH(cc, &c->tag->clients, tnext)
{
if(GEOCMP(c->geo, cc->geo))
{
SLIST_INSERT_AFTER(prev, cc, tbnext);
prev = cc;
}
}
c->tabhead = &cs;
}
#define CCOL(c) (c == c->tag->sel ? &c->scol : &c->ncol) #define CCOL(c) (c == c->tag->sel ? &c->scol : &c->ncol)
static void static void
client_frame_update(struct client *c, struct colpair *cp) client_frame_update(struct client *c, struct colpair *cp)
@ -779,6 +804,9 @@ client_moveresize(struct client *c, struct geo *g)
c->flags &= ~CLIENT_DID_WINSIZE; c->flags &= ~CLIENT_DID_WINSIZE;
if(/* TABBING OPTION */ 1)
{ /* client_tab_etablish(c); */ }
client_frame_update(c, CCOL(c)); client_frame_update(c, CCOL(c));
client_update_props(c, CPROP_GEO); client_update_props(c, CPROP_GEO);
client_configure(c); client_configure(c);

View File

@ -83,7 +83,7 @@ config_bars(void)
size_t i, n; size_t i, n;
struct conf_sec *sec, **ks; struct conf_sec *sec, **ks;
int screenid; int screenid;
char *elem; char *name, *elem;
enum barpos pos = BarTop; enum barpos pos = BarTop;
/* [bars] */ /* [bars] */
@ -94,6 +94,7 @@ config_bars(void)
/* [bar] */ /* [bar] */
for(i = 0; i < n; ++i) for(i = 0; i < n; ++i)
{ {
name = fetch_opt_first(ks[i], "infobar", "name").str;
elem = fetch_opt_first(ks[i], "", "elements").str; elem = fetch_opt_first(ks[i], "", "elements").str;
screenid = fetch_opt_first(ks[i], "-1", "screen").num; screenid = fetch_opt_first(ks[i], "-1", "screen").num;
t = name_to_theme(fetch_opt_first(ks[i], "default", "theme").str); t = name_to_theme(fetch_opt_first(ks[i], "default", "theme").str);
@ -101,7 +102,7 @@ config_bars(void)
SLIST_FOREACH(s, &W->h.screen, next) SLIST_FOREACH(s, &W->h.screen, next)
if(screenid == s->id || screenid == -1) if(screenid == s->id || screenid == -1)
infobar_new(s, t, pos, elem); infobar_new(s, name, t, pos, elem);
} }
free(ks); free(ks);

View File

@ -168,7 +168,7 @@ infobar_elem_remove(struct element *e)
} }
struct infobar* struct infobar*
infobar_new(struct screen *s, struct theme *theme, enum barpos pos, const char *elem) infobar_new(struct screen *s, char *name, struct theme *theme, enum barpos pos, const char *elem)
{ {
bool map; bool map;
struct infobar *i = (struct infobar*)xcalloc(1, sizeof(struct infobar)); struct infobar *i = (struct infobar*)xcalloc(1, sizeof(struct infobar));
@ -176,6 +176,7 @@ infobar_new(struct screen *s, struct theme *theme, enum barpos pos, const char *
i->screen = s; i->screen = s;
i->theme = theme; i->theme = theme;
i->elemorder = xstrdup(elem); i->elemorder = xstrdup(elem);
i->name = xstrdup(name);
map = infobar_placement(i, pos); map = infobar_placement(i, pos);
@ -214,6 +215,7 @@ infobar_remove(struct infobar *i)
struct element *e; struct element *e;
free(i->elemorder); free(i->elemorder);
free(i->name);
TAILQ_FOREACH(e, &i->elements, next) TAILQ_FOREACH(e, &i->elements, next)
infobar_elem_remove(e); infobar_elem_remove(e);

View File

@ -13,7 +13,7 @@
enum { ElemTag = 0, ElemLayout, ElemSelbar, ElemStatus, ElemCustom, ElemLast }; enum { ElemTag = 0, ElemLayout, ElemSelbar, ElemStatus, ElemCustom, ElemLast };
struct infobar *infobar_new(struct screen *s, struct theme *theme, enum barpos pos, const char *elem); struct infobar *infobar_new(struct screen *s, char *name, struct theme *theme, enum barpos pos, const char *elem);
void infobar_elem_update(struct infobar *i); void infobar_elem_update(struct infobar *i);
void infobar_refresh(struct infobar *i); void infobar_refresh(struct infobar *i);
void infobar_remove(struct infobar *i); void infobar_remove(struct infobar *i);
@ -69,4 +69,21 @@ infobar_elem_screen_update(struct screen *s, int addf)
s->elemupdate &= ~FLAGINT(addf); s->elemupdate &= ~FLAGINT(addf);
} }
static inline struct infobar*
infobar_gb_name(const char *name)
{
struct screen *s;
struct infobar *i;
SLIST_FOREACH(s, &W->h.screen, next)
{
SLIST_FOREACH(i, &s->infobars, next)
if(!strcmp(i->name, name))
return i;
}
return SLIST_FIRST(&s->infobars);
}
#endif /* INFOBAR_H */ #endif /* INFOBAR_H */

View File

@ -32,6 +32,7 @@
#define ATOI(s) strtol(s, NULL, 10) #define ATOI(s) strtol(s, NULL, 10)
#define ABS(j) (j < 0 ? -j : j) #define ABS(j) (j < 0 ? -j : j)
#define INAREA(i, j, a) ((i) >= (a).x && (i) <= (a).x + (a).w && (j) >= (a).y && (j) <= (a).y + (a).h) #define INAREA(i, j, a) ((i) >= (a).x && (i) <= (a).x + (a).w && (j) >= (a).y && (j) <= (a).y + (a).h)
#define GEOCMP(g1, g2) ((g1).x == (g2).x && (g1).y == (g2).y && (g1).w == (g2).w && (g1).h == (g2).h)
/* /*
* "#RRGGBB" -> 0xRRGGBB * "#RRGGBB" -> 0xRRGGBB

View File

@ -111,6 +111,7 @@ struct infobar
struct theme *theme; struct theme *theme;
enum barpos pos; enum barpos pos;
char *elemorder; char *elemorder;
char *name;
TAILQ_HEAD(esub, element) elements; TAILQ_HEAD(esub, element) elements;
SLIST_ENTRY(infobar) next; SLIST_ENTRY(infobar) next;
}; };
@ -139,6 +140,7 @@ struct tag
TAILQ_ENTRY(tag) next; TAILQ_ENTRY(tag) next;
}; };
SLIST_HEAD(chead, client);
struct client struct client
{ {
struct tag *tag; struct tag *tag;
@ -147,6 +149,7 @@ struct client
struct geo geo, wgeo, tgeo, ttgeo, rgeo; struct geo geo, wgeo, tgeo, ttgeo, rgeo;
struct colpair ncol, scol; struct colpair ncol, scol;
struct theme *theme; struct theme *theme;
struct chead *tabhead;
int sizeh[SHLAST]; int sizeh[SHLAST];
char *title; char *title;
int border, tbarw; int border, tbarw;
@ -158,8 +161,9 @@ struct client
#define CLIENT_RULED 0x20 #define CLIENT_RULED 0x20
Flags flags; Flags flags;
Window win, frame; Window win, frame;
SLIST_ENTRY(client) next; /* Global list */ SLIST_ENTRY(client) next; /* Global list */
SLIST_ENTRY(client) tnext; /* struct tag list */ SLIST_ENTRY(client) tnext; /* struct tag list */
SLIST_ENTRY(client) tbnext; /* Tabbed client list */
}; };
struct layout_set struct layout_set
@ -217,9 +221,6 @@ struct theme
SLIST_ENTRY(theme) next; SLIST_ENTRY(theme) next;
}; };
#define RULE_FREE 0x01
#define RULE_MAX 0x02
#define RULE_IGNORE_TAG 0x04
struct rule struct rule
{ {
struct theme *theme; struct theme *theme;
@ -228,6 +229,9 @@ struct rule
char *role; char *role;
char *name; char *name;
int tag, screen; int tag, screen;
#define RULE_FREE 0x01
#define RULE_MAX 0x02
#define RULE_IGNORE_TAG 0x04
Flags flags; Flags flags;
SLIST_ENTRY(rule) next; SLIST_ENTRY(rule) next;
}; };