[hackers] [wmii] Beginings of Xinerama support || Kris Maglione

From: <hg_AT_suckless.org>
Date: Sun, 12 Oct 2008 00:31:21 +0000 (UTC)

changeset: 2350:e6c8be956668
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Sat Oct 11 20:31:06 2008 -0400
files: cmd/wmii/Makefile cmd/wmii/_util.c cmd/wmii/area.c cmd/wmii/bar.c cmd/wmii/client.c cmd/wmii/column.c cmd/wmii/div.c cmd/wmii/event.c cmd/wmii/ewmh.c cmd/wmii/float.c cmd/wmii/fns.h cmd/wmii/frame.c cmd/wmii/fs.c cmd/wmii/geom.c cmd/wmii/layout.c cmd/wmii/main.c cmd/wmii/message.c cmd/wmii/mouse.c cmd/wmii/printevent.c cmd/wmii/view.c cmd/wmii/x11.c cmd/wmii/xdnd.c cmd/wmii/xext.c
description:
Beginings of Xinerama support

diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/Makefile
--- a/cmd/wmii/Makefile Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/Makefile Sat Oct 11 20:31:06 2008 -0400
@@ -8,7 +8,9 @@
 HFILES= dat.h fns.h
 
 LIB = ${LIBIXP}
-LDFLAGS += -lm ${LIBX11} -lXext -lXrandr ${LIBICONV} -lregexp9 -lbio -lfmt -lutf
+LDFLAGS += -lm ${LIBX11} -lXext -lXrandr -lXinerama \
+ ${LIBICONV} -lregexp9 -lbio -lfmt -lutf
+
 CFLAGS += ${INCX11} ${INCICONV} -DVERSION=\"${VERSION}\" \
           -DIXP_NEEDAPI=97
 OBJ = area \
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/_util.c
--- a/cmd/wmii/_util.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/_util.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/area.c
--- a/cmd/wmii/area.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/area.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/bar.c
--- a/cmd/wmii/bar.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/bar.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
@@ -13,6 +13,11 @@
 void
 bar_init(WMScreen *s) {
         WinAttr wa;
+
+ if(s->barwin) {
+ bar_resize(s);
+ return;
+ }
 
         s->brect = s->r;
         s->brect.min.y = s->brect.max.y - labelh(def.font);
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/client.c
--- a/cmd/wmii/client.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/client.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,5 +1,5 @@
 /* Copyright ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
- * Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+ * Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/column.c
--- a/cmd/wmii/column.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/column.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,5 +1,5 @@
 /* Copyright ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
- * Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+ * Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
@@ -17,6 +17,12 @@
 column_setmode(Area *a, const char *mode) {
         char *s, *t, *orig;
         char add, old;
+
+ /* The mapping between the current internal
+ * representation and the external interface
+ * is currently a bit complex. That will probably
+ * change.
+ */
 
         orig = strdup(mode);
         t = orig;
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/div.c
--- a/cmd/wmii/div.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/div.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/event.c
--- a/cmd/wmii/event.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/event.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/ewmh.c
--- a/cmd/wmii/ewmh.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/ewmh.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2007-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2007-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/float.c
--- a/cmd/wmii/float.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/float.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/fns.h Sat Oct 11 20:31:06 2008 -0400
@@ -175,7 +175,7 @@
 void update_keys(void);
 
 /* main.c */
-void init_screen(WMScreen*);
+void init_screens(void);
 
 /* map.c */
 void** hash_get(Map*, const char*, bool create);
@@ -272,4 +272,5 @@
 bool render_argb_p(Visual*);
 void xext_event(XEvent*);
 void xext_init(void);
+Rectangle* xinerama_screens(int*);
 
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/frame.c
--- a/cmd/wmii/frame.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/frame.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/fs.c
--- a/cmd/wmii/fs.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/fs.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2006-2008 Kris Maglione <fbsdaemon at gmail dot com>
+/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/geom.c
--- a/cmd/wmii/geom.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/geom.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/layout.c
--- a/cmd/wmii/layout.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/layout.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/main.c
--- a/cmd/wmii/main.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/main.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,5 +1,5 @@
 /* Copyright ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
- * Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+ * Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #define EXTERN
@@ -152,16 +152,34 @@
 };
 
 void
-init_screen(WMScreen *screen) {
+init_screens(void) {
+ Rectangle *rects;
+ int i, n, m;
 
- screen->r = scr.rect;
- def.snap = Dy(scr.rect) / 63;
- freeimage(screen->ibuf);
- freeimage(screen->ibuf32);
- screen->ibuf = allocimage(Dx(screen->r), Dy(screen->r), scr.depth);
- /* Probably shouldn't do this until it's needed. */
- if(render_visual)
- screen->ibuf32 = allocimage(Dx(screen->r), Dy(screen->r), 32);
+ rects = xinerama_screens(&n);
+ m = max(n, num_screens);
+
+ screens = erealloc(screens, m * sizeof *screens);
+ for(i=num_screens; i < m; i++)
+ screens[i] = (WMScreen){ 0, };
+
+ num_screens = m;
+
+ for(i=0; i < n; i++) {
+ screen = &screens[i];
+
+ screen->r = scr.rect;
+ def.snap = Dy(scr.rect) / 63;
+ freeimage(screen->ibuf);
+ freeimage(screen->ibuf32);
+ screen->ibuf = allocimage(Dx(screen->r), Dy(screen->r), scr.depth);
+ /* Probably shouldn't do this until it's needed. */
+ if(render_visual)
+ screen->ibuf32 = allocimage(Dx(screen->r), Dy(screen->r), 32);
+
+ bar_init(screen);
+ }
+ screen = &screens[0];
 }
 
 static void
