From a0f82a11357f214db5499ff5a0d218eab711e20c Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Tue, 23 Aug 2011 10:16:03 +0200 Subject: [PATCH] add xinerama support --- wmfs2/src/infobar.c | 3 +++ wmfs2/src/infobar.h | 10 +++++++++ wmfs2/src/screen.c | 53 +++++++++++++++++++++++++++++++++++++++------ wmfs2/src/wmfs.c | 11 +++++----- wmfs2/src/wmfs.h | 20 +++++++++++++++++ 5 files changed, 84 insertions(+), 13 deletions(-) diff --git a/wmfs2/src/infobar.c b/wmfs2/src/infobar.c index 899bab6..019b7c8 100755 --- a/wmfs2/src/infobar.c +++ b/wmfs2/src/infobar.c @@ -4,4 +4,7 @@ */ #include "wmfs.h" +#include "infobar.h" + + diff --git a/wmfs2/src/infobar.h b/wmfs2/src/infobar.h index c949018..2b6ed26 100755 --- a/wmfs2/src/infobar.h +++ b/wmfs2/src/infobar.h @@ -8,6 +8,16 @@ #include "wmfs.h" +enum { ElemTag = 0, ElemLayout, ElemSelbar, ElemStatus, ElemCustom }; +/* +const struct elem_funcs { char c; void (*func_init)(Infobar *i); void (*func_update)(Element *e); } elem_funcs[] = +{ + { 't', infobar_elem_tag_init, infobar_elem_tag_update }, + { 'l', infobar_elem_layout_init, infobar_elem_layout_update }, + { 's', infobar_elem_selbar_init, infobar_elem_selbar_update }, + { 'S', infobar_elem_status_init, infobar_elem_status_update }, + { '\0', NULL, NULL } +};*/ #endif /* INFOBAR_H */ diff --git a/wmfs2/src/screen.c b/wmfs2/src/screen.c index f8a124b..472f76e 100755 --- a/wmfs2/src/screen.c +++ b/wmfs2/src/screen.c @@ -3,6 +3,12 @@ * For license, see COPYING. */ +#define HAVE_XINERAMA + +#ifdef HAVE_XINERAMA +#include +#endif /* HAVE_XINERAMA */ + #include "screen.h" #include "util.h" @@ -30,15 +36,48 @@ screen_init(void) Scr33n *s; Geo g; - g.x = 0; - g.y = 0; - g.w = DisplayWidth(W->dpy, W->xscreen); - g.h = DisplayHeight(W->dpy, W->xscreen); - SLIST_INIT(&W->h.screen); - s = screen_new(&g); - tag_screen(s, tag_new(s, "tag")); +#ifdef HAVE_XINERAMA + XineramaScreenInfo *xsi; + int i = 0, n; + + if(XineramaIsActive(W->dpy)) + { + xsi = XineramaQueryScreens(W->dpy, &n); + + for(; i < n; ++i) + { + s = NULL; + g.x = xsi[i].x_org; + g.y = xsi[i].y_org; + g.w = xsi[i].width; + g.h = xsi[i].height; + + s = screen_new(&g); + tag_screen(s, tag_new(s, "tag")); /* tmp */ + + SLIST_INSERT_HEAD(&W->h.screen, s, next); + + printf("%d: %d %d %d %d\n", i, s->geo.x, s->geo.y, s->geo.w, s->geo.h); + } + + XFree(xsi); + } + else +#endif /* HAVE_XINERAMA */ + { + g.x = g.y = 0; + g.w = DisplayWidth(W->dpy, W->xscreen); + g.h = DisplayHeight(W->dpy, W->xscreen); + + s = screen_new(&g); + tag_screen(s, tag_new(s, "tag")); + + SLIST_INSERT_HEAD(&W->h.screen, s, next); + printf("%d: %d %d %d %d\n", i, s->geo.x, s->geo.y, s->geo.w, s->geo.h); + } + } void diff --git a/wmfs2/src/wmfs.c b/wmfs2/src/wmfs.c index 9728432..bb05c18 100755 --- a/wmfs2/src/wmfs.c +++ b/wmfs2/src/wmfs.c @@ -114,6 +114,7 @@ wmfs_xinit(void) W->numlockmask = (1 << i); XFreeModifiermap(mm); + W->running = true; } void @@ -194,8 +195,6 @@ wmfs_scan(void) } XFree(w); - - return; } static void @@ -204,10 +203,8 @@ wmfs_loop(void) XEvent ev; while(XPending(W->dpy)) - { - XNextEvent(W->dpy, &ev); - HANDLE_EVENT(&ev); - } + while(W->running && !XNextEvent(W->dpy, &ev)) + HANDLE_EVENT(&ev); } static void @@ -240,6 +237,8 @@ wmfs_quit(void) free(W->net_atom); free(W); + + W->running = false; } diff --git a/wmfs2/src/wmfs.h b/wmfs2/src/wmfs.h index 2681374..2c42930 100755 --- a/wmfs2/src/wmfs.h +++ b/wmfs2/src/wmfs.h @@ -35,6 +35,8 @@ typedef const char* Uicb; * Structures */ typedef struct Geo Geo; +typedef struct Element Element; +typedef struct Infobar Infobar; typedef struct Barwin Barwin; typedef struct Scr33n Scr33n; typedef struct Tag Tag; @@ -55,13 +57,29 @@ struct Barwin Color fg, bg; Geo geo; Flags flags; + SLIST_HEAD(, MouseBind) mousebinds; SLIST_ENTRY(Barwin) next; }; +/* Infobar's element */ +struct Element +{ + SLIST_ENTRY(Barwin) bars; + Geo geo; + int type; + void (*func_init)(Infobar *i); + void (*func_update)(Element *e); + STAILQ_ENTRY(Element) next; +}; + /* Infobar */ struct Infobar { Barwin *bar; + Geo geo; + Scr33n *screen; + STAILQ_HEAD(, Element) elements; + SLIST_ENTRY(Infobar) next; }; /* Screen */ @@ -137,6 +155,7 @@ struct Wmfs Flags numlockmask; GC gc; Atom *net_atom; + bool running; struct { @@ -149,6 +168,7 @@ struct Wmfs { SLIST_HEAD(, Scr33n) screen; SLIST_HEAD(, Client) client; + SLIST_HEAD(, Infobar) infobar; SLIST_HEAD(, Keybind) keybind; SLIST_HEAD(, Barwin) barwin; } h;