wmii

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

commit b0fc54d6fab19629a155e8a9009efdd272728c7d
parent 812f07a6a145332b069ae2883c3dea3e01249b14
Author: Kris Maglione <jg@suckless.org>
Date:   Sat, 11 Oct 2008 20:31:06 -0400

Beginings of Xinerama support

Diffstat:
cmd/wmii/Makefile | 4+++-
cmd/wmii/_util.c | 2+-
cmd/wmii/area.c | 2+-
cmd/wmii/bar.c | 7++++++-
cmd/wmii/client.c | 2+-
cmd/wmii/column.c | 8+++++++-
cmd/wmii/div.c | 2+-
cmd/wmii/event.c | 2+-
cmd/wmii/ewmh.c | 2+-
cmd/wmii/float.c | 2+-
cmd/wmii/fns.h | 3++-
cmd/wmii/frame.c | 2+-
cmd/wmii/fs.c | 2+-
cmd/wmii/geom.c | 2+-
cmd/wmii/layout.c | 2+-
cmd/wmii/main.c | 70++++++++++++++++++++++++++++++++++++++++------------------------------
cmd/wmii/message.c | 2+-
cmd/wmii/mouse.c | 2+-
cmd/wmii/printevent.c | 2+-
cmd/wmii/view.c | 7+------
cmd/wmii/x11.c | 2+-
cmd/wmii/xdnd.c | 2+-
cmd/wmii/xext.c | 43++++++++++++++++++++++++++++++++++++++++---
23 files changed, 115 insertions(+), 59 deletions(-)

