wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 89f0ba20160251cbe58c59fa5075dd2b73d4574e
parent 2560525d20b10a52688959fe53dfbb8373edb258
Author: Kris Maglione <jg@suckless.org>
Date:   Mon, 13 Oct 2008 22:25:05 -0400

Some more work towards Xinerama support. This is *not* yet stable.

Diffstat:
cmd/util.c | 21+++++++++++++++++++++
cmd/wmii/Makefile | 16++++++++--------
cmd/wmii/area.c | 86+++++++++++++++++++++++++++++++++++++++++--------------------------------------
cmd/wmii/bar.c | 2+-
cmd/wmii/client.c | 2+-
cmd/wmii/column.c | 10+++++-----
cmd/wmii/dat.h | 8++++++--
cmd/wmii/div.c | 2+-
cmd/wmii/event.c | 8++------
cmd/wmii/ewmh.c | 14++++++++------
cmd/wmii/float.c | 2+-
cmd/wmii/fns.h | 5+++--
cmd/wmii/frame.c | 2+-
cmd/wmii/layout.c | 10+++++-----
cmd/wmii/main.c | 29++++++++++++++++++++++++-----
cmd/wmii/message.c | 35++++++++++++++++++-----------------
cmd/wmii/mouse.c | 12++++++------
cmd/wmii/view.c | 129+++++++++++++++++++++++++++++++++++++++++++------------------------------------
include/util.h | 2++
19 files changed, 229 insertions(+), 166 deletions(-)

