[hackers] [wmii] Change order of initialization after randr screens are added. Closes issue #153. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Fri, 18 Jun 2010 14:17:32 +0000 (UTC)

changeset: 2733:45371d69c278
tag: tip
user: Kris Maglione <kris_AT_suckless.org>
date: Fri Jun 18 10:17:25 2010 -0400
files: cmd/wmii/dat.h cmd/wmii/fns.h cmd/wmii/main.c cmd/wmii/message.c cmd/wmii/view.c include/stuff/x.h
description:
Change order of initialization after randr screens are added. Closes issue #153.

diff -r 1ff913b96fff -r 45371d69c278 cmd/wmii/dat.h
--- a/cmd/wmii/dat.h Thu Jun 17 19:51:58 2010 -0400
+++ b/cmd/wmii/dat.h Fri Jun 18 10:17:25 2010 -0400
@@ -25,25 +25,45 @@
 /* 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,
         IShow,
         ISqueeze,
 };
 
-enum {
- UrgManager,
- UrgClient,
+enum ClientPermission {
+ PermActivate = 1<<0,
 };
 
-enum ClientPermission {
- PermActivate = 1<<0,
+enum {
+ PingTime = 10000,
+ PingPeriod = 4000,
+ PingPartition = 10,
+};
+
+enum Protocols {
+ ProtoDelete = 1<<0,
+ ProtoTakeFocus = 1<<1,
+ ProtoPing = 1<<2,
 };
 
 enum {
@@ -64,7 +84,8 @@
 };
 
 enum {
- Coldefault, Colstack, Colmax, Collast
+ UrgManager,
+ UrgClient,
 };
 
 extern char* modes[];
@@ -88,32 +109,10 @@
 
 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 Group {
         Group* next;
         XWindow leader;
- Client *client;
+ Client* client;
         int ref;
 };
 
diff -r 1ff913b96fff -r 45371d69c278 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Thu Jun 17 19:51:58 2010 -0400
+++ b/cmd/wmii/fns.h Fri Jun 18 10:17:25 2010 -0400
@@ -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 -r 1ff913b96fff -r 45371d69c278 cmd/wmii/main.c
--- a/cmd/wmii/main.c Thu Jun 17 19:51:58 2010 -0400
+++ b/cmd/wmii/main.c Fri Jun 18 10:17:25 2010 -0400
@@ -175,23 +175,16 @@
 
         /* 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 @@
 
         /* 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 @@
                         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 -r 1ff913b96fff -r 45371d69c278 cmd/wmii/message.c
--- a/cmd/wmii/message.c Thu Jun 17 19:51:58 2010 -0400
+++ b/cmd/wmii/message.c Fri Jun 18 10:17:25 2010 -0400
@@ -565,6 +565,12 @@
                 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 -r 1ff913b96fff -r 45371d69c278 cmd/wmii/view.c
--- a/cmd/wmii/view.c Thu Jun 17 19:51:58 2010 -0400
+++ b/cmd/wmii/view.c Fri Jun 18 10:17:25 2010 -0400
@@ -107,6 +107,7 @@
 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 -r 1ff913b96fff -r 45371d69c278 include/stuff/x.h
--- a/include/stuff/x.h Thu Jun 17 19:51:58 2010 -0400
+++ b/include/stuff/x.h Fri Jun 18 10:17:25 2010 -0400
@@ -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 bool event_looprunning;
 extern void (*event_debug)(XEvent*);
 
+extern Visual* render_visual;
+extern bool have_RandR;
+extern bool have_render;
+extern bool have_xinerama;
+
Received on Fri Jun 18 2010 - 14:17:32 UTC

This archive was generated by hypermail 2.2.0 : Fri Jun 18 2010 - 14:24:04 UTC