@@ -271,7 +289,6 @@
 main(int argc, char *argv[]) {
         char **oargv;
         char *wmiirc;
- WMScreen *s;
         WinAttr wa;
         int i;
 
@@ -352,24 +369,17 @@
 
         sel_screen = pointerscreen();
 
- num_screens = 1;
- screens = emallocz(num_screens * sizeof *screens);
- screen = &screens[0];
- for(i = 0; i < num_screens; i++) {
- s = &screens[i];
- init_screen(s);
+ init_screens();
 
- wa.event_mask = SubstructureRedirectMask
- | SubstructureNotifyMask
- | EnterWindowMask
- | LeaveWindowMask
- | FocusChangeMask;
- wa.cursor = cursor[CurNormal];
- setwinattr(&scr.root, &wa,
- CWEventMask
- | CWCursor);
- bar_init(s);
- }
+ wa.event_mask = SubstructureRedirectMask
+ | SubstructureNotifyMask
+ | EnterWindowMask
+ | LeaveWindowMask
+ | FocusChangeMask;
+ wa.cursor = cursor[CurNormal];
+ setwinattr(&scr.root, &wa,
+ CWEventMask
+ | CWCursor);
 
         screen->focus = nil;
         setfocus(screen->barwin, RevertToParent);
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/message.c
--- a/cmd/wmii/message.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/message.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/mouse.c
--- a/cmd/wmii/mouse.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/mouse.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/printevent.c
--- a/cmd/wmii/printevent.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/printevent.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,7 +1,7 @@
 /*
  * Original code posted to comp.sources.x
  * Modifications by Russ Cox <rsc_AT_swtch.com>.
- * Further modifications by Kris Maglione <fbsdaemon_AT_gmail.com>
+ * Further modifications by Kris Maglione <maglione.k at Gmail>
  */
 
 /*
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/view.c
--- a/cmd/wmii/view.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/view.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,5 +1,5 @@
 /* Copyright ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
- * Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+ * Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
@@ -307,9 +307,6 @@
 
         oldsel = v->oldsel;
         a = v->sel;
- print("view: %s\n", v->name);
- print("client: %C\n", c);
- print("< sel: %a\n", v->sel);
         if(client_floats_p(c)) {
                 if(v->sel != v->area)
                         oldsel = v->sel;
@@ -327,7 +324,6 @@
                 else if(starting || c->sel && c->sel->area && !c->sel->area->floating)
                         a = v->area->next;
         }
- print("< sel: %a oldsel: %a\n", v->sel, oldsel);
 
         area_attach(a, f);
         /* TODO: Decide whether to focus this frame */
@@ -346,7 +342,6 @@
 
         if(oldsel)
                 v->oldsel = oldsel;
- print("< sel: %a oldsel: %a\n", v->sel, oldsel);
 
         if(c->sel == nil)
                 c->sel = f;
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/x11.c
--- a/cmd/wmii/x11.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/x11.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2007-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2007-2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #define _X11_VISIBLE
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/xdnd.c
--- a/cmd/wmii/xdnd.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/xdnd.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #include "dat.h"
diff -r fe9282224a76 -r e6c8be956668 cmd/wmii/xext.c
--- a/cmd/wmii/xext.c Sat Oct 11 19:05:24 2008 -0400
+++ b/cmd/wmii/xext.c Sat Oct 11 20:31:06 2008 -0400
@@ -1,9 +1,10 @@
-/* Copyright ©2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2008 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
 #define _X11_VISIBLE
 #include "dat.h"
 #include <X11/extensions/Xrender.h>
+#include <X11/extensions/Xinerama.h>
 #include "fns.h"
 
 #if RANDR_MAJOR < 1
@@ -14,12 +15,14 @@
 static bool randr_event_p(XEvent *e);
 static void randr_init(void);
 static void render_init(void);
+static void xinerama_init(void);
 
 typedef void (*EvHandler)(XEvent*);
 static EvHandler randr_handlers[RRNumberEvents];
 
 bool have_RandR;
 bool have_render;
+bool have_xinerama;
 int randr_eventbase;
 
 static void
@@ -33,6 +36,7 @@
 xext_init(void) {
         randr_init();
         render_init();
+ xinerama_init();
 }
 
 void
@@ -77,8 +81,7 @@
                 v->r.max.x += d.x;
                 v->r.max.y += d.y;
         }
- init_screen(screen);
- bar_resize(screen);
+ init_screens();
 }
 
 static EvHandler randr_handlers[] = {
@@ -125,3 +128,37 @@
             && f->direct.alphaMask;
 }
 
+static void
+xinerama_init(void) {
+ int base;
+
+ have_xinerama = XineramaQueryExtension(display, &base, &base);
+ if(have_xinerama)
+ have_xinerama = XineramaIsActive(display);
+}
+
+Rectangle*
+xinerama_screens(int *np) {
+ static Rectangle *rects;
+ XineramaScreenInfo *res;
+ int i, n;
+
+ if(!have_xinerama) {
+ *np = 1;
+ return &scr.rect;
+ }
+
+ free(rects);
+ res = XineramaQueryScreens(display, &n);
+ rects = emalloc(n * sizeof *rects);
+ for(i=0; i < n; i++) {
+ rects[i].min.x = res[i].x_org;
+ rects[i].min.y = res[i].y_org;
+ rects[i].max.x = res[i].x_org + res[i].width;
+ rects[i].max.y = res[i].y_org + res[i].height;
+ }
+
+ *np = n;
+ return rects;
+}
+
Received on Sun Oct 12 2008 - 00:31:21 UTC

This archive was generated by hypermail 2.2.0 : Sun Oct 12 2008 - 00:36:04 UTC