diff --git a/cmd/util.c b/cmd/util.c @@ -1,12 +1,15 @@ /* Written by Kris Maglione <fbsdaemon at gmail dot com> */ /* Public domain */ +#include <ctype.h> #include <errno.h> #include <sys/types.h> #include <signal.h> #include <stdarg.h> #include <stdlib.h> +#include <stdint.h> #include <stdio.h> #include <string.h> +#include <strings.h> #include <unistd.h> #include <util.h> #include <fmt.h> @@ -219,3 +222,21 @@ strlcat(char *dst, const char *src, uint size) { return size - n - 1; } +/* TODO: Make this UTF-8 compliant. */ +char* +strcasestr(const char *dst, const char *src) { + int dc, sc; + int len; + + len = strlen(src) - 1; + for(; (sc = *src) && *dst; src++) { + sc = tolower(dc); + for(; (dc = *dst); dst++) { + dc = tolower(dc); + if(sc == dc && !strncasecmp(dst+1, src+1, len)) + return (char*)(uintptr_t)dst; + } + } + return nil; +} + diff --git a/cmd/wmii/Makefile b/cmd/wmii/Makefile @@ -1,17 +1,17 @@ ROOT= ../.. -include ${ROOT}/mk/hdr.mk -include ${ROOT}/mk/wmii.mk +include $(ROOT)/mk/hdr.mk +include $(ROOT)/mk/wmii.mk -main.c: ${ROOT}/mk/wmii.mk +main.c: $(ROOT)/mk/wmii.mk TARG = wmii HFILES= dat.h fns.h -LIB = ${LIBIXP} -LDFLAGS += -lm ${LIBX11} -lXext -lXrandr -lXinerama \ - ${LIBICONV} -lregexp9 -lbio -lfmt -lutf +LIB = $(LIBIXP) +LDFLAGS += -lm $(LIBX11) -lXext -lXrandr -lXinerama \ + $(LIBICONV) -lregexp9 -lbio -lfmt -lutf -CFLAGS += ${INCX11} ${INCICONV} -DVERSION=\"${VERSION}\" \ +CFLAGS += $(INCX11) $(INCICONV) -DVERSION=\"$(VERSION)\" \ -DIXP_NEEDAPI=97 OBJ = area \ bar \ @@ -40,5 +40,5 @@ OBJ = area \ xext \ ../util -include ${ROOT}/mk/one.mk +include $(ROOT)/mk/one.mk diff --git a/cmd/wmii/area.c b/cmd/wmii/area.c @@ -20,8 +20,8 @@ area_idx(Area *a) { uint i; v = a->view; - i = 0; - for(ap=v->area; a != ap; ap=ap->next) + i = 1; + for(ap=v->areas[a->screen]; a != ap; ap=ap->next) i++; return i; } @@ -49,50 +49,52 @@ area_name(Area *a) { } Area* -area_create(View *v, Area *pos, uint w) { +area_create(View *v, Area *pos, int scrn, uint w) { static ushort id = 1; - uint areanum, i; + uint i; uint minwidth; int colnum; Area *a; - minwidth = Dx(v->r)/NCOL; - - i = 0; - if(pos) - i = area_idx(pos); - areanum = 0; - for(a=v->area; a; a=a->next) - areanum++; - /* TODO: Need a better sizing/placing algorithm. - */ - colnum = areanum - 1; - if(w == 0) { - if(colnum >= 0) { - w = view_newcolw(v, i); - if (w == 0) - w = Dx(v->r) / (colnum + 1); + if(v->areas) { /* Creating a column. */ + minwidth = Dx(v->r)/NCOL; + i = v->floating == nil; + if(pos) + i = area_idx(pos); + + colnum = 0; + for(a=v->areas[scrn]; a; a=a->next) + colnum++; + + /* TODO: Need a better sizing/placing algorithm. + */ + if(w == 0) { + if(colnum >= 0) { + w = view_newcolw(v, i); + if (w == 0) + w = Dx(v->r) / (colnum + 1); + } + else + w = Dx(v->r); } - else - w = Dx(v->r); - } - if(w < minwidth) - w = minwidth; - if(colnum && (colnum * minwidth + w) > Dx(v->r)) - return nil; + if(w < minwidth) + w = minwidth; + if(colnum && (colnum * minwidth + w) > Dx(v->r)) + return nil; - if(pos) view_scale(v, Dx(v->r) - w); + } a = emallocz(sizeof *a); a->view = v; a->id = id++; - if(v->area) - a->mode = def.colmode; - else + if(v->areas) a->mode = Coldefault; + else + a->mode = def.colmode; + a->screen = scrn; a->frame = nil; a->sel = nil; @@ -100,21 +102,23 @@ area_create(View *v, Area *pos, uint w) { a->r.min.x = 0; a->r.max.x = w; - if(pos) { + if(!v->floating) { + v->floating = a; + a->floating = true; + } + else if(pos) { a->next = pos->next; a->prev = pos; - }else { - a->next = v->area; - v->area = a; + } + else { + a->next = v->areas[scrn]; + v->areas[scrn] = a; } if(a->prev) a->prev->next = a; if(a->next) a->next->prev = a; - if(a == v->area) - a->floating = true; - if(v->sel == nil) area_focus(a); @@ -232,8 +236,8 @@ area_detach(Frame *f) { else column_detach(f); - if(v->sel->sel == nil && v->area->sel) - v->sel = v->area; + if(v->sel->sel == nil && v->floating->sel) + v->sel = v->floating; view_arrange(v); } @@ -259,7 +263,7 @@ area_focus(Area *a) { if((old_a) && (a->floating != old_a->floating)) { v->revert = old_a; - if(v->area->max) + if(v->floating->max) view_update(v); } diff --git a/cmd/wmii/bar.c b/cmd/wmii/bar.c @@ -91,7 +91,7 @@ bar_create(Bar **bp, const char *name) { b->col = def.normcolor; /* FIXME: Kludge. */ - for(s=screens; s < screens+num_screens; s++) { + for(s=screens; s < screens+nscreens; s++) { i = bp - s->bar; if(i < nelem(s->bar)) b->bar = i; diff --git a/cmd/wmii/client.c b/cmd/wmii/client.c @@ -645,7 +645,7 @@ client_seturgent(Client *c, bool urgent, int from) { for(f=c->frame; f; f=f->cnext) { SET(ff); if(!urgent) - for(a=f->view->area; a; a=a->next) + for(a=f->view->floating; a; a=a->next) for(ff=a->frame; ff; ff=ff->anext) if(ff->client->urgent) break; if(urgent || ff == nil) diff --git a/cmd/wmii/column.c b/cmd/wmii/column.c @@ -77,10 +77,10 @@ column_getmode(Area *a) { } Area* -column_new(View *v, Area *pos, uint w) { +column_new(View *v, Area *pos, int scrn, uint w) { Area *a; - a = area_create(v, pos, w); + a = area_create(v, pos, scrn, w); return a; #if 0 if(!a) @@ -204,7 +204,7 @@ column_detach(Frame *f) { if(first) stack_scale(first, dy); column_arrange(a, false); - }else if(a->view->area->next->next) + }else if(a->view->areas[a->screen]->next) area_destroy(a); } @@ -353,7 +353,7 @@ column_fit(Area *a, uint *ncolp, uint *nuncolp) { if(f->collapsed) { if(i < 0) { f->collapsed = false; - area_moveto(f->view->area, f); + area_moveto(f->view->floating, f); continue; } i--; @@ -633,7 +633,7 @@ column_resizeframe(Frame *f, Rectangle r) { ar = a->next; al = a->prev; - if(al == v->area) + if(al == v->floating) al = nil; if(al) diff --git a/cmd/wmii/dat.h b/cmd/wmii/dat.h @@ -134,6 +134,7 @@ struct Area { bool floating; ushort id; int mode; + int screen; bool max; Rectangle r; Rectangle r_old; @@ -259,11 +260,13 @@ struct Strut { Rectangle bottom; }; +#define firstarea areas[screen->idx] struct View { View* next; char name[256]; ushort id; - Area* area; + Area* floating; + Area** areas; Area* sel; Area* oldsel; Area* revert; @@ -325,6 +328,7 @@ EXTERN struct WMScreen { Image* ibuf; Image* ibuf32; int barpos; + int idx; Rectangle r; Rectangle brect; @@ -353,7 +357,7 @@ EXTERN IxpServer srv; EXTERN Ixp9Srv p9srv; /* X11 */ -EXTERN uint num_screens; +EXTERN uint nscreens; EXTERN uint valid_mask; EXTERN uint numlock_mask; EXTERN bool sel_screen; diff --git a/cmd/wmii/div.c b/cmd/wmii/div.c @@ -122,7 +122,7 @@ div_update_all(void) { v = screen->sel; dp = &divs; - for(a = v->area->next; a; a = a->next) { + for(a = v->firstarea; a; a = a->next) { d = getdiv(dp); dp = &d->next; div_set(d, a->r.min.x); diff --git a/cmd/wmii/event.c b/cmd/wmii/event.c @@ -49,7 +49,6 @@ xtime_kludge(void) { XIfEvent(display, &e, findtime, (void*)w); } - uint flushevents(long event_mask, bool dispatch) { XEvent ev; @@ -366,12 +365,9 @@ EvHandler handler[LASTEvent] = { void check_x_event(IxpConn *c) { XEvent ev; - - USED(c); - while(XPending(display)) { - XNextEvent(display, &ev); + USED(c); + while(XCheckMaskEvent(display, ~0, &ev)) dispatch_event(&ev); - } } diff --git a/cmd/wmii/ewmh.c b/cmd/wmii/ewmh.c @@ -91,16 +91,18 @@ ewmh_updatestacking(void) { Frame *f; Area *a; View *v; + int i; vector_linit(&vec); - for(v=view; v; v=v->next) - for(a=v->area->next; a; a=a->next) - for(f=a->frame; f; f=f->anext) - if(f->client->sel == f) - vector_lpush(&vec, f->client->w.w); + for(v=view; v; v=v->next) /* Wow... */ + for(i=0; i < nscreens; i++) + for(a=v->areas[i]; a; a=a->next) + for(f=a->frame; f; f=f->anext) + if(f->client->sel == f) + vector_lpush(&vec, f->client->w.w); for(v=view; v; v=v->next) { - for(f=v->area->stack; f; f=f->snext) + for(f=v->floating->stack; f; f=f->snext) if(!f->snext) break; for(; f; f=f->sprev) if(f->client->sel == f) diff --git a/cmd/wmii/float.c b/cmd/wmii/float.c @@ -31,7 +31,7 @@ float_detach(Frame *f) { a = f->area; sel = view_findarea(v, v->selcol, false); oldsel = v->oldsel; - if(!(sel || !v->area->next)) warning("%s:%d: !(sel || !v->area->next)", __FILE__, __LINE__); + if(!(sel || !v->areas[a->screen]->next)) warning("%s:%d: !(sel || !v->area->next)", __FILE__, __LINE__); pr = f->aprev; frame_remove(f); diff --git a/cmd/wmii/fns.h b/cmd/wmii/fns.h @@ -19,7 +19,7 @@ /* area.c */ int afmt(Fmt*); void area_attach(Area*, Frame*); -Area* area_create(View*, Area *pos, uint w); +Area* area_create(View*, Area *pos, int scrn, uint w); void area_destroy(Area*); void area_detach(Frame*); void area_focus(Area*); @@ -82,7 +82,7 @@ void column_attachrect(Area*, Frame*, Rectangle); void column_detach(Frame*); void column_frob(Area*); void column_insert(Area*, Frame*, Frame*); -Area* column_new(View*, Area *, uint); +Area* column_new(View*, Area*, int, uint); void column_remove(Frame*); void column_resize(Area*, int); void column_resizeframe(Frame*, Rectangle); @@ -233,6 +233,7 @@ Area* view_findarea(View*, int, bool); void view_focus(WMScreen*, View*); bool view_fullscreen_p(View*); char* view_index(View*); +void view_init(View*, int iscreen); char** view_names(void); uint view_newcolw(View*, int i); void view_restack(View*); diff --git a/cmd/wmii/frame.c b/cmd/wmii/frame.c @@ -640,7 +640,7 @@ constrain(Rectangle r) { Rectangle sr; Point p; - sr = screen->sel->area->r; + sr = screen->sel->floating->r; if(Dx(r) > Dx(sr)) r.max.x = r.min.x + Dx(sr); diff --git a/cmd/wmii/layout.c b/cmd/wmii/layout.c @@ -129,7 +129,7 @@ vplace(Framewin *fw, Point pt) { v = screen->sel; - for(a = v->area->next; a->next; a = a->next) + for(a = v->firstarea; a->next; a = a->next) if(pt.x < a->r.max.x) break; fw->ra = a; @@ -180,7 +180,7 @@ hplace(Framewin *fw, Point pt) { v = screen->sel; minw = Dx(v->r)/NCOL; - for(a = v->area->next; a->next; a = a->next) + for(a = v->firstarea; a->next; a = a->next) if(pt.x < a->r.max.x) break; @@ -428,7 +428,7 @@ thcol(Frame *f) { } - if(!a->frame && !a->floating && f->view->area->next->next) + if(!a->frame && !a->floating && f->view->firstarea->next) area_destroy(a); goto done; case ButtonPress: @@ -490,7 +490,7 @@ tvcol(Frame *f) { if(button != 1) continue; if(fw->ra) { - fw->ra = column_new(f->view, fw->ra, 0); + fw->ra = column_new(f->view, fw->ra, screen->idx, 0); area_moveto(fw->ra, f); } goto done; @@ -518,7 +518,7 @@ tfloat(Frame *f) { f->anext->colr.min.y = f->colr.min.y; else if(f->aprev) f->aprev->colr.max.y = f->colr.max.y; - area_moveto(f->view->area, f); + area_moveto(f->view->floating, f); } map_frame(f->client); focus(f->client, false); diff --git a/cmd/wmii/main.c b/cmd/wmii/main.c @@ -154,16 +154,34 @@ ErrorCode ignored_xerrors[] = { void init_screens(void) { Rectangle *rects; + View *v; static Image *ibuf, *ibuf32; int i, n, m; +#ifdef notdef + d.x = Dx(scr.rect) - Dx(screen->r); + d.y = Dy(scr.rect) - Dy(screen->r); + for(v=view; v; v=v->next) { + v->r.max.x += d.x; + v->r.max.y += d.y; + } +#endif + + /* Reallocate screens, zero any new ones. */ rects = xinerama_screens(&n); - m = max(n, num_screens); + m = max(n, nscreens); screens = erealloc(screens, m * sizeof *screens); - for(i=num_screens; i < m; i++) - screens[i] = (WMScreen){ 0, }; - num_screens = m; + for(i=nscreens; i < m; i++) { + screens[i] = (WMScreen){0}; + for(v=view; v; v=v->next) { + v->areas = erealloc(v->areas, m * sizeof *v->areas); + view_init(v, i); + } + } + + nscreens = m; + /* Reallocate buffers. */ freeimage(ibuf); freeimage(ibuf32); ibuf = allocimage(Dx(scr.rect), Dy(scr.rect), scr.depth); @@ -171,10 +189,11 @@ init_screens(void) { if(render_visual) ibuf32 = allocimage(Dx(scr.rect), Dy(scr.rect), 32); + /* Resize and initialize screens. */ for(i=0; i < n; i++) { screen = &screens[i]; + screen->idx = i; - print("rects[%d]: %R\n", i, rects[i]); screen->r = rects[i]; def.snap = Dy(rects[i]) / 63; screen->ibuf = ibuf; diff --git a/cmd/wmii/message.c b/cmd/wmii/message.c @@ -325,20 +325,21 @@ strarea(View *v, const char *s) { if(!strcmp(s, "sel")) return v->sel; if(!strcmp(s, "~")) - return v->area; + return v->floating; if(!getlong(s, &i) || i == 0) return nil; + /* FIXME: Very broken! */ if(i > 0) { - for(a = v->area; a; a = a->next) + for(a = v->firstarea; a; a = a->next) if(i-- == 0) break; } else { - for(a = v->area; a->next; a = a->next) + for(a = v->firstarea; a->next; a = a->next) ; - for(; a != v->area; a = a->prev) + for(; a != v->firstarea; a = a->prev) if(++i == 0) break; - if(a == v->area) + if(a == v->firstarea) a = nil; } return a; @@ -642,7 +643,7 @@ readctl_view(View *v) { if(v->sel->sel) bufprint("select client %C\n", v->sel->sel->client); - for(a = v->area->next, i = 1; a; a = a->next, i++) + for(a = v->firstarea, i = 1; a; a = a->next, i++) bufprint("colmode %d %s\n", i, column_getmode(a)); return buffer; } @@ -833,11 +834,11 @@ msg_selectarea(Area *a, IxpMsg *m) { switch(sym) { case LTOGGLE: if(!a->floating) - ap = v->area; + ap = v->floating; else if(v->revert && v->revert != a) ap = v->revert; else - ap = v->area->next; + ap = v->firstarea; break; case LUP: case LDOWN: @@ -846,7 +847,7 @@ msg_selectarea(Area *a, IxpMsg *m) { case LLEFT: if(a->floating) return Ebadvalue; - for(ap=v->area->next; ap->next; ap=ap->next) + for(ap=v->firstarea; ap->next; ap=ap->next) if(ap->next == a) break; break; case LRIGHT: @@ -854,10 +855,10 @@ msg_selectarea(Area *a, IxpMsg *m) { return Ebadvalue; ap = a->next; if(ap == nil) - ap = v->area->next; + ap = v->firstarea; break; case LTILDE: - ap = v->area; + ap = v->floating; break; default: if(!strcmp(s, "sel")) @@ -865,7 +866,7 @@ msg_selectarea(Area *a, IxpMsg *m) { else { if(!getulong(s, &i) || i == 0) return Ebadvalue; - for(ap=v->area->next; ap; ap=ap->next) + for(ap=v->firstarea; ap; ap=ap->next) if(--i == 0) break; if(i != 0) return Ebadvalue; @@ -1005,9 +1006,9 @@ msg_sendclient(View *v, IxpMsg *m, bool swap) { case LLEFT: if(a->floating) return Ebadvalue; - if(a->prev != v->area) + if(a->prev) to = a->prev; - a = v->area; + a = v->floating; break; case LRIGHT: if(a->floating) @@ -1016,7 +1017,7 @@ msg_sendclient(View *v, IxpMsg *m, bool swap) { break; case LTOGGLE: if(!a->floating) - to = v->area; + to = v->floating; else if(f->column) to = view_findarea(v, f->column, true); else @@ -1025,7 +1026,7 @@ msg_sendclient(View *v, IxpMsg *m, bool swap) { case LTILDE: if(a->floating) return Ebadvalue; - to = v->area; + to = v->floating; break; default: if(!getulong(s, &i) || i == 0) @@ -1035,7 +1036,7 @@ msg_sendclient(View *v, IxpMsg *m, bool swap) { } if(!to && !swap && (f->anext || f != f->area->frame)) - to = column_new(v, a, 0); + to = column_new(v, a, screen->idx, 0); if(!to) return Ebadvalue; diff --git a/cmd/wmii/mouse.c b/cmd/wmii/mouse.c @@ -218,7 +218,7 @@ mouse_resizecolframe(Frame *f, Align align) { v = screen->sel; d = divs; - for(a=v->area->next; a != f->area; a=a->next) + for(a=v->firstarea; a != f->area; a=a->next) d = d->next; if(align&East) @@ -241,13 +241,13 @@ mouse_resizecolframe(Frame *f, Align align) { r.rmax.xy = r.rmin.xy plus 1; \ }) if(align&North) - frob(f->aprev, f, aprev, min, max, +, -, y); + frob(f->aprev, f, aprev, min, max, +, -, y); else - frob(f->anext, f, anext, max, min, -, +, y); + frob(f->anext, f, anext, max, min, -, +, y); if(align&West) - frob(a->prev != v->area, a, prev, min, max, +, -, x); + frob(a->prev, a, prev, min, max, +, -, x); else - frob(a->next, a, next, max, min, -, +, x); + frob(a->next, a, next, max, min, -, +, x); #undef frob cwin = constraintwin(r); @@ -320,7 +320,7 @@ mouse_resizecol(Divide *d) { v = screen->sel; - for(a = v->area->next, dp = divs; a; a = a->next, dp = dp->next) + for(a = v->firstarea, dp = divs; a; a = a->next, dp = dp->next) if(dp->next == d) break; /* Fix later */ diff --git a/cmd/wmii/view.c b/cmd/wmii/view.c @@ -5,9 +5,15 @@ #include "dat.h" #include "fns.h" -#define foreach_frame(v, a, f) \ - for((a)=(v)->area; (a); (a)=(a)->next) \ - for((f)=(a)->frame; (f); (f)=(f)->anext) +#define foreach_area(v, s, a) \ + Area *__anext; /* Getting ugly... */ \ + for(s=0; s <= nscreens; s++) \ + for((a)=(s < nscreens ? (v)->areas[s] : v->floating), __anext=(a)->next; (a); (void)(((a)=__anext) && (__anext=(a)->next))) + +#define foreach_frame(v, s, a, f) \ + Frame *__fnext; \ + foreach_area(v, s, a) \ + for((void)(((f)=(a)->frame) && (__fnext=(f)->anext)); (f); (void)(((f)=__fnext) && (__fnext=(f)->anext))) static bool empty_p(View *v) { @@ -15,8 +21,9 @@ empty_p(View *v) { Area *a; char **p; int cmp; + int s; - foreach_frame(v, a, f) { + foreach_frame(v, s, a, f) { cmp = 1; for(p=f->client->retags; *p; p++) { cmp = strcmp(*p, v->name); @@ -52,7 +59,7 @@ bool view_fullscreen_p(View *v) { Frame *f; - for(f=v->area->frame; f; f=f->anext) + for(f=v->floating->frame; f; f=f->anext) if(f->client->fullscreen) return true; return false; @@ -64,10 +71,15 @@ view_create(const char *name) { View **vp; Client *c; View *v; + int i; - for(v=view; v; v=v->next) - if(!strcmp(name, v->name)) - return v; + for(vp=&view; *vp; vp=&(*vp)->next) { + i = strcmp((*vp)->name, name); + if(i == 0) + return *vp; + if(i > 0) + break; + } v = emallocz(sizeof *v); v->id = id++; @@ -76,14 +88,14 @@ view_create(const char *name) { utflcpy(v->name, name, sizeof v->name); event("CreateTag %s\n", v->name); - area_create(v, nil, 0); - column_new(v, v->area, 0); + area_create(v, nil, screen->idx, 0); + + v->areas = emallocz(nscreens * sizeof *v->areas); + for(i=0; i < nscreens; i++) + view_init(v, i); - area_focus(v->area->next); + area_focus(v->firstarea); - for(vp=&view; *vp; vp=&(*vp)->next) - if(strcmp((*vp)->name, name) >= 0) - break; v->next = *vp; *vp = v; @@ -101,11 +113,17 @@ view_create(const char *name) { } void +view_init(View *v, int iscreen) { + column_new(v, nil, iscreen, 0); +} + +void view_destroy(View *v) { View **vp; Frame *f, *fn; View *tv; Area *a, *an; + int s; if(v->dead) return; @@ -118,7 +136,7 @@ view_destroy(View *v) { /* FIXME: Can do better */ /* Detach frames held here by regex tags. */ - for(a=v->area; a; a=an) { + for(a=v->floating; a; a=an) { an = a->next; for(f=a->frame; f; f=fn) { fn = f->anext; @@ -126,9 +144,8 @@ view_destroy(View *v) { } } - while((a = v->area->next)) + foreach_area(v, s, a) area_destroy(a); - area_destroy(v->area); event("DestroyTag %s\n", v->name); @@ -148,18 +165,19 @@ Area* view_findarea(View *v, int idx, bool create) { Area *a; - for(a=v->area->next; a && --idx > 0; a=a->next) + for(a=v->firstarea; a && --idx > 0; a=a->next) if(create && a->next == nil) - return area_create(v, a, 0); + return area_create(v, a, screen->idx, 0); return a; } static void frames_update_sel(View *v) { - Area *a; Frame *f; + Area *a; + int s; - foreach_frame(v, a, f) + foreach_frame(v, s, a, f) f->client->sel = f; } @@ -174,7 +192,7 @@ view_update_rect(View *v) { left = 0; right = 0; bottom = 0; - for(f=v->area->frame; f; f=f->anext) { + for(f=v->floating->frame; f; f=f->anext) { strut = f->client->strut; if(!strut) continue; @@ -196,13 +214,13 @@ view_update_rect(View *v) { r.max.y -= Dy(screen->brect); bar_sety(r.max.y); } - v->area->r = r; + v->floating->r = r; v->r = r; brect = screen->brect; brect.min.x = screen->r.min.x; brect.max.x = screen->r.max.x; - for(f=v->area->frame; f; f=f->anext) { + for(f=v->floating->frame; f; f=f->anext) { /* This is not pretty. :( */ strut = f->client->strut; if(!strut) @@ -220,9 +238,10 @@ view_update_rect(View *v) { void view_update(View *v) { Client *c; - Frame *f, *fnext; - Area *a, *an; + Frame *f; + Area *a; bool fscrn; + int s; if(v != screen->sel) return; @@ -232,23 +251,17 @@ view_update(View *v) { frames_update_sel(v); view_arrange(v); - fscrn = false; - for(a=v->area; a; a=an) { - an = a->next; - for(f=a->frame; f; f=fnext) { - fnext = f->anext; - if(f->client->fullscreen) { - f->collapsed = false; - fscrn = true; - if(!f->area->floating) { - f->oldarea = area_idx(f->area); - area_moveto(v->area, f); - area_setsel(v->area, f); - }else if(f->oldarea == -1) - f->oldarea = 0; - } + foreach_frame(v, s, a, f) + if(f->client->fullscreen) { + f->collapsed = false; + fscrn = true; + if(!f->area->floating) { + f->oldarea = area_idx(f->area); + area_moveto(v->floating, f); + area_setsel(v->floating, f); + }else if(f->oldarea == -1) + f->oldarea = 0; } - } for(c=client; c; c=c->next) { f = c->sel; @@ -266,7 +279,7 @@ view_update(View *v) { view_restack(v); if(fscrn) - area_focus(v->area); + area_focus(v->floating); else area_focus(v->sel); frame_draw_all(); @@ -308,9 +321,9 @@ view_attach(View *v, Frame *f) { oldsel = v->oldsel; a = v->sel; if(client_floats_p(c)) { - if(v->sel != v->area) + if(v->sel != v->floating) oldsel = v->sel; - a = v->area; + a = v->floating; } else if((ff = client_groupframe(c, v))) a = ff->area; @@ -322,7 +335,7 @@ view_attach(View *v, Frame *f) { * tagging with +foo. */ else if(starting || c->sel && c->sel->area && !c->sel->area->floating) - a = v->area->next; + a = v->firstarea; } area_attach(a, f); @@ -393,7 +406,7 @@ view_restack(View *v) { fscrn = view_fullscreen_p(v); /* *sigh */ - for(f=v->area->stack; f; f=f->snext) + for(f=v->floating->stack; f; f=f->snext) if(f->client->w.ewmh.type & TypeDock) vector_lpush(&wins, f->client->framewin->w); else @@ -411,7 +424,7 @@ view_restack(View *v) { for(d = divs; d && d->w->mapped; d = d->next) vector_lpush(&wins, d->w->w); - for(a=v->area->next; a; a=a->next) + for(a=v->firstarea; a; a=a->next) if(a->frame) { vector_lpush(&wins, a->sel->client->framewin->w); for(f=a->frame; f; f=f->anext) @@ -434,19 +447,19 @@ view_scale(View *v, int w) { minwidth = Dx(v->r)/NCOL; - if(!v->area->next) + if(!v->firstarea) return; numcol = 0; dx = 0; - for(a=v->area->next; a; a=a->next) { + for(a=v->firstarea; a; a=a->next) { numcol++; dx += Dx(a->r); } scale = (float)w / dx; xoff = v->r.min.x; - for(a=v->area->next; a; a=a->next) { + for(a=v->firstarea; a; a=a->next) { a->r.max.x = xoff + Dx(a->r) * scale; a->r.min.x = xoff; if(!a->next) @@ -458,7 +471,7 @@ view_scale(View *v, int w) { return; xoff = v->r.min.x; - for(a=v->area->next; a; a=a->next) { + for(a=v->firstarea; a; a=a->next) { a->r.min.x = xoff; if(Dx(a->r) < minwidth) @@ -473,12 +486,12 @@ void view_arrange(View *v) { Area *a; - if(!v->area->next) + if(!v->firstarea) return; view_update_rect(v); view_scale(v, Dx(v->r)); - for(a=v->area->next; a; a=a->next) { + for(a=v->firstarea; a; a=a->next) { /* This is wrong... */ a->r.min.y = v->r.min.y; a->r.max.y = v->r.max.y; @@ -495,12 +508,12 @@ view_rects(View *v, uint *num, Frame *ignore) { int i; i = 2; - for(f=v->area->frame; f; f=f->anext) + for(f=v->floating->frame; f; f=f->anext) i++; result = emallocz(i * sizeof *result); i = 0; - for(f=v->area->frame; f; f=f->anext) + for(f=v->floating->frame; f; f=f->anext) if(f != ignore) result[i++] = f->r; result[i++] = screen->r; @@ -551,10 +564,10 @@ view_index(View *v) { Rectangle *r; Frame *f; Area *a; - int i; + int i, s; bufclear(); - for(a=v->area, i=0; a; a=a->next, i++) { + foreach_area(v, s, a) { if(a->floating) bufprint("# ~ %d %d\n", Dx(a->r), Dy(a->r)); else diff --git a/include/util.h b/include/util.h @@ -32,6 +32,7 @@ typedef long long vlong; #endif #define strlcat wmii_strlcat +#define strcasestr wmii_strcasestr /* util.c */ void _die(char*, int, char*, ...); void* emalloc(uint); @@ -43,6 +44,7 @@ void* freelater(void*); int max(int, int); int min(int, int); uint strlcat(char*, const char*, uint); +char* strcasestr(const char*, const char*); char* sxprint(const char*, ...); uint tokenize(char **, uint, char*, char); int utflcpy(char*, const char*, int);