diff --git a/cmd/wmii/Makefile b/cmd/wmii/Makefile @@ -8,7 +8,9 @@ TARG = wmii 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 --git a/cmd/wmii/_util.c b/cmd/wmii/_util.c @@ -1,4 +1,4 @@ -/* Copyright ©2008 Kris Maglione <fbsdaemon@gmail.com> +/* Copyright ©2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" diff --git a/cmd/wmii/area.c b/cmd/wmii/area.c @@ -1,4 +1,4 @@ -/* Copyright ©2006-2008 Kris Maglione <fbsdaemon@gmail.com> +/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" diff --git a/cmd/wmii/bar.c b/cmd/wmii/bar.c @@ -1,4 +1,4 @@ -/* Copyright ©2006-2008 Kris Maglione <fbsdaemon@gmail.com> +/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" @@ -14,6 +14,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 --git a/cmd/wmii/client.c b/cmd/wmii/client.c @@ -1,5 +1,5 @@ /* Copyright ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com> - * Copyright ©2006-2008 Kris Maglione <fbsdaemon@gmail.com> + * Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" diff --git a/cmd/wmii/column.c b/cmd/wmii/column.c @@ -1,5 +1,5 @@ /* Copyright ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com> - * Copyright ©2006-2008 Kris Maglione <fbsdaemon@gmail.com> + * Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" @@ -18,6 +18,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; old = '\0'; diff --git a/cmd/wmii/div.c b/cmd/wmii/div.c @@ -1,4 +1,4 @@ -/* Copyright ©2006-2008 Kris Maglione <fbsdaemon@gmail.com> +/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" diff --git a/cmd/wmii/event.c b/cmd/wmii/event.c @@ -1,4 +1,4 @@ -/* Copyright ©2006-2008 Kris Maglione <fbsdaemon@gmail.com> +/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" diff --git a/cmd/wmii/ewmh.c b/cmd/wmii/ewmh.c @@ -1,4 +1,4 @@ -/* Copyright ©2007-2008 Kris Maglione <fbsdaemon@gmail.com> +/* Copyright ©2007-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" diff --git a/cmd/wmii/float.c b/cmd/wmii/float.c @@ -1,4 +1,4 @@ -/* Copyright ©2006-2008 Kris Maglione <fbsdaemon@gmail.com> +/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" diff --git a/cmd/wmii/fns.h b/cmd/wmii/fns.h @@ -175,7 +175,7 @@ ulong str2modmask(const char*); 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 @@ void randr_event(XEvent*); bool render_argb_p(Visual*); void xext_event(XEvent*); void xext_init(void); +Rectangle* xinerama_screens(int*); diff --git a/cmd/wmii/frame.c b/cmd/wmii/frame.c @@ -1,4 +1,4 @@ -/* Copyright ©2006-2008 Kris Maglione <fbsdaemon@gmail.com> +/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" diff --git a/cmd/wmii/fs.c b/cmd/wmii/fs.c @@ -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 --git a/cmd/wmii/geom.c b/cmd/wmii/geom.c @@ -1,4 +1,4 @@ -/* Copyright ©2006-2008 Kris Maglione <fbsdaemon@gmail.com> +/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" diff --git a/cmd/wmii/layout.c b/cmd/wmii/layout.c @@ -1,4 +1,4 @@ -/* Copyright ©2006-2008 Kris Maglione <fbsdaemon@gmail.com> +/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" diff --git a/cmd/wmii/main.c b/cmd/wmii/main.c @@ -1,5 +1,5 @@ /* Copyright ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com> - * Copyright ©2006-2008 Kris Maglione <fbsdaemon@gmail.com> + * Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #define EXTERN @@ -152,16 +152,34 @@ ErrorCode ignored_xerrors[] = { }; void -init_screen(WMScreen *screen) { - - 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); +init_screens(void) { + Rectangle *rects; + int i, n, m; + + 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 @@ int main(int argc, char *argv[]) { char **oargv; char *wmiirc; - WMScreen *s; WinAttr wa; int i; @@ -352,24 +369,17 @@ extern int fmtevent(Fmt*); 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); - - wa.event_mask = SubstructureRedirectMask - | SubstructureNotifyMask - | EnterWindowMask - | LeaveWindowMask - | FocusChangeMask; - wa.cursor = cursor[CurNormal]; - setwinattr(&scr.root, &wa, - CWEventMask - | CWCursor); - bar_init(s); - } + init_screens(); + + 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 --git a/cmd/wmii/message.c b/cmd/wmii/message.c @@ -1,4 +1,4 @@ -/* Copyright ©2006-2008 Kris Maglione <fbsdaemon@gmail.com> +/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" diff --git a/cmd/wmii/mouse.c b/cmd/wmii/mouse.c @@ -1,4 +1,4 @@ -/* Copyright ©2006-2008 Kris Maglione <fbsdaemon@gmail.com> +/* Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" diff --git a/cmd/wmii/printevent.c b/cmd/wmii/printevent.c @@ -1,7 +1,7 @@ /* * Original code posted to comp.sources.x * Modifications by Russ Cox <rsc@swtch.com>. - * Further modifications by Kris Maglione <fbsdaemon@gmail.com> + * Further modifications by Kris Maglione <maglione.k at Gmail> */ /* diff --git a/cmd/wmii/view.c b/cmd/wmii/view.c @@ -1,5 +1,5 @@ /* Copyright ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com> - * Copyright ©2006-2008 Kris Maglione <fbsdaemon@gmail.com> + * Copyright ©2006-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" @@ -307,9 +307,6 @@ view_attach(View *v, Frame *f) { 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 @@ view_attach(View *v, Frame *f) { 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 @@ view_attach(View *v, Frame *f) { if(oldsel) v->oldsel = oldsel; - print("< sel: %a oldsel: %a\n", v->sel, oldsel); if(c->sel == nil) c->sel = f; diff --git a/cmd/wmii/x11.c b/cmd/wmii/x11.c @@ -1,4 +1,4 @@ -/* Copyright ©2007-2008 Kris Maglione <fbsdaemon@gmail.com> +/* Copyright ©2007-2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #define _X11_VISIBLE diff --git a/cmd/wmii/xdnd.c b/cmd/wmii/xdnd.c @@ -1,4 +1,4 @@ -/* Copyright ©2008 Kris Maglione <fbsdaemon@gmail.com> +/* Copyright ©2008 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" diff --git a/cmd/wmii/xext.c b/cmd/wmii/xext.c @@ -1,9 +1,10 @@ -/* Copyright ©2008 Kris Maglione <fbsdaemon@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 void randr_screenchange(XRRScreenChangeNotifyEvent*); 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 @@ void xext_init(void) { randr_init(); render_init(); + xinerama_init(); } void @@ -77,8 +81,7 @@ randr_screenchange(XRRScreenChangeNotifyEvent *ev) { 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 @@ render_argb_p(Visual *v) { && 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; +} +