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 */ /* From CGO */
#define assert_equal(x, y) typedef char _##x##_does_not_equal_##y[((x)-(y))*((x)-(y))*-2+1] #define assert_equal(x, y) typedef char _##x##_does_not_equal_##y[((x)-(y))*((x)-(y))*-2+1]
enum { enum Barpos {
PingTime = 10000, BBottom,
PingPeriod = 4000, BTop,
PingPartition = 10,
}; };
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 { enum IncMode {
IIgnore, IIgnore,
IShow, IShow,
ISqueeze, ISqueeze,
}; };
enum {
UrgManager,
UrgClient,
};
enum ClientPermission { enum ClientPermission {
PermActivate = 1<<0, PermActivate = 1<<0,
}; };
enum {
PingTime = 10000,
PingPeriod = 4000,
PingPartition = 10,
};
enum Protocols {
ProtoDelete = 1<<0,
ProtoTakeFocus = 1<<1,
ProtoPing = 1<<2,
};
enum { enum {
SourceUnknown, SourceUnknown,
SourceClient, SourceClient,
@ -64,7 +84,8 @@ enum EWMHType {
}; };
enum { enum {
Coldefault, Colstack, Colmax, Collast UrgManager,
UrgClient,
}; };
extern char* modes[]; extern char* modes[];
@ -88,32 +109,10 @@ enum {
assert_equal(Always, 2); assert_equal(Always, 2);
enum Barpos {
BBottom,
BTop,
};
enum { enum {
NCOL = 16, 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 */ /* Data Structures */
typedef struct Area Area; typedef struct Area Area;
typedef struct Bar Bar; typedef struct Bar Bar;
@ -232,7 +231,7 @@ struct Frame {
struct Group { struct Group {
Group* next; Group* next;
XWindow leader; XWindow leader;
Client *client; Client* client;
int ref; int ref;
}; };

View File

@ -27,18 +27,24 @@
with(int, __alive) \ with(int, __alive) \
with(Area*, __anext) \ with(Area*, __anext) \
for(s=0; _cond(s <= nscreens, 0); _cont(s++)) \ 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))) 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) \ #define foreach_column(v, s, a) \
with(int, __alive) \ with(int, __alive) \
with(Area*, __anext) \ with(Area*, __anext) \
for(s=0; _cond(s < nscreens, 0); _cont(s++)) \ 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))) for((a)=(v)->areas[s], __anext=(a)->next; \
_cond(a, 1); \
_cont(((a)=__anext) && (__anext=(a)->next)))
#define foreach_frame(v, s, a, f) \ #define foreach_frame(v, s, a, f) \
with(Frame*, __fnext) \ with(Frame*, __fnext) \
foreach_area(v, s, a) \ 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) \ #define btassert(arg, cond) \
(cond ? fprint(1, __FILE__":%d: failed assertion: " #cond "\n", __LINE__), backtrace(arg), true : false) (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. */ /* Reallocate screens, zero any new ones. */
rects = xinerama_screens(&n); rects = xinerama_screens(&n);
m = max(n, nscreens); m = nscreens;
screens = erealloc(screens, (m + 1) * sizeof *screens); nscreens = max(n, nscreens);
screens[m] = nil; screens = erealloc(screens, (nscreens + 1) * sizeof *screens);
screens[nscreens] = nil;
for(v=view; v; v=v->next) { for(v=view; v; v=v->next) {
v->areas = erealloc(v->areas, m * sizeof *v->areas); v->areas = erealloc(v->areas, nscreens * sizeof *v->areas);
v->r = erealloc(v->r, m * sizeof *v->r); v->r = erealloc(v->r, nscreens * sizeof *v->r);
v->pad = erealloc(v->pad, m * sizeof *v->pad); 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. */ /* Reallocate buffers. */
freeimage(ibuf); freeimage(ibuf);
freeimage(ibuf32); freeimage(ibuf32);
@ -204,6 +197,9 @@ init_screens(void) {
/* Resize and initialize screens. */ /* Resize and initialize screens. */
for(i=0; i < nscreens; i++) { for(i=0; i < nscreens; i++) {
if(i >= m)
screens[i] = emallocz(sizeof *screens[i]);
screen = screens[i]; screen = screens[i];
screen->idx = i; screen->idx = i;
@ -212,6 +208,9 @@ init_screens(void) {
screen->r = rects[i]; screen->r = rects[i];
else else
screen->r = rectsetorigin(screen->r, scr.rect.max); 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; def.snap = Dy(screen->r) / 63;
bar_init(screens[i]); bar_init(screens[i]);
} }

View File

@ -565,6 +565,12 @@ message_root(void *p, IxpMsg *m) {
return nil; return nil;
} }
if(!strcmp(s, "xinerama")) {
setenv("XINERAMA_SCREENS", m->pos, 1);
init_screens();
return nil;
}
switch(getsym(s)) { switch(getsym(s)) {
case LBAR: /* bar on? <"top" | "bottom"> */ case LBAR: /* bar on? <"top" | "bottom"> */
s = msg_getword(m, Ebadvalue); s = msg_getword(m, Ebadvalue);

View File

@ -107,6 +107,7 @@ view_create(const char *name) {
void void
view_init(View *v, int iscreen) { view_init(View *v, int iscreen) {
v->r[iscreen] = screens[iscreen]->r; v->r[iscreen] = screens[iscreen]->r;
v->pad[iscreen] = ZR;
v->areas[iscreen] = nil; v->areas[iscreen] = nil;
column_new(v, nil, iscreen, 0); column_new(v, nil, iscreen, 0);
} }

View File

@ -2,8 +2,6 @@
#include <stuff/x11.h> #include <stuff/x11.h>
#include <fmt.h> #include <fmt.h>
extern Visual* render_visual;
extern void init_screens(void); extern void init_screens(void);
#define Net(x) ("_NET_" x) #define Net(x) ("_NET_" x)
@ -74,3 +72,8 @@ extern long event_xtime;
extern bool event_looprunning; extern bool event_looprunning;
extern void (*event_debug)(XEvent*); extern void (*event_debug)(XEvent*);
extern Visual* render_visual;
extern bool have_RandR;
extern bool have_render;
extern bool have_xinerama;