some minor fixes regarding the new xinerama support

This commit is contained in:
Anselm R Garbe 2009-06-20 16:18:02 +01:00
parent 3da2453997
commit 6644a6aa2e
1 changed files with 48 additions and 30 deletions

78
dwm.c
View File

@ -116,6 +116,7 @@ typedef struct {
typedef struct { typedef struct {
char symbol[4]; char symbol[4];
float mfact;
int by, btx; /* bar geometry */ int by, btx; /* bar geometry */
int wx, wy, ww, wh; /* window area */ int wx, wy, ww, wh; /* window area */
unsigned int seltags; unsigned int seltags;
@ -251,7 +252,7 @@ static Display *dpy;
static DC dc; static DC dc;
static Layout *lt[] = { NULL, NULL }; static Layout *lt[] = { NULL, NULL };
static Monitor *mon = NULL, *selmon = NULL; static Monitor *mon = NULL, *selmon = NULL;
static unsigned int nmons; static unsigned int nmons = 0;
static Window root; static Window root;
/* configuration, allows nested code to access above variables */ /* configuration, allows nested code to access above variables */
#include "config.h" #include "config.h"
@ -1322,10 +1323,10 @@ setmfact(const Arg *arg) {
if(!arg || !lt[selmon->sellt]->arrange) if(!arg || !lt[selmon->sellt]->arrange)
return; return;
f = arg->f < 1.0 ? arg->f + mfact : arg->f - 1.0; f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
if(f < 0.1 || f > 0.9) if(f < 0.1 || f > 0.9)
return; return;
mfact = f; selmon->mfact = f;
arrange(); arrange();
} }
@ -1483,7 +1484,7 @@ tile(Monitor *m) {
/* master */ /* master */
c = nexttiled(m, clients); c = nexttiled(m, clients);
mw = mfact * m->ww; mw = m->mfact * m->ww;
resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw); resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw);
if(--n == 0) if(--n == 0)
@ -1581,30 +1582,31 @@ unmapnotify(XEvent *e) {
void void
updategeom(void) { updategeom(void) {
#ifdef XINERAMA #ifdef XINERAMA
int di, x, y, n; int n;
unsigned int dui, i = 0; unsigned int i = 0;
Bool pquery;
Client *c; Client *c;
Window dummy;
XineramaScreenInfo *info = NULL; XineramaScreenInfo *info = NULL;
/* window area geometry */ /* window area geometry */
if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) { if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) {
nmons = (unsigned int)n; if(n != nmons) {
for(c = clients; c; c = c->next) for(c = clients; c; c = c->next)
if(c->mon >= nmons) if(c->mon >= n)
c->mon = nmons - 1; c->mon = n - 1;
if(!(mon = (Monitor *)realloc(mon, sizeof(Monitor) * nmons))) if(!(mon = (Monitor *)realloc(mon, sizeof(Monitor) * n)))
die("fatal: could not realloc() %u bytes\n", sizeof(Monitor) * nmons); die("fatal: could not realloc() %u bytes\n", sizeof(Monitor) * nmons);
pquery = XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui); }
for(i = 0; i < nmons; i++) { for(i = 0; i < n ; i++) {
/* TODO: consider re-using XineramaScreenInfo */ /* TODO: consider re-using XineramaScreenInfo */
mon[i].symbol[0] = '['; mon[i].symbol[0] = '[';
mon[i].symbol[1] = '0' + info[i].screen_number; mon[i].symbol[1] = '0' + info[i].screen_number;
mon[i].symbol[2] = ']'; mon[i].symbol[2] = ']';
mon[i].symbol[3] = 0; mon[i].symbol[3] = 0;
mon[i].showbar = showbar; if(!selmon) { /* not initialised yet */
mon[i].topbar = topbar; mon[i].mfact = mfact;
mon[i].showbar = showbar;
mon[i].topbar = topbar;
}
mon[i].wx = info[i].x_org; mon[i].wx = info[i].x_org;
mon[i].wy = mon[i].showbar && mon[i].topbar ? info[i].y_org + bh : info[i].y_org; mon[i].wy = mon[i].showbar && mon[i].topbar ? info[i].y_org + bh : info[i].y_org;
mon[i].ww = info[i].width; mon[i].ww = info[i].width;
@ -1615,24 +1617,39 @@ updategeom(void) {
mon[i].by = mon[i].topbar ? info[i].y_org : mon[i].wy + mon[i].wh; mon[i].by = mon[i].topbar ? info[i].y_org : mon[i].wy + mon[i].wh;
else else
mon[i].by = -bh; mon[i].by = -bh;
if(pquery && INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)) }
selmon = &mon[i]; nmons = (unsigned int)n;
if(!selmon) {
selmon = &mon[0];
int di, x, y;
unsigned int dui;
Window dummy;
if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui))
for(i = 0; i < nmons; i++)
if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)) {
selmon = &mon[i];
break;
}
} }
XFree(info); XFree(info);
} }
else else
#endif /* XINERAMA */ #endif /* XINERAMA */
{ {
nmons = 1; if(!mon) {
if(!(mon = (Monitor *)realloc(mon, sizeof(Monitor)))) nmons = 1;
die("fatal: could not realloc() %u bytes\n", sizeof(Monitor)); if(!(mon = (Monitor *)malloc(sizeof(Monitor))))
selmon = &mon[0]; die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
mon[0].symbol[0] = '['; }
mon[0].symbol[1] = '0'; if(!selmon) {
mon[0].symbol[2] = ']'; mon[0].symbol[0] = '[';
mon[0].symbol[3] = 0; mon[0].symbol[1] = '0';
mon[0].showbar = showbar; mon[0].symbol[2] = ']';
mon[0].topbar = topbar; mon[0].symbol[3] = 0;
mon[0].mfact = mfact;
mon[0].showbar = showbar;
mon[0].topbar = topbar;
}
mon[0].wx = sx; mon[0].wx = sx;
mon[0].wy = mon[0].showbar && mon[0].topbar ? sy + bh : sy; mon[0].wy = mon[0].showbar && mon[0].topbar ? sy + bh : sy;
mon[0].ww = sw; mon[0].ww = sw;
@ -1643,6 +1660,7 @@ updategeom(void) {
mon[0].by = mon[0].topbar ? sy : mon[0].wy + mon[0].wh; mon[0].by = mon[0].topbar ? sy : mon[0].wy + mon[0].wh;
else else
mon[0].by = -bh; mon[0].by = -bh;
selmon = &mon[0];
} }
} }