summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorAnselm R Garbe <anselm@garbe.us>2009-06-19 20:15:15 +0100
committerAnselm R Garbe <anselm@garbe.us>2009-06-19 20:15:15 +0100
commitf27ccc5c60e4518c90f33bb20e68ea7bb23a2947 (patch)
treee0d504da2f9987851938d929dc77e6ab51870512 /dwm.c
parentremoved MAXTAGLEN (diff)
downloaddwm-f27ccc5c60e4518c90f33bb20e68ea7bb23a2947.tar.gz
dwm-f27ccc5c60e4518c90f33bb20e68ea7bb23a2947.zip
introduction of Monitor for better Xinerama support, work in progress
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c183
1 files changed, 107 insertions, 76 deletions
diff --git a/dwm.c b/dwm.c
index 1709db0..75c9a76 100644
--- a/dwm.c
+++ b/dwm.c
@@ -44,7 +44,7 @@
44#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) 44#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
45#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) 45#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask))
46#define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) 46#define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
47#define ISVISIBLE(x) (x->tags & tagset[seltags]) 47#define ISVISIBLE(x) (x->tags & tagset[selmon->seltags])
48#define LENGTH(x) (sizeof x / sizeof x[0]) 48#define LENGTH(x) (sizeof x / sizeof x[0])
49#define MAX(a, b) ((a) > (b) ? (a) : (b)) 49#define MAX(a, b) ((a) > (b) ? (a) : (b))
50#define MIN(a, b) ((a) < (b) ? (a) : (b)) 50#define MIN(a, b) ((a) < (b) ? (a) : (b))
@@ -85,6 +85,7 @@ struct Client {
85 int basew, baseh, incw, inch, maxw, maxh, minw, minh; 85 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
86 int bw, oldbw; 86 int bw, oldbw;
87 unsigned int tags; 87 unsigned int tags;
88 unsigned int mon;
88 Bool isfixed, isfloating, isurgent; 89 Bool isfixed, isfloating, isurgent;
89 Client *next; 90 Client *next;
90 Client *snext; 91 Client *snext;
@@ -119,6 +120,12 @@ typedef struct {
119} Layout; 120} Layout;
120 121
121typedef struct { 122typedef struct {
123 int wx, wy, ww, wh;
124 unsigned int seltags;
125 unsigned int sellt;
126} Monitor;
127
128typedef struct {
122 const char *class; 129 const char *class;
123 const char *instance; 130 const char *instance;
124 const char *title; 131 const char *title;
@@ -208,8 +215,6 @@ static char stext[256];
208static int screen; 215static int screen;
209static int sx, sy, sw, sh; /* X display screen geometry x, y, width, height */ 216static int sx, sy, sw, sh; /* X display screen geometry x, y, width, height */
210static int by, bh, blw; /* bar geometry y, height and layout symbol width */ 217static int by, bh, blw; /* bar geometry y, height and layout symbol width */
211static int wx, wy, ww, wh; /* window area geometry x, y, width, height, bar excluded */
212static unsigned int seltags = 0, sellt = 0;
213static int (*xerrorxlib)(Display *, XErrorEvent *); 218static int (*xerrorxlib)(Display *, XErrorEvent *);
214static unsigned int numlockmask = 0; 219static unsigned int numlockmask = 0;
215static void (*handler[LASTEvent]) (XEvent *) = { 220static void (*handler[LASTEvent]) (XEvent *) = {
@@ -236,6 +241,8 @@ static Cursor cursor[CurLast];
236static Display *dpy; 241static Display *dpy;
237static DC dc; 242static DC dc;
238static Layout *lt[] = { NULL, NULL }; 243static Layout *lt[] = { NULL, NULL };
244static Monitor *mon = NULL, *selmon = NULL;
245static unsigned int nmons;
239static Window root, barwin; 246static Window root, barwin;
240/* configuration, allows nested code to access above variables */ 247/* configuration, allows nested code to access above variables */
241#include "config.h" 248#include "config.h"
@@ -267,7 +274,7 @@ applyrules(Client *c) {
267 if(ch.res_name) 274 if(ch.res_name)
268 XFree(ch.res_name); 275 XFree(ch.res_name);
269 } 276 }
270 c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : tagset[seltags]; 277 c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : tagset[mon[c->mon].seltags];
271} 278}
272 279
273Bool 280Bool
@@ -339,8 +346,8 @@ void
339arrange(void) { 346arrange(void) {
340 showhide(stack); 347 showhide(stack);
341 focus(NULL); 348 focus(NULL);
342 if(lt[sellt]->arrange) 349 if(lt[selmon->sellt]->arrange)
343 lt[sellt]->arrange(); 350 lt[selmon->sellt]->arrange();
344 restack(); 351 restack();
345} 352}
346 353
@@ -373,7 +380,7 @@ buttonpress(XEvent *e) {
373 } 380 }
374 else if(ev->x < x + blw) 381 else if(ev->x < x + blw)
375 click = ClkLtSymbol; 382 click = ClkLtSymbol;
376 else if(ev->x > wx + ww - TEXTW(stext)) 383 else if(ev->x > selmon->wx + selmon->ww - TEXTW(stext))
377 click = ClkStatusText; 384 click = ClkStatusText;
378 else 385 else
379 click = ClkWinTitle; 386 click = ClkWinTitle;
@@ -409,7 +416,7 @@ cleanup(void) {
409 Layout foo = { "", NULL }; 416 Layout foo = { "", NULL };
410 417
411 view(&a); 418 view(&a);
412 lt[sellt] = &foo; 419 lt[selmon->sellt] = &foo;
413 while(stack) 420 while(stack)
414 unmanage(stack); 421 unmanage(stack);
415 if(dc.font.set) 422 if(dc.font.set)
@@ -479,7 +486,7 @@ configurerequest(XEvent *e) {
479 if((c = getclient(ev->window))) { 486 if((c = getclient(ev->window))) {
480 if(ev->value_mask & CWBorderWidth) 487 if(ev->value_mask & CWBorderWidth)
481 c->bw = ev->border_width; 488 c->bw = ev->border_width;
482 else if(c->isfloating || !lt[sellt]->arrange) { 489 else if(c->isfloating || !lt[selmon->sellt]->arrange) {
483 if(ev->value_mask & CWX) 490 if(ev->value_mask & CWX)
484 c->x = sx + ev->x; 491 c->x = sx + ev->x;
485 if(ev->value_mask & CWY) 492 if(ev->value_mask & CWY)
@@ -564,23 +571,23 @@ drawbar(void) {
564 dc.x = 0; 571 dc.x = 0;
565 for(i = 0; i < LENGTH(tags); i++) { 572 for(i = 0; i < LENGTH(tags); i++) {
566 dc.w = TEXTW(tags[i]); 573 dc.w = TEXTW(tags[i]);
567 col = tagset[seltags] & 1 << i ? dc.sel : dc.norm; 574 col = tagset[selmon->seltags] & 1 << i ? dc.sel : dc.norm;
568 drawtext(tags[i], col, urg & 1 << i); 575 drawtext(tags[i], col, urg & 1 << i);
569 drawsquare(sel && sel->tags & 1 << i, occ & 1 << i, urg & 1 << i, col); 576 drawsquare(sel && sel->tags & 1 << i, occ & 1 << i, urg & 1 << i, col);
570 dc.x += dc.w; 577 dc.x += dc.w;
571 } 578 }
572 if(blw > 0) { 579 if(blw > 0) {
573 dc.w = blw; 580 dc.w = blw;
574 drawtext(lt[sellt]->symbol, dc.norm, False); 581 drawtext(lt[selmon->sellt]->symbol, dc.norm, False);
575 x = dc.x + dc.w; 582 x = dc.x + dc.w;
576 } 583 }
577 else 584 else
578 x = dc.x; 585 x = dc.x;
579 dc.w = TEXTW(stext); 586 dc.w = TEXTW(stext);
580 dc.x = ww - dc.w; 587 dc.x = selmon->ww - dc.w;
581 if(dc.x < x) { 588 if(dc.x < x) {
582 dc.x = x; 589 dc.x = x;
583 dc.w = ww - x; 590 dc.w = selmon->ww - x;
584 } 591 }
585 drawtext(stext, dc.norm, False); 592 drawtext(stext, dc.norm, False);
586 if((dc.w = dc.x - x) > bh) { 593 if((dc.w = dc.x - x) > bh) {
@@ -592,7 +599,7 @@ drawbar(void) {
592 else 599 else
593 drawtext(NULL, dc.norm, False); 600 drawtext(NULL, dc.norm, False);
594 } 601 }
595 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, ww, bh, 0, 0); 602 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, selmon->ww, bh, 0, 0);
596 XSync(dpy, False); 603 XSync(dpy, False);
597} 604}
598 605
@@ -919,6 +926,7 @@ manage(Window w, XWindowAttributes *wa) {
919 die("fatal: could not malloc() %u bytes\n", sizeof(Client)); 926 die("fatal: could not malloc() %u bytes\n", sizeof(Client));
920 *c = cz; 927 *c = cz;
921 c->win = w; 928 c->win = w;
929 for(c->mon = 0; selmon != &mon[c->mon]; c->mon++);
922 930
923 /* geometry */ 931 /* geometry */
924 c->x = wa->x; 932 c->x = wa->x;
@@ -938,8 +946,9 @@ manage(Window w, XWindowAttributes *wa) {
938 c->y = sy + sh - HEIGHT(c); 946 c->y = sy + sh - HEIGHT(c);
939 c->x = MAX(c->x, sx); 947 c->x = MAX(c->x, sx);
940 /* only fix client y-offset, if the client center might cover the bar */ 948 /* only fix client y-offset, if the client center might cover the bar */
941 c->y = MAX(c->y, ((by == 0) && (c->x + (c->w / 2) >= wx) 949 /* TODO: is c always attached to selmon? */
942 && (c->x + (c->w / 2) < wx + ww)) ? bh : sy); 950 c->y = MAX(c->y, ((by == 0) && (c->x + (c->w / 2) >= selmon->wx)
951 && (c->x + (c->w / 2) < selmon->wx + selmon->ww)) ? bh : sy);
943 c->bw = borderpx; 952 c->bw = borderpx;
944 } 953 }
945 954
@@ -994,9 +1003,11 @@ maprequest(XEvent *e) {
994void 1003void
995monocle(void) { 1004monocle(void) {
996 Client *c; 1005 Client *c;
1006 Monitor *m;
997 1007
998 for(c = nexttiled(clients); c; c = nexttiled(c->next)) { 1008 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
999 resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw); 1009 m = &mon[c->mon];
1010 resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw);
1000 } 1011 }
1001} 1012}
1002 1013
@@ -1028,21 +1039,21 @@ movemouse(const Arg *arg) {
1028 case MotionNotify: 1039 case MotionNotify:
1029 nx = ocx + (ev.xmotion.x - x); 1040 nx = ocx + (ev.xmotion.x - x);
1030 ny = ocy + (ev.xmotion.y - y); 1041 ny = ocy + (ev.xmotion.y - y);
1031 if(snap && nx >= wx && nx <= wx + ww 1042 if(snap && nx >= selmon->wx && nx <= selmon->wx + selmon->ww
1032 && ny >= wy && ny <= wy + wh) { 1043 && ny >= selmon->wy && ny <= selmon->wy + selmon->wh) {
1033 if(abs(wx - nx) < snap) 1044 if(abs(selmon->wx - nx) < snap)
1034 nx = wx; 1045 nx = selmon->wx;
1035 else if(abs((wx + ww) - (nx + WIDTH(c))) < snap) 1046 else if(abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap)
1036 nx = wx + ww - WIDTH(c); 1047 nx = selmon->wx + selmon->ww - WIDTH(c);
1037 if(abs(wy - ny) < snap) 1048 if(abs(selmon->wy - ny) < snap)
1038 ny = wy; 1049 ny = selmon->wy;
1039 else if(abs((wy + wh) - (ny + HEIGHT(c))) < snap) 1050 else if(abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap)
1040 ny = wy + wh - HEIGHT(c); 1051 ny = selmon->wy + selmon->wh - HEIGHT(c);
1041 if(!c->isfloating && lt[sellt]->arrange 1052 if(!c->isfloating && lt[selmon->sellt]->arrange
1042 && (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) 1053 && (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
1043 togglefloating(NULL); 1054 togglefloating(NULL);
1044 } 1055 }
1045 if(!lt[sellt]->arrange || c->isfloating) 1056 if(!lt[selmon->sellt]->arrange || c->isfloating)
1046 resize(c, nx, ny, c->w, c->h); 1057 resize(c, nx, ny, c->w, c->h);
1047 break; 1058 break;
1048 } 1059 }
@@ -1141,13 +1152,13 @@ resizemouse(const Arg *arg) {
1141 nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); 1152 nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
1142 nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); 1153 nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
1143 1154
1144 if(snap && nw >= wx && nw <= wx + ww 1155 if(snap && nw >= selmon->wx && nw <= selmon->wx + selmon->ww
1145 && nh >= wy && nh <= wy + wh) { 1156 && nh >= selmon->wy && nh <= selmon->wy + selmon->wh) {
1146 if(!c->isfloating && lt[sellt]->arrange 1157 if(!c->isfloating && lt[selmon->sellt]->arrange
1147 && (abs(nw - c->w) > snap || abs(nh - c->h) > snap)) 1158 && (abs(nw - c->w) > snap || abs(nh - c->h) > snap))
1148 togglefloating(NULL); 1159 togglefloating(NULL);
1149 } 1160 }
1150 if(!lt[sellt]->arrange || c->isfloating) 1161 if(!lt[selmon->sellt]->arrange || c->isfloating)
1151 resize(c, c->x, c->y, nw, nh); 1162 resize(c, c->x, c->y, nw, nh);
1152 break; 1163 break;
1153 } 1164 }
@@ -1167,9 +1178,9 @@ restack(void) {
1167 drawbar(); 1178 drawbar();
1168 if(!sel) 1179 if(!sel)
1169 return; 1180 return;
1170 if(sel->isfloating || !lt[sellt]->arrange) 1181 if(sel->isfloating || !lt[selmon->sellt]->arrange)
1171 XRaiseWindow(dpy, sel->win); 1182 XRaiseWindow(dpy, sel->win);
1172 if(lt[sellt]->arrange) { 1183 if(lt[selmon->sellt]->arrange) {
1173 wc.stack_mode = Below; 1184 wc.stack_mode = Below;
1174 wc.sibling = barwin; 1185 wc.sibling = barwin;
1175 for(c = stack; c; c = c->snext) 1186 for(c = stack; c; c = c->snext)
@@ -1230,10 +1241,10 @@ setclientstate(Client *c, long state) {
1230 1241
1231void 1242void
1232setlayout(const Arg *arg) { 1243setlayout(const Arg *arg) {
1233 if(!arg || !arg->v || arg->v != lt[sellt]) 1244 if(!arg || !arg->v || arg->v != lt[selmon->sellt])
1234 sellt ^= 1; 1245 selmon->sellt ^= 1;
1235 if(arg && arg->v) 1246 if(arg && arg->v)
1236 lt[sellt] = (Layout *)arg->v; 1247 lt[selmon->sellt] = (Layout *)arg->v;
1237 if(sel) 1248 if(sel)
1238 arrange(); 1249 arrange();
1239 else 1250 else
@@ -1245,7 +1256,7 @@ void
1245setmfact(const Arg *arg) { 1256setmfact(const Arg *arg) {
1246 float f; 1257 float f;
1247 1258
1248 if(!arg || !lt[sellt]->arrange) 1259 if(!arg || !lt[selmon->sellt]->arrange)
1249 return; 1260 return;
1250 f = arg->f < 1.0 ? arg->f + mfact : arg->f - 1.0; 1261 f = arg->f < 1.0 ? arg->f + mfact : arg->f - 1.0;
1251 if(f < 0.1 || f > 0.9) 1262 if(f < 0.1 || f > 0.9)
@@ -1308,7 +1319,7 @@ setup(void) {
1308 wa.background_pixmap = ParentRelative; 1319 wa.background_pixmap = ParentRelative;
1309 wa.event_mask = ButtonPressMask|ExposureMask; 1320 wa.event_mask = ButtonPressMask|ExposureMask;
1310 1321
1311 barwin = XCreateWindow(dpy, root, wx, by, ww, bh, 0, DefaultDepth(dpy, screen), 1322 barwin = XCreateWindow(dpy, root, selmon->wx, by, selmon->ww, bh, 0, DefaultDepth(dpy, screen),
1312 CopyFromParent, DefaultVisual(dpy, screen), 1323 CopyFromParent, DefaultVisual(dpy, screen),
1313 CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); 1324 CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
1314 XDefineCursor(dpy, barwin, cursor[CurNormal]); 1325 XDefineCursor(dpy, barwin, cursor[CurNormal]);
@@ -1335,7 +1346,7 @@ showhide(Client *c) {
1335 return; 1346 return;
1336 if(ISVISIBLE(c)) { /* show clients top down */ 1347 if(ISVISIBLE(c)) { /* show clients top down */
1337 XMoveWindow(dpy, c->win, c->x, c->y); 1348 XMoveWindow(dpy, c->win, c->x, c->y);
1338 if(!lt[sellt]->arrange || c->isfloating) 1349 if(!lt[selmon->sellt]->arrange || c->isfloating)
1339 resize(c, c->x, c->y, c->w, c->h); 1350 resize(c, c->x, c->y, c->w, c->h);
1340 showhide(c->snext); 1351 showhide(c->snext);
1341 } 1352 }
@@ -1389,6 +1400,7 @@ tile(void) {
1389 int x, y, h, w, mw; 1400 int x, y, h, w, mw;
1390 unsigned int i, n; 1401 unsigned int i, n;
1391 Client *c; 1402 Client *c;
1403 Monitor *m;
1392 1404
1393 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++); 1405 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++);
1394 if(n == 0) 1406 if(n == 0)
@@ -1396,24 +1408,25 @@ tile(void) {
1396 1408
1397 /* master */ 1409 /* master */
1398 c = nexttiled(clients); 1410 c = nexttiled(clients);
1399 mw = mfact * ww; 1411 m = &mon[c->mon];
1400 resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw); 1412 mw = mfact * m->ww;
1413 resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw);
1401 1414
1402 if(--n == 0) 1415 if(--n == 0)
1403 return; 1416 return;
1404 1417
1405 /* tile stack */ 1418 /* tile stack */
1406 x = (wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : wx + mw; 1419 x = (m->wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : m->wx + mw;
1407 y = wy; 1420 y = m->wy;
1408 w = (wx + mw > c->x + c->w) ? wx + ww - x : ww - mw; 1421 w = (m->wx + mw > c->x + c->w) ? m->wx + m->ww - x : m->ww - mw;
1409 h = wh / n; 1422 h = m->wh / n;
1410 if(h < bh) 1423 if(h < bh)
1411 h = wh; 1424 h = m->wh;
1412 1425
1413 for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { 1426 for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
1414 resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) 1427 resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
1415 ? wy + wh - y - 2 * c->bw : h - 2 * c->bw)); 1428 ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw));
1416 if(h != wh) 1429 if(h != m->wh)
1417 y = c->y + HEIGHT(c); 1430 y = c->y + HEIGHT(c);
1418 } 1431 }
1419} 1432}
@@ -1452,10 +1465,10 @@ toggletag(const Arg *arg) {
1452 1465
1453void 1466void
1454toggleview(const Arg *arg) { 1467toggleview(const Arg *arg) {
1455 unsigned int mask = tagset[seltags] ^ (arg->ui & TAGMASK); 1468 unsigned int mask = tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
1456 1469
1457 if(mask) { 1470 if(mask) {
1458 tagset[seltags] = mask; 1471 tagset[selmon->seltags] = mask;
1459 arrange(); 1472 arrange();
1460 } 1473 }
1461} 1474}
@@ -1495,44 +1508,62 @@ void
1495updatebar(void) { 1508updatebar(void) {
1496 if(dc.drawable != 0) 1509 if(dc.drawable != 0)
1497 XFreePixmap(dpy, dc.drawable); 1510 XFreePixmap(dpy, dc.drawable);
1498 dc.drawable = XCreatePixmap(dpy, root, ww, bh, DefaultDepth(dpy, screen)); 1511 dc.drawable = XCreatePixmap(dpy, root, selmon->ww, bh, DefaultDepth(dpy, screen));
1499 XMoveResizeWindow(dpy, barwin, wx, by, ww, bh); 1512 XMoveResizeWindow(dpy, barwin, selmon->wx, by, selmon->ww, bh);
1500} 1513}
1501 1514
1502void 1515void
1503updategeom(void) { 1516updategeom(void) {
1504#ifdef XINERAMA 1517#ifdef XINERAMA
1505 int n, i = 0; 1518 int di, x, y, n;
1519 unsigned int dui, i = 0;
1520 Bool pquery;
1521 Client *c;
1522 Window dummy;
1506 XineramaScreenInfo *info = NULL; 1523 XineramaScreenInfo *info = NULL;
1507 1524
1508 /* window area geometry */ 1525 /* window area geometry */
1509 if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) { 1526 if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) {
1510 if(n > 1) { 1527 nmons = (unsigned int)n;
1511 int di, x, y; 1528 for(c = clients; c; c = c->next)
1512 unsigned int dui; 1529 if(c->mon >= nmons)
1513 Window dummy; 1530 c->mon = nmons - 1;
1514 if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui)) 1531 if(!(mon = (Monitor *)realloc(mon, sizeof(Monitor) * nmons)))
1515 for(i = 0; i < n; i++) 1532 die("fatal: could not realloc() %u bytes\n", sizeof(Monitor) * nmons);
1516 if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)) 1533 pquery = XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui);
1517 break; 1534 for(i = 0; i < nmons; i++) {
1535 /* TODO: consider re-using XineramaScreenInfo */
1536 mon[i].wx = info[i].x_org;
1537 mon[i].wy = info[i].y_org;
1538 mon[i].ww = info[i].width;
1539 mon[i].wh = info[i].height;
1540 mon[i].seltags = 0;
1541 mon[i].sellt = 0;
1542 if(pquery && INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height))
1543 selmon = &mon[i];
1518 } 1544 }
1519 wx = info[i].x_org; 1545 /* bar adjustments of selmon */
1520 wy = showbar && topbar ? info[i].y_org + bh : info[i].y_org; 1546 selmon->wy = showbar && topbar ? selmon->wy + bh : selmon->wy;
1521 ww = info[i].width; 1547 selmon->wh = showbar ? selmon->wh - bh : selmon->wh;
1522 wh = showbar ? info[i].height - bh : info[i].height;
1523 XFree(info); 1548 XFree(info);
1524 } 1549 }
1525 else 1550 else
1526#endif 1551#endif
1527 { 1552 {
1528 wx = sx; 1553 nmons = 1;
1529 wy = showbar && topbar ? sy + bh : sy; 1554 if(!(mon = (Monitor *)realloc(mon, sizeof(Monitor))))
1530 ww = sw; 1555 die("fatal: could not realloc() %u bytes\n", sizeof(Monitor));
1531 wh = showbar ? sh - bh : sh; 1556 selmon = &mon[0];
1557 mon[0].wx = sx;
1558 mon[0].wy = showbar && topbar ? sy + bh : sy;
1559 mon[0].ww = sw;
1560 mon[0].wh = showbar ? sh - bh : sh;
1561 mon[0].seltags = 0;
1562 mon[0].sellt = 0;
1532 } 1563 }
1533 1564
1534 /* bar position */ 1565 /* bar position */
1535 by = showbar ? (topbar ? wy - bh : wy + wh) : -bh; 1566 by = showbar ? (topbar ? selmon->wy - bh : selmon->wy + selmon->wh) : -bh;
1536} 1567}
1537 1568
1538void 1569void
@@ -1631,11 +1662,11 @@ updatewmhints(Client *c) {
1631 1662
1632void 1663void
1633view(const Arg *arg) { 1664view(const Arg *arg) {
1634 if((arg->ui & TAGMASK) == tagset[seltags]) 1665 if((arg->ui & TAGMASK) == tagset[selmon->seltags])
1635 return; 1666 return;
1636 seltags ^= 1; /* toggle sel tagset */ 1667 selmon->seltags ^= 1; /* toggle sel tagset */
1637 if(arg->ui & TAGMASK) 1668 if(arg->ui & TAGMASK)
1638 tagset[seltags] = arg->ui & TAGMASK; 1669 tagset[selmon->seltags] = arg->ui & TAGMASK;
1639 arrange(); 1670 arrange();
1640} 1671}
1641 1672
@@ -1676,7 +1707,7 @@ void
1676zoom(const Arg *arg) { 1707zoom(const Arg *arg) {
1677 Client *c = sel; 1708 Client *c = sel;
1678 1709
1679 if(!lt[sellt]->arrange || lt[sellt]->arrange == monocle || (sel && sel->isfloating)) 1710 if(!lt[selmon->sellt]->arrange || lt[selmon->sellt]->arrange == monocle || (sel && sel->isfloating))
1680 return; 1711 return;
1681 if(c == nexttiled(clients)) 1712 if(c == nexttiled(clients))
1682 if(!c || !(c = nexttiled(c->next))) 1713 if(!c || !(c = nexttiled(c->next)))