add xinerama support

This commit is contained in:
Martin Duquesnoy 2011-08-23 10:16:03 +02:00
parent 8d3f4beb55
commit a0f82a1135
5 changed files with 84 additions and 13 deletions

View File

@ -4,4 +4,7 @@
*/
#include "wmfs.h"
#include "infobar.h"

View File

@ -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 */

View File

@ -3,6 +3,12 @@
* For license, see COPYING.
*/
#define HAVE_XINERAMA
#ifdef HAVE_XINERAMA
#include <X11/extensions/Xinerama.h>
#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

View File

@ -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;
}

View File

@ -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;