applied Gottox' monitor.diff patch (thanks btw)
4076e2ff
1 file(s) · +80 −67
| 60 | 60 | enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */ |
|
| 61 | 61 | ||
| 62 | 62 | /* typedefs */ |
|
| 63 | + | typedef struct Monitor Monitor; |
|
| 63 | 64 | typedef struct Client Client; |
|
| 64 | 65 | struct Client { |
|
| 65 | 66 | char name[256]; |
|
| 74 | 75 | Client *prev; |
|
| 75 | 76 | Client *snext; |
|
| 76 | 77 | Window win; |
|
| 77 | - | int monitor; |
|
| 78 | + | Monitor *monitor; |
|
| 78 | 79 | }; |
|
| 79 | 80 | ||
| 80 | 81 | typedef struct { |
|
| 99 | 100 | const char *arg; |
|
| 100 | 101 | } Key; |
|
| 101 | 102 | ||
| 102 | - | typedef struct Monitor Monitor; |
|
| 103 | 103 | typedef struct { |
|
| 104 | 104 | const char *symbol; |
|
| 105 | 105 | void (*arrange)(Monitor *); |
|
| 165 | 165 | void grabkeys(void); |
|
| 166 | 166 | unsigned int idxoftag(const char *tag); |
|
| 167 | 167 | void initfont(const char *fontstr); |
|
| 168 | - | Bool isoccupied(unsigned int monitor, unsigned int t); |
|
| 168 | + | Bool isoccupied(Monitor *monitor, unsigned int t); |
|
| 169 | 169 | Bool isprotodel(Client *c); |
|
| 170 | - | Bool isurgent(unsigned int monitor, unsigned int t); |
|
| 171 | - | Bool isvisible(Client *c, int monitor); |
|
| 170 | + | Bool isurgent(Monitor *monitor, unsigned int t); |
|
| 171 | + | Bool isvisible(Client *c, Monitor *m); |
|
| 172 | 172 | void keypress(XEvent *e); |
|
| 173 | 173 | void killclient(const char *arg); |
|
| 174 | 174 | void manage(Window w, XWindowAttributes *wa); |
|
| 175 | 175 | void mappingnotify(XEvent *e); |
|
| 176 | 176 | void maprequest(XEvent *e); |
|
| 177 | + | Monitor *monitorat(void); |
|
| 177 | 178 | void movemouse(Client *c); |
|
| 178 | - | Client *nexttiled(Client *c, int monitor); |
|
| 179 | + | Client *nexttiled(Client *c, Monitor *monitor); |
|
| 179 | 180 | void propertynotify(XEvent *e); |
|
| 180 | 181 | void quit(const char *arg); |
|
| 181 | 182 | void reapply(const char *arg); |
|
| 210 | 211 | int xerrordummy(Display *dsply, XErrorEvent *ee); |
|
| 211 | 212 | int xerrorstart(Display *dsply, XErrorEvent *ee); |
|
| 212 | 213 | void zoom(const char *arg); |
|
| 213 | - | int monitorat(void); |
|
| 214 | 214 | void movetomonitor(const char *arg); |
|
| 215 | 215 | void selectmonitor(const char *arg); |
|
| 216 | 216 | ||
| 217 | 217 | /* variables */ |
|
| 218 | 218 | char stext[256]; |
|
| 219 | 219 | int mcount = 1; |
|
| 220 | - | int selmonitor = 0; |
|
| 220 | + | Monitor *selmonitor; |
|
| 221 | 221 | int screen; |
|
| 222 | 222 | int (*xerrorxlib)(Display *, XErrorEvent *); |
|
| 223 | 223 | unsigned int bh, bpos; |
|
| 277 | 277 | if(regs[i].propregex && !regexec(regs[i].propregex, buf, 1, &tmp, 0)) { |
|
| 278 | 278 | if (rules[i].monitor >= 0 && rules[i].monitor < mcount) { |
|
| 279 | 279 | matched_monitor = True; |
|
| 280 | - | c->monitor = rules[i].monitor; |
|
| 280 | + | c->monitor = &monitors[rules[i].monitor]; |
|
| 281 | 281 | } |
|
| 282 | 282 | ||
| 283 | 283 | c->isfloating = rules[i].isfloating; |
|
| 293 | 293 | if(ch.res_name) |
|
| 294 | 294 | XFree(ch.res_name); |
|
| 295 | 295 | if(!matched_tag) |
|
| 296 | - | memcpy(c->tags, monitors[monitorat()].seltags, sizeof initags); |
|
| 296 | + | memcpy(c->tags, monitorat()->seltags, sizeof initags); |
|
| 297 | 297 | if (!matched_monitor) |
|
| 298 | 298 | c->monitor = monitorat(); |
|
| 299 | 299 | } |
|
| 308 | 308 | else |
|
| 309 | 309 | ban(c); |
|
| 310 | 310 | ||
| 311 | - | monitors[selmonitor].layout->arrange(&monitors[selmonitor]); |
|
| 311 | + | selmonitor->layout->arrange(selmonitor); |
|
| 312 | 312 | focus(NULL); |
|
| 313 | - | restack(&monitors[selmonitor]); |
|
| 313 | + | restack(selmonitor); |
|
| 314 | 314 | } |
|
| 315 | 315 | ||
| 316 | 316 | void |
|
| 331 | 331 | ban(Client *c) { |
|
| 332 | 332 | if(c->isbanned) |
|
| 333 | 333 | return; |
|
| 334 | - | XMoveWindow(dpy, c->win, c->x + 3 * monitors[c->monitor].sw, c->y); |
|
| 334 | + | XMoveWindow(dpy, c->win, c->x + 3 * c->monitor->sw, c->y); |
|
| 335 | 335 | c->isbanned = True; |
|
| 336 | 336 | } |
|
| 337 | 337 | ||
| 341 | 341 | Client *c; |
|
| 342 | 342 | XButtonPressedEvent *ev = &e->xbutton; |
|
| 343 | 343 | ||
| 344 | - | Monitor *m = &monitors[monitorat()]; |
|
| 344 | + | Monitor *m = monitorat(); |
|
| 345 | 345 | ||
| 346 | 346 | if(ev->window == m->barwin) { |
|
| 347 | 347 | x = 0; |
|
| 371 | 371 | if(CLEANMASK(ev->state) != MODKEY) |
|
| 372 | 372 | return; |
|
| 373 | 373 | if(ev->button == Button1) { |
|
| 374 | - | restack(&monitors[c->monitor]); |
|
| 374 | + | restack(c->monitor); |
|
| 375 | 375 | movemouse(c); |
|
| 376 | 376 | } |
|
| 377 | 377 | else if(ev->button == Button2) { |
|
| 381 | 381 | zoom(NULL); |
|
| 382 | 382 | } |
|
| 383 | 383 | else if(ev->button == Button3 && !c->isfixed) { |
|
| 384 | - | restack(&monitors[c->monitor]); |
|
| 384 | + | restack(c->monitor); |
|
| 385 | 385 | resizemouse(c); |
|
| 386 | 386 | } |
|
| 387 | 387 | } |
|
| 475 | 475 | void |
|
| 476 | 476 | configurenotify(XEvent *e) { |
|
| 477 | 477 | XConfigureEvent *ev = &e->xconfigure; |
|
| 478 | - | Monitor *m = &monitors[selmonitor]; |
|
| 478 | + | Monitor *m = selmonitor; |
|
| 479 | 479 | ||
| 480 | 480 | if(ev->window == root && (ev->width != m->sw || ev->height != m->sh)) { |
|
| 481 | 481 | /* TODO -- update Xinerama dimensions here */ |
|
| 496 | 496 | XWindowChanges wc; |
|
| 497 | 497 | ||
| 498 | 498 | if((c = getclient(ev->window))) { |
|
| 499 | - | Monitor *m = &monitors[c->monitor]; |
|
| 499 | + | Monitor *m = c->monitor; |
|
| 500 | 500 | if(ev->value_mask & CWBorderWidth) |
|
| 501 | 501 | c->border = ev->border_width; |
|
| 502 | 502 | if(c->isfixed || c->isfloating || (floating == m->layout->arrange)) { |
|
| 568 | 568 | Client *c; |
|
| 569 | 569 | ||
| 570 | 570 | dc.x = 0; |
|
| 571 | - | for(c = stack; c && !isvisible(c, m->id); c = c->snext); |
|
| 571 | + | for(c = stack; c && !isvisible(c, m); c = c->snext); |
|
| 572 | 572 | for(j = 0; j < LENGTH(tags); j++) { |
|
| 573 | 573 | dc.w = textw(tags[j]); |
|
| 574 | 574 | if(m->seltags[j]) { |
|
| 575 | - | drawtext(m, tags[j], dc.sel, isurgent(m->id, j)); |
|
| 576 | - | drawsquare(m, c && c->tags[j] && c->monitor == m->id, |
|
| 577 | - | isoccupied(m->id, j), isurgent(m->id, j), dc.sel); |
|
| 575 | + | drawtext(m, tags[j], dc.sel, isurgent(m, j)); |
|
| 576 | + | drawsquare(m, c && c->tags[j] && c->monitor == m, |
|
| 577 | + | isoccupied(m, j), isurgent(m, j), dc.sel); |
|
| 578 | 578 | } |
|
| 579 | 579 | else { |
|
| 580 | - | drawtext(m, tags[j], dc.norm, isurgent(m->id, j)); |
|
| 581 | - | drawsquare(m, c && c->tags[j] && c->monitor == m->id, |
|
| 582 | - | isoccupied(m->id, j), isurgent(m->id, j), dc.norm); |
|
| 580 | + | drawtext(m, tags[j], dc.norm, isurgent(m, j)); |
|
| 581 | + | drawsquare(m, c && c->tags[j] && c->monitor == m, |
|
| 582 | + | isoccupied(m, j), isurgent(m, j), dc.norm); |
|
| 583 | 583 | } |
|
| 584 | 584 | dc.x += dc.w; |
|
| 585 | 585 | } |
|
| 586 | 586 | dc.w = blw; |
|
| 587 | 587 | drawtext(m, m->layout->symbol, dc.norm, False); |
|
| 588 | 588 | x = dc.x + dc.w; |
|
| 589 | - | if(m->id == selmonitor) { |
|
| 589 | + | if(m == selmonitor) { |
|
| 590 | 590 | dc.w = textw(stext); |
|
| 591 | 591 | dc.x = m->sw - dc.w; |
|
| 592 | 592 | if(dc.x < x) { |
|
| 693 | 693 | focus(c); |
|
| 694 | 694 | else { |
|
| 695 | 695 | selmonitor = monitorat(); |
|
| 696 | - | fprintf(stderr, "updating selmonitor %d\n", selmonitor); |
|
| 696 | + | fprintf(stderr, "updating selmonitor %d\n", selmonitor - monitors); |
|
| 697 | 697 | focus(NULL); |
|
| 698 | 698 | } |
|
| 699 | 699 | } |
|
| 723 | 723 | ||
| 724 | 724 | domwfact = dozoom = False; |
|
| 725 | 725 | for(c = clients; c; c = c->next) |
|
| 726 | - | if(isvisible(c, m->id)) |
|
| 726 | + | if(isvisible(c, m)) |
|
| 727 | 727 | resize(c, c->x, c->y, c->w, c->h, True); |
|
| 728 | 728 | } |
|
| 729 | 729 | ||
| 730 | 730 | void |
|
| 731 | 731 | focus(Client *c) { |
|
| 732 | - | Monitor *m; |
|
| 733 | - | ||
| 734 | 732 | if(c) |
|
| 735 | 733 | selmonitor = c->monitor; |
|
| 736 | - | m = &monitors[selmonitor]; |
|
| 737 | 734 | if(!c || (c && !isvisible(c, selmonitor))) |
|
| 738 | 735 | for(c = stack; c && !isvisible(c, c->monitor); c = c->snext); |
|
| 739 | 736 | if(sel && sel != c) { |
|
| 753 | 750 | } |
|
| 754 | 751 | else |
|
| 755 | 752 | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
|
| 756 | - | drawbar(&monitors[selmonitor]); |
|
| 753 | + | drawbar(selmonitor); |
|
| 757 | 754 | } |
|
| 758 | 755 | ||
| 759 | 756 | void |
|
| 775 | 772 | for(c = clients; c && !isvisible(c, selmonitor); c = c->next); |
|
| 776 | 773 | if(c) { |
|
| 777 | 774 | focus(c); |
|
| 778 | - | restack(&monitors[c->monitor]); |
|
| 775 | + | restack(c->monitor); |
|
| 779 | 776 | } |
|
| 780 | 777 | } |
|
| 781 | 778 | ||
| 792 | 789 | } |
|
| 793 | 790 | if(c) { |
|
| 794 | 791 | focus(c); |
|
| 795 | - | restack(&monitors[c->monitor]); |
|
| 792 | + | restack(c->monitor); |
|
| 796 | 793 | } |
|
| 797 | 794 | } |
|
| 798 | 795 | ||
| 985 | 982 | } |
|
| 986 | 983 | ||
| 987 | 984 | Bool |
|
| 988 | - | isoccupied(unsigned int monitor, unsigned int t) { |
|
| 985 | + | isoccupied(Monitor *monitor, unsigned int t) { |
|
| 989 | 986 | Client *c; |
|
| 990 | 987 | ||
| 991 | 988 | for(c = clients; c; c = c->next) |
|
| 1010 | 1007 | } |
|
| 1011 | 1008 | ||
| 1012 | 1009 | Bool |
|
| 1013 | - | isurgent(unsigned int monitor, unsigned int t) { |
|
| 1010 | + | isurgent(Monitor *monitor, unsigned int t) { |
|
| 1014 | 1011 | Client *c; |
|
| 1015 | 1012 | ||
| 1016 | 1013 | for(c = clients; c; c = c->next) |
|
| 1020 | 1017 | } |
|
| 1021 | 1018 | ||
| 1022 | 1019 | Bool |
|
| 1023 | - | isvisible(Client *c, int monitor) { |
|
| 1020 | + | isvisible(Client *c, Monitor *m) { |
|
| 1024 | 1021 | unsigned int i; |
|
| 1025 | 1022 | ||
| 1026 | - | if(c->monitor != monitor) |
|
| 1023 | + | if(c->monitor != m) |
|
| 1027 | 1024 | return False; |
|
| 1028 | 1025 | for(i = 0; i < LENGTH(tags); i++) |
|
| 1029 | - | if(c->tags[i] && monitors[c->monitor].seltags[i]) |
|
| 1026 | + | if(c->tags[i] && c->monitor->seltags[i]) |
|
| 1030 | 1027 | return True; |
|
| 1031 | 1028 | return False; |
|
| 1032 | 1029 | } |
|
| 1081 | 1078 | ||
| 1082 | 1079 | applyrules(c); |
|
| 1083 | 1080 | ||
| 1084 | - | m = &monitors[c->monitor]; |
|
| 1081 | + | m = selmonitor; |
|
| 1085 | 1082 | ||
| 1086 | 1083 | c->x = wa->x + m->sx; |
|
| 1087 | 1084 | c->y = wa->y + m->sy; |
|
| 1150 | 1147 | manage(ev->window, &wa); |
|
| 1151 | 1148 | } |
|
| 1152 | 1149 | ||
| 1153 | - | int |
|
| 1150 | + | Monitor * |
|
| 1154 | 1151 | monitorat() { |
|
| 1155 | 1152 | int i, x, y; |
|
| 1156 | 1153 | Window win; |
|
| 1160 | 1157 | for(i = 0; i < mcount; i++) { |
|
| 1161 | 1158 | if((x >= monitors[i].sx && x < monitors[i].sx + monitors[i].sw) |
|
| 1162 | 1159 | && (y >= monitors[i].sy && y < monitors[i].sy + monitors[i].sh)) { |
|
| 1163 | - | return i; |
|
| 1160 | + | return &monitors[i]; |
|
| 1164 | 1161 | } |
|
| 1165 | 1162 | } |
|
| 1166 | - | return 0; |
|
| 1163 | + | return NULL; |
|
| 1167 | 1164 | } |
|
| 1168 | 1165 | ||
| 1169 | 1166 | void |
|
| 1176 | 1173 | ||
| 1177 | 1174 | ocx = nx = c->x; |
|
| 1178 | 1175 | ocy = ny = c->y; |
|
| 1179 | - | m = &monitors[c->monitor]; |
|
| 1176 | + | m = c->monitor; |
|
| 1180 | 1177 | if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, |
|
| 1181 | 1178 | None, cursor[CurMove], CurrentTime) != GrabSuccess) |
|
| 1182 | 1179 | return; |
|
| 1214 | 1211 | } |
|
| 1215 | 1212 | ||
| 1216 | 1213 | Client * |
|
| 1217 | - | nexttiled(Client *c, int monitor) { |
|
| 1214 | + | nexttiled(Client *c, Monitor *monitor) { |
|
| 1218 | 1215 | for(; c && (c->isfloating || !isvisible(c, monitor)); c = c->next); |
|
| 1219 | 1216 | return c; |
|
| 1220 | 1217 | } |
|
| 1240 | 1237 | break; |
|
| 1241 | 1238 | case XA_WM_HINTS: |
|
| 1242 | 1239 | updatewmhints(c); |
|
| 1243 | - | drawbar(&monitors[c->monitor]); |
|
| 1240 | + | drawbar(c->monitor); |
|
| 1244 | 1241 | break; |
|
| 1245 | 1242 | } |
|
| 1246 | 1243 | if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { |
|
| 1247 | 1244 | updatetitle(c); |
|
| 1248 | 1245 | if(c == sel) |
|
| 1249 | - | drawbar(&monitors[c->monitor]); |
|
| 1246 | + | drawbar(c->monitor); |
|
| 1250 | 1247 | } |
|
| 1251 | 1248 | } |
|
| 1252 | 1249 | } |
|
| 1273 | 1270 | Monitor *m; |
|
| 1274 | 1271 | XWindowChanges wc; |
|
| 1275 | 1272 | ||
| 1276 | - | m = &monitors[c->monitor]; |
|
| 1273 | + | m = c->monitor; |
|
| 1277 | 1274 | ||
| 1278 | 1275 | if(sizehints) { |
|
| 1279 | 1276 | /* set minimum possible */ |
|
| 1344 | 1341 | ||
| 1345 | 1342 | ocx = c->x; |
|
| 1346 | 1343 | ocy = c->y; |
|
| 1347 | - | m = &monitors[c->monitor]; |
|
| 1344 | + | m = c->monitor; |
|
| 1348 | 1345 | if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, |
|
| 1349 | 1346 | None, cursor[CurResize], CurrentTime) != GrabSuccess) |
|
| 1350 | 1347 | return; |
|
| 1396 | 1393 | XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc); |
|
| 1397 | 1394 | wc.sibling = sel->win; |
|
| 1398 | 1395 | } |
|
| 1399 | - | for(c = nexttiled(clients, m->id); c; c = nexttiled(c->next, m->id)) { |
|
| 1396 | + | for(c = nexttiled(clients, m); c; c = nexttiled(c->next, m)) { |
|
| 1400 | 1397 | if(c == sel) |
|
| 1401 | 1398 | continue; |
|
| 1402 | 1399 | XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc); |
|
| 1457 | 1454 | } |
|
| 1458 | 1455 | break; |
|
| 1459 | 1456 | } |
|
| 1460 | - | drawbar(&monitors[selmonitor]); |
|
| 1457 | + | drawbar(selmonitor); |
|
| 1461 | 1458 | } |
|
| 1462 | 1459 | while(XPending(dpy)) { |
|
| 1463 | 1460 | XNextEvent(dpy, &ev); |
|
| 1505 | 1502 | void |
|
| 1506 | 1503 | setlayout(const char *arg) { |
|
| 1507 | 1504 | unsigned int i; |
|
| 1508 | - | Monitor *m = &monitors[monitorat()]; |
|
| 1505 | + | Monitor *m = monitorat(); |
|
| 1509 | 1506 | ||
| 1510 | 1507 | if(!arg) { |
|
| 1511 | 1508 | m->layout++; |
|
| 1530 | 1527 | setmwfact(const char *arg) { |
|
| 1531 | 1528 | double delta; |
|
| 1532 | 1529 | ||
| 1533 | - | Monitor *m = &monitors[monitorat()]; |
|
| 1530 | + | Monitor *m = monitorat(); |
|
| 1534 | 1531 | ||
| 1535 | 1532 | if(!domwfact) |
|
| 1536 | 1533 | return; |
|
| 1574 | 1571 | mcount = 1; |
|
| 1575 | 1572 | if((isxinerama = XineramaIsActive(dpy))) |
|
| 1576 | 1573 | info = XineramaQueryScreens(dpy, &mcount); |
|
| 1577 | - | monitors = emallocz(mcount * sizeof(Monitor)); |
|
| 1574 | + | selmonitor = monitors = emallocz(mcount * sizeof(Monitor)); |
|
| 1578 | 1575 | ||
| 1579 | 1576 | screen = DefaultScreen(dpy); |
|
| 1580 | 1577 | root = RootWindow(dpy, screen); |
|
| 1665 | 1662 | compileregs(); |
|
| 1666 | 1663 | ||
| 1667 | 1664 | selmonitor = monitorat(); |
|
| 1668 | - | fprintf(stderr, "selmonitor == %d\n", selmonitor); |
|
| 1665 | + | fprintf(stderr, "selmonitor == %d\n", selmonitor - monitors); |
|
| 1669 | 1666 | } |
|
| 1670 | 1667 | ||
| 1671 | 1668 | void |
|
| 1729 | 1726 | ||
| 1730 | 1727 | nx = ny = nw = 0; /* gcc stupidity requires this */ |
|
| 1731 | 1728 | ||
| 1732 | - | for(n = 0, c = nexttiled(clients, m->id); c; c = nexttiled(c->next, m->id)) |
|
| 1729 | + | for(n = 0, c = nexttiled(clients, m); c; c = nexttiled(c->next, m)) |
|
| 1733 | 1730 | n++; |
|
| 1734 | 1731 | ||
| 1735 | 1732 | /* window geoms */ |
|
| 1738 | 1735 | if(n > 1 && th < bh) |
|
| 1739 | 1736 | th = m->wah; |
|
| 1740 | 1737 | ||
| 1741 | - | for(i = 0, c = mc = nexttiled(clients, m->id); c; c = nexttiled(c->next, m->id)) { |
|
| 1738 | + | for(i = 0, c = mc = nexttiled(clients, m); c; c = nexttiled(c->next, m)) { |
|
| 1742 | 1739 | if(i == 0) { /* master */ |
|
| 1743 | 1740 | nx = m->wax; |
|
| 1744 | 1741 | ny = m->way; |
|
| 1772 | 1769 | bpos = (BARPOS == BarOff) ? BarTop : BARPOS; |
|
| 1773 | 1770 | else |
|
| 1774 | 1771 | bpos = BarOff; |
|
| 1775 | - | updatebarpos(&monitors[monitorat()]); |
|
| 1772 | + | updatebarpos(monitorat()); |
|
| 1776 | 1773 | arrange(); |
|
| 1777 | 1774 | } |
|
| 1778 | 1775 | ||
| 1804 | 1801 | toggleview(const char *arg) { |
|
| 1805 | 1802 | unsigned int i, j; |
|
| 1806 | 1803 | ||
| 1807 | - | Monitor *m = &monitors[monitorat()]; |
|
| 1804 | + | Monitor *m = monitorat(); |
|
| 1808 | 1805 | ||
| 1809 | 1806 | i = idxoftag(arg); |
|
| 1810 | 1807 | m->seltags[i] = !m->seltags[i]; |
|
| 1984 | 1981 | view(const char *arg) { |
|
| 1985 | 1982 | unsigned int i; |
|
| 1986 | 1983 | Bool tmp[LENGTH(tags)]; |
|
| 1987 | - | Monitor *m = &monitors[monitorat()]; |
|
| 1984 | + | Monitor *m = monitorat(); |
|
| 1988 | 1985 | ||
| 1989 | 1986 | for(i = 0; i < LENGTH(tags); i++) |
|
| 1990 | 1987 | tmp[i] = (NULL == arg); |
|
| 2000 | 1997 | viewprevtag(const char *arg) { |
|
| 2001 | 1998 | static Bool tmp[LENGTH(tags)]; |
|
| 2002 | 1999 | ||
| 2003 | - | Monitor *m = &monitors[monitorat()]; |
|
| 2000 | + | Monitor *m = monitorat(); |
|
| 2004 | 2001 | ||
| 2005 | 2002 | memcpy(tmp, m->seltags, sizeof initags); |
|
| 2006 | 2003 | memcpy(m->seltags, m->prevtags, sizeof initags); |
|
| 2025 | 2022 | ||
| 2026 | 2023 | void |
|
| 2027 | 2024 | movetomonitor(const char *arg) { |
|
| 2028 | - | if (sel) { |
|
| 2029 | - | sel->monitor = arg ? atoi(arg) : (sel->monitor+1) % mcount; |
|
| 2025 | + | int i; |
|
| 2030 | 2026 | ||
| 2031 | - | memcpy(sel->tags, monitors[sel->monitor].seltags, sizeof initags); |
|
| 2032 | - | resize(sel, monitors[sel->monitor].wax, monitors[sel->monitor].way, sel->w, sel->h, True); |
|
| 2033 | - | arrange(); |
|
| 2027 | + | if (sel) |
|
| 2028 | + | return; |
|
| 2029 | + | if(arg) |
|
| 2030 | + | i = atoi(arg); |
|
| 2031 | + | else { |
|
| 2032 | + | for(i = 0; &monitors[i] != sel->monitor && i < mcount; i++); |
|
| 2033 | + | i++; |
|
| 2034 | 2034 | } |
|
| 2035 | + | sel->monitor = &monitors[i % mcount]; |
|
| 2036 | + | ||
| 2037 | + | memcpy(sel->tags, sel->monitor->seltags, sizeof initags); |
|
| 2038 | + | resize(sel, sel->monitor->wax, sel->monitor->way, sel->w, sel->h, True); |
|
| 2039 | + | arrange(); |
|
| 2035 | 2040 | } |
|
| 2036 | 2041 | ||
| 2037 | 2042 | void |
|
| 2038 | 2043 | selectmonitor(const char *arg) { |
|
| 2039 | - | Monitor *m = &monitors[arg ? atoi(arg) : (monitorat()+1) % mcount]; |
|
| 2044 | + | int i; |
|
| 2045 | + | Monitor *m; |
|
| 2040 | 2046 | ||
| 2047 | + | if(arg) |
|
| 2048 | + | i = atoi(arg); |
|
| 2049 | + | else { |
|
| 2050 | + | for(i = 0; &monitors[i] != sel->monitor && i < mcount; i++); |
|
| 2051 | + | i++; |
|
| 2052 | + | } |
|
| 2053 | + | m = &monitors[i % mcount]; |
|
| 2041 | 2054 | XWarpPointer(dpy, None, root, 0, 0, 0, 0, m->wax+m->waw/2, m->way+m->wah/2); |
|
| 2042 | 2055 | focus(NULL); |
|
| 2043 | 2056 | } |
|