wmii

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

commit 87f46f44bb3f555526a9f8ddca90190242275895
parent fb9e477fba5758bae4a584193fca3a147cfb58ba
Author: Kris Maglione <kris@suckless.org>
Date:   Fri, 18 Jun 2010 10:17:25 -0400

Change order of initialization after randr screens are added. Closes issue #153.

Diffstat:
cmd/wmii/dat.h | 61++++++++++++++++++++++++++++++-------------------------------
cmd/wmii/fns.h | 24+++++++++++++++---------
cmd/wmii/main.c | 27+++++++++++++--------------
cmd/wmii/message.c | 6++++++
cmd/wmii/view.c | 1+
include/stuff/x.h | 7+++++--
6 files changed, 70 insertions(+), 56 deletions(-)

diff --git a/cmd/wmii/dat.h b/cmd/wmii/dat.h @@ -25,11 +25,24 @@ /* From CGO */ #define assert_equal(x, y) typedef char _##x##_does_not_equal_##y[((x)-(y))*((x)-(y))*-2+1] +enum Barpos { + BBottom, + BTop, +}; + enum { - PingTime = 10000, - PingPeriod = 4000, - PingPartition = 10, + 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, @@ -37,13 +50,20 @@ enum IncMode { ISqueeze, }; +enum ClientPermission { + PermActivate = 1<<0, +}; + enum { - UrgManager, - UrgClient, + PingTime = 10000, + PingPeriod = 4000, + PingPartition = 10, }; -enum ClientPermission { - PermActivate = 1<<0, +enum Protocols { + ProtoDelete = 1<<0, + ProtoTakeFocus = 1<<1, + ProtoPing = 1<<2, }; enum { @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -2,8 +2,6 @@ #include <stuff/x11.h> #include <fmt.h> -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; +