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

This commit is contained in:
Kris Maglione 2010-06-18 10:17:25 -04:00
parent fb9e477fba
commit 87f46f44bb
6 changed files with 72 additions and 58 deletions

View File

@ -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;
};

View File

@ -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)

View File

@ -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]);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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;