[hackers] [wmii] Some more work towards Xinerama support. This is *not* yet stable. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Tue, 14 Oct 2008 02:25:10 +0000 (UTC)

changeset: 2354:bfc7f8542c1f
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Mon Oct 13 22:25:05 2008 -0400
files: cmd/util.c cmd/wmii/Makefile cmd/wmii/area.c cmd/wmii/bar.c cmd/wmii/client.c cmd/wmii/column.c cmd/wmii/dat.h cmd/wmii/div.c cmd/wmii/event.c cmd/wmii/ewmh.c cmd/wmii/float.c cmd/wmii/fns.h cmd/wmii/frame.c cmd/wmii/layout.c cmd/wmii/main.c cmd/wmii/message.c cmd/wmii/mouse.c cmd/wmii/view.c include/util.h
description:
Some more work towards Xinerama support. This is *not* yet stable.

diff -r 54a6aab54ce8 -r bfc7f8542c1f cmd/util.c
--- a/cmd/util.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/util.c Mon Oct 13 22:25:05 2008 -0400
@@ -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 @@
         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 -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/Makefile
--- a/cmd/wmii/Makefile Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/Makefile Mon Oct 13 22:25:05 2008 -0400
@@ -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 @@
         xext \
         ../util
 
-include ${ROOT}/mk/one.mk
+include $(ROOT)/mk/one.mk
 
diff -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/area.c
--- a/cmd/wmii/area.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/area.c Mon Oct 13 22:25:05 2008 -0400
@@ -20,8 +20,8 @@
         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*
-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++;
+ if(v->areas) { /* Creating a column. */
+ minwidth = Dx(v->r)/NCOL;
+ i = v->floating == nil;
+ if(pos)
+ i = area_idx(pos);
 
- /* 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);
+ 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;
+
+ view_scale(v, Dx(v->r) - w);
         }
-
- 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)
+ if(v->areas)
+ a->mode = Coldefault;
+ else
                 a->mode = def.colmode;
- else
- a->mode = Coldefault;
+ a->screen = scrn;
         a->frame = nil;
         a->sel = nil;
 
@@ -100,20 +102,22 @@
         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 @@
         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 @@
 
         if((old_a) && (a->floating != old_a->floating)) {
                 v->revert = old_a;
- if(v->area->max)
+ if(v->floating->max)
                         view_update(v);
         }
 
diff -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/bar.c
--- a/cmd/wmii/bar.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/bar.c Mon Oct 13 22:25:05 2008 -0400
@@ -91,7 +91,7 @@
         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 -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/client.c
--- a/cmd/wmii/client.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/client.c Mon Oct 13 22:25:05 2008 -0400
@@ -645,7 +645,7 @@
                         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 -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/column.c
--- a/cmd/wmii/column.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/column.c Mon Oct 13 22:25:05 2008 -0400
@@ -77,10 +77,10 @@
 }
 
 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 @@
                 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 @@
                         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 @@
 
         ar = a->next;
         al = a->prev;
- if(al == v->area)
+ if(al == v->floating)
                 al = nil;
 
         if(al)
diff -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/dat.h
--- a/cmd/wmii/dat.h Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/dat.h Mon Oct 13 22:25:05 2008 -0400
@@ -134,6 +134,7 @@
         bool floating;
         ushort id;
         int mode;
+ int screen;
         bool max;
         Rectangle r;
         Rectangle r_old;
@@ -259,11 +260,13 @@
         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 @@
         Image* ibuf;
         Image* ibuf32;
         int barpos;
+ int idx;
 
         Rectangle r;
         Rectangle brect;
@@ -353,7 +357,7 @@
 EXTERN Ixp9Srv p9srv;
 
 /* X11 */
-EXTERN uint num_screens;
+EXTERN uint nscreens;
 EXTERN uint valid_mask;
 EXTERN uint numlock_mask;
 EXTERN bool sel_screen;
diff -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/div.c
--- a/cmd/wmii/div.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/div.c Mon Oct 13 22:25:05 2008 -0400
@@ -122,7 +122,7 @@
 
         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 -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/event.c
--- a/cmd/wmii/event.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/event.c Mon Oct 13 22:25:05 2008 -0400
@@ -48,7 +48,6 @@
         sync();
         XIfEvent(display, &e, findtime, (void*)w);
 }
