diff --git a/cmd/wmii/dat.h b/cmd/wmii/dat.h index d50c7be2..de805a16 100644 --- a/cmd/wmii/dat.h +++ b/cmd/wmii/dat.h @@ -25,27 +25,47 @@ /* From CGO */ #define assert_equal(x, y) typedef char _##x##_does_not_equal_##y[((x)-(y))*((x)-(y))*-2+1] -enum { - PingTime = 10000, - PingPeriod = 4000, - PingPartition = 10, +enum Barpos { + BBottom, + BTop, }; +enum { + Coldefault, Colstack, Colmax, Collast +}; + +enum { + CurNormal, + CurNECorner, CurNWCorner, CurSECorner, CurSWCorner, + CurDHArrow, CurDVArrow, CurMove, CurInput, CurSizing, + CurTCross, CurIcon, + CurNone, + CurLast, +}; +Cursor cursor[CurLast]; + enum IncMode { IIgnore, IShow, ISqueeze, }; -enum { - UrgManager, - UrgClient, -}; - enum ClientPermission { PermActivate = 1<<0, }; +enum { + PingTime = 10000, + PingPeriod = 4000, + PingPartition = 10, +}; + +enum Protocols { + ProtoDelete = 1<<0, + ProtoTakeFocus = 1<<1, + ProtoPing = 1<<2, +}; + enum { SourceUnknown, SourceClient, @@ -64,7 +84,8 @@ enum EWMHType { }; enum { - Coldefault, Colstack, Colmax, Collast + UrgManager, + UrgClient, }; extern char* modes[]; @@ -88,32 +109,10 @@ enum { assert_equal(Always, 2); -enum Barpos { - BBottom, - BTop, -}; - enum { NCOL = 16, }; -enum Protocols { - ProtoDelete = 1<<0, - ProtoTakeFocus = 1<<1, - ProtoPing = 1<<2, -}; - -enum { - CurNormal, - CurNECorner, CurNWCorner, CurSECorner, CurSWCorner, - CurDHArrow, CurDVArrow, CurMove, CurInput, CurSizing, - CurTCross, CurIcon, - CurNone, - CurLast, -}; -Cursor cursor[CurLast]; - - /* Data Structures */ typedef struct Area Area; typedef struct Bar Bar; @@ -232,7 +231,7 @@ struct Frame { struct Group { Group* next; XWindow leader; - Client *client; + Client* client; int ref; }; diff --git a/cmd/wmii/fns.h b/cmd/wmii/fns.h index c8b53fc0..d7649d61 100644 --- a/cmd/wmii/fns.h +++ b/cmd/wmii/fns.h @@ -24,21 +24,27 @@ /* Grotesque, but worth it. */ #define foreach_area(v, s, a) \ - with(int, __alive) \ - with(Area*, __anext) \ - for(s=0; _cond(s <= nscreens, 0); _cont(s++)) \ - for((a)=(s < nscreens ? (v)->areas[s] : v->floating), __anext=(a)->next; _cond(a, 1); _cont(((a)=__anext) && (__anext=(a)->next))) + with(int, __alive) \ + with(Area*, __anext) \ + for(s=0; _cond(s <= nscreens, 0); _cont(s++)) \ + for((a)=(s < nscreens ? (v)->areas[s] : v->floating), __anext=(a)->next; \ + _cond(a, 1); \ + _cont(((a)=__anext) && (__anext=(a)->next))) #define foreach_column(v, s, a) \ - with(int, __alive) \ - with(Area*, __anext) \ - for(s=0; _cond(s < nscreens, 0); _cont(s++)) \ - for((a)=(v)->areas[s], __anext=(a)->next; _cond(a, 1); _cont(((a)=__anext) && (__anext=(a)->next))) + with(int, __alive) \ + with(Area*, __anext) \ + for(s=0; _cond(s < nscreens, 0); _cont(s++)) \ + for((a)=(v)->areas[s], __anext=(a)->next; \ + _cond(a, 1); \ + _cont(((a)=__anext) && (__anext=(a)->next))) #define foreach_frame(v, s, a, f) \ with(Frame*, __fnext) \ foreach_area(v, s, a) \ - for((void)(((f)=(a)->frame) && (__fnext=(f)->anext)); _cond(f, 2); _cont(((f)=__fnext) && (__fnext=(f)->anext))) + for((void)(((f)=(a)->frame) && (__fnext=(f)->anext)); \ + _cond(f, 2); \ + _cont(((f)=__fnext) && (__fnext=(f)->anext))) #define btassert(arg, cond) \ (cond ? fprint(1, __FILE__":%d: failed assertion: " #cond "\n", __LINE__), backtrace(arg), true : false) diff --git a/cmd/wmii/main.c b/cmd/wmii/main.c index 1dbe5e78..75059102 100644 --- a/cmd/wmii/main.c +++ b/cmd/wmii/main.c @@ -175,23 +175,16 @@ init_screens(void) { /* Reallocate screens, zero any new ones. */ rects = xinerama_screens(&n); - m = max(n, nscreens); - screens = erealloc(screens, (m + 1) * sizeof *screens); - screens[m] = nil; + m = nscreens; + nscreens = max(n, nscreens); + screens = erealloc(screens, (nscreens + 1) * sizeof *screens); + screens[nscreens] = nil; for(v=view; v; v=v->next) { - v->areas = erealloc(v->areas, m * sizeof *v->areas); - v->r = erealloc(v->r, m * sizeof *v->r); - v->pad = erealloc(v->pad, m * sizeof *v->pad); + v->areas = erealloc(v->areas, nscreens * sizeof *v->areas); + v->r = erealloc(v->r, nscreens * sizeof *v->r); + v->pad = erealloc(v->pad, nscreens * sizeof *v->pad); } - for(i=nscreens; i < m; i++) { - screens[i] = emallocz(sizeof *screens[i]); - for(v=view; v; v=v->next) - view_init(v, i); - } - - nscreens = m; - /* Reallocate buffers. */ freeimage(ibuf); freeimage(ibuf32); @@ -204,6 +197,9 @@ init_screens(void) { /* Resize and initialize screens. */ for(i=0; i < nscreens; i++) { + if(i >= m) + screens[i] = emallocz(sizeof *screens[i]); + screen = screens[i]; screen->idx = i; @@ -212,6 +208,9 @@ init_screens(void) { screen->r = rects[i]; else screen->r = rectsetorigin(screen->r, scr.rect.max); + if(i >= m) + for(v=view; v; v=v->next) + view_init(v, i); def.snap = Dy(screen->r) / 63; bar_init(screens[i]); } diff --git a/cmd/wmii/message.c b/cmd/wmii/message.c index d5b48ae7..fbc378f8 100644 --- a/cmd/wmii/message.c +++ b/cmd/wmii/message.c @@ -565,6 +565,12 @@ message_root(void *p, IxpMsg *m) { return nil; } + if(!strcmp(s, "xinerama")) { + setenv("XINERAMA_SCREENS", m->pos, 1); + init_screens(); + return nil; + } + switch(getsym(s)) { case LBAR: /* bar on? <"top" | "bottom"> */ s = msg_getword(m, Ebadvalue); diff --git a/cmd/wmii/view.c b/cmd/wmii/view.c index 194e008e..1531122c 100644 --- a/cmd/wmii/view.c +++ b/cmd/wmii/view.c @@ -107,6 +107,7 @@ view_create(const char *name) { void view_init(View *v, int iscreen) { v->r[iscreen] = screens[iscreen]->r; + v->pad[iscreen] = ZR; v->areas[iscreen] = nil; column_new(v, nil, iscreen, 0); } diff --git a/include/stuff/x.h b/include/stuff/x.h index 965bd0af..594981cd 100644 --- a/include/stuff/x.h +++ b/include/stuff/x.h @@ -2,8 +2,6 @@ #include #include -extern Visual* render_visual; - extern void init_screens(void); #define Net(x) ("_NET_" x) @@ -74,3 +72,8 @@ extern long event_xtime; extern bool event_looprunning; extern void (*event_debug)(XEvent*); +extern Visual* render_visual; +extern bool have_RandR; +extern bool have_render; +extern bool have_xinerama; +