-
 
 uint
 flushevents(long event_mask, bool dispatch) {
@@ -366,12 +365,9 @@
 void
 check_x_event(IxpConn *c) {
         XEvent ev;
-
+
         USED(c);
-
- while(XPending(display)) {
- XNextEvent(display, &ev);
+ while(XCheckMaskEvent(display, ~0, &ev))
                 dispatch_event(&ev);
- }
 }
 
diff -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/ewmh.c
--- a/cmd/wmii/ewmh.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/ewmh.c Mon Oct 13 22:25:05 2008 -0400
@@ -91,16 +91,18 @@
         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 -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/float.c
--- a/cmd/wmii/float.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/float.c Mon Oct 13 22:25:05 2008 -0400
@@ -31,7 +31,7 @@
         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 -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/fns.h Mon Oct 13 22:25:05 2008 -0400
@@ -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_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 @@
 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 -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/frame.c
--- a/cmd/wmii/frame.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/frame.c Mon Oct 13 22:25:05 2008 -0400
@@ -640,7 +640,7 @@
         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 -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/layout.c
--- a/cmd/wmii/layout.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/layout.c Mon Oct 13 22:25:05 2008 -0400
@@ -129,7 +129,7 @@
 
         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 @@
         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 @@
                         }
                                 
 
- 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 @@
                         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 @@
                         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 -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/main.c
--- a/cmd/wmii/main.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/main.c Mon Oct 13 22:25:05 2008 -0400
@@ -154,16 +154,34 @@
 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 @@
         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 -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/message.c
--- a/cmd/wmii/message.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/message.c Mon Oct 13 22:25:05 2008 -0400
@@ -325,20 +325,21 @@
         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 @@
         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 @@
         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 @@
         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 @@
                         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 @@
                 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 @@
         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 @@
                 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 @@
         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 @@
         }
 
         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 -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/mouse.c
--- a/cmd/wmii/mouse.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/mouse.c Mon Oct 13 22:25:05 2008 -0400
@@ -218,7 +218,7 @@
 
         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 @@
                         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 @@
 
         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 -r 54a6aab54ce8 -r bfc7f8542c1f cmd/wmii/view.c
--- a/cmd/wmii/view.c Mon Oct 13 21:38:03 2008 -0400
+++ b/cmd/wmii/view.c Mon Oct 13 22:25:05 2008 -0400
@@ -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 @@
         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 @@
 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 **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 @@
         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 @@
 }
 
 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 @@
 
         /* 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 @@
                 }
         }
 
- 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 @@
 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) {
+ Frame *f;
         Area *a;
- Frame *f;
+ int s;
 
- foreach_frame(v, a, f)
+ foreach_frame(v, s, a, f)
                 f->client->sel = f;
 }
 
@@ -174,7 +192,7 @@
         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 @@
                 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 @@
 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 @@
         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_restack(v);
         if(fscrn)
- area_focus(v->area);
+ area_focus(v->floating);
         else
                 area_focus(v->sel);
         frame_draw_all();
@@ -308,9 +321,9 @@
         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 @@
                  * 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 @@
         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 @@
         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 @@
 
         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 @@
                 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 @@
 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 @@
         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 @@
         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 -r 54a6aab54ce8 -r bfc7f8542c1f include/util.h
--- a/include/util.h Mon Oct 13 21:38:03 2008 -0400
+++ b/include/util.h Mon Oct 13 22:25:05 2008 -0400
@@ -32,6 +32,7 @@
 #endif
 
 #define strlcat wmii_strlcat
+#define strcasestr wmii_strcasestr
 /* util.c */
 void _die(char*, int, char*, ...);
 void* emalloc(uint);
@@ -43,6 +44,7 @@
 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);
Received on Tue Oct 14 2008 - 02:25:10 UTC

This archive was generated by hypermail 2.2.0 : Tue Oct 14 2008 - 02:36:04 UTC