summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorAnselm R Garbe <anselm@garbe.us>2009-09-18 21:18:00 +0100
committerAnselm R Garbe <anselm@garbe.us>2009-09-18 21:18:00 +0100
commit82ec7a7ed4f3ba376faadfc2aca783b24618575f (patch)
treef6e5cfadb9a910341f2a9b13af082279c852188b /dwm.c
parentimplemented dynamic layout symbol stuff (diff)
downloaddwm-82ec7a7ed4f3ba376faadfc2aca783b24618575f.tar.gz
dwm-82ec7a7ed4f3ba376faadfc2aca783b24618575f.zip
new experimental updategeom() additions that should avoid several problems with Xinerama, this is EXPERIMENTAL and might break something, the algorithms in use are quite complex and cumbersome, patches and comments welcome
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c101
1 files changed, 77 insertions, 24 deletions
diff --git a/dwm.c b/dwm.c
index 1cb07d3..2b4d6b0 100644
--- a/dwm.c
+++ b/dwm.c
@@ -221,7 +221,7 @@ static void toggleview(const Arg *arg);
221static void unfocus(Client *c); 221static void unfocus(Client *c);
222static void unmanage(Client *c, Bool destroyed); 222static void unmanage(Client *c, Bool destroyed);
223static void unmapnotify(XEvent *e); 223static void unmapnotify(XEvent *e);
224static void updategeom(void); 224static Bool updategeom(void);
225static void updatebarpos(Monitor *m); 225static void updatebarpos(Monitor *m);
226static void updatebars(void); 226static void updatebars(void);
227static void updatenumlockmask(void); 227static void updatenumlockmask(void);
@@ -535,14 +535,15 @@ configurenotify(XEvent *e) {
535 if(ev->window == root) { 535 if(ev->window == root) {
536 sw = ev->width; 536 sw = ev->width;
537 sh = ev->height; 537 sh = ev->height;
538 updategeom(); 538 if(updategeom()) {
539 if(dc.drawable != 0) 539 if(dc.drawable != 0)
540 XFreePixmap(dpy, dc.drawable); 540 XFreePixmap(dpy, dc.drawable);
541 dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); 541 dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
542 updatebars(); 542 updatebars();
543 for(m = mons; m; m = m->next) 543 for(m = mons; m; m = m->next)
544 XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); 544 XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
545 arrange(); 545 arrange();
546 }
546 } 547 }
547} 548}
548 549
@@ -1692,26 +1693,73 @@ updatebarpos(Monitor *m) {
1692 m->by = -bh; 1693 m->by = -bh;
1693} 1694}
1694 1695
1695void 1696Bool
1696updategeom(void) { 1697updategeom(void) {
1697 int i, n = 1; 1698 int i, j, nn = 1, n = 1;
1698 Client *c; 1699 Client *c;
1699 Monitor *newmons = NULL, *m = NULL, *tm; 1700 Monitor *newmons = NULL, *m = NULL, *tm;
1700 1701
1701#ifdef XINERAMA 1702#ifdef XINERAMA
1702 int nn;
1703 XineramaScreenInfo *info = NULL; 1703 XineramaScreenInfo *info = NULL;
1704 Bool *flags = NULL;
1704 1705
1705 if(XineramaIsActive(dpy)) 1706 if(XineramaIsActive(dpy))
1706 info = XineramaQueryScreens(dpy, &n); 1707 info = XineramaQueryScreens(dpy, &n);
1707 for(i = 1, nn = n; i < n; i++) 1708 flags = (Bool *)malloc(sizeof(Bool) * n);
1708 if(info[i - 1].x_org == info[i].x_org && info[i - 1].y_org == info[i].y_org 1709 for(i = 0; i < n; i++)
1709 && info[i - 1].width == info[i].width && info[i - 1].height == info[i].height) 1710 flags[i] = False;
1710 --nn; 1711 /* next double-loop seeks any combination of retrieved Xinerama info
1711 n = nn; /* we only consider unique geometries as separate screens */ 1712 * with existing monitors, this is used to avoid unnecessary
1713 * re-allocations of monitor structs */
1714 for(i = 0, nn = n; i < n; i++)
1715 for(j = 0, m = mons; m; m = m->next, j++)
1716 if(!flags[j]) {
1717 if((flags[j] = (
1718 info[i].x_org == m->mx
1719 && info[i].y_org == m->my
1720 && info[i].width == m->mw
1721 && info[i].height == m->mh)
1722 ))
1723 --nn;
1724 }
1725 if(nn == 0) { /* no need to re-allocate monitors */
1726 j = 0;
1727 for(i = 0, m = mons; m; m = m->next, i++) {
1728 m->num = info[i].screen_number;
1729 if(info[i].x_org != m->mx
1730 || info[i].y_org != m->my
1731 || info[i].width != m->mw
1732 || info[i].height != m->mh)
1733 {
1734 m->mx = m->wx = info[i].x_org;
1735 m->my = m->wy = info[i].y_org;
1736 m->mw = m->ww = info[i].width;
1737 m->mh = m->wh = info[i].height;
1738 updatebarpos(m);
1739 j++;
1740 }
1741 }
1742 XFree(info);
1743 free(flags);
1744 return j > 0;
1745 }
1746 /* next algorithm only considers unique geometries as separate screens */
1747 for(i = 0; i < n; i++)
1748 flags[i] = False; /* used for ignoring certain monitors */
1749 for(i = 0, nn = n; i < n; i++)
1750 for(j = 0; j < n; j++)
1751 if(i != j && !flags[i]) {
1752 if((flags[i] = (
1753 info[i].x_org == info[j].x_org
1754 && info[i].y_org == info[j].y_org
1755 && info[i].width == info[j].width
1756 && info[i].height == info[j].height)
1757 ))
1758 --nn;
1759 }
1712#endif /* XINERAMA */ 1760#endif /* XINERAMA */
1713 /* allocate monitor(s) for the new geometry setup */ 1761 /* allocate monitor(s) for the new geometry setup */
1714 for(i = 0; i < n; i++) { 1762 for(i = 0; i < nn; i++) {
1715 if(!(m = (Monitor *)malloc(sizeof(Monitor)))) 1763 if(!(m = (Monitor *)malloc(sizeof(Monitor))))
1716 die("fatal: could not malloc() %u bytes\n", sizeof(Monitor)); 1764 die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
1717 m->next = newmons; 1765 m->next = newmons;
@@ -1720,14 +1768,18 @@ updategeom(void) {
1720 /* initialise monitor(s) */ 1768 /* initialise monitor(s) */
1721#ifdef XINERAMA 1769#ifdef XINERAMA
1722 if(XineramaIsActive(dpy)) { 1770 if(XineramaIsActive(dpy)) {
1723 for(i = 0, m = newmons; m; m = m->next, i++) { 1771 for(i = 0, m = newmons; m && i < n; i++) {
1724 m->num = info[i].screen_number; 1772 if(!flags[i]) { /* only use screens that aren't dublettes */
1725 m->mx = m->wx = info[i].x_org; 1773 m->num = info[i].screen_number;
1726 m->my = m->wy = info[i].y_org; 1774 m->mx = m->wx = info[i].x_org;
1727 m->mw = m->ww = info[i].width; 1775 m->my = m->wy = info[i].y_org;
1728 m->mh = m->wh = info[i].height; 1776 m->mw = m->ww = info[i].width;
1777 m->mh = m->wh = info[i].height;
1778 m = m->next;
1779 }
1729 } 1780 }
1730 XFree(info); 1781 XFree(info);
1782 free(flags);
1731 } 1783 }
1732 else 1784 else
1733#endif /* XINERAMA */ 1785#endif /* XINERAMA */
@@ -1767,6 +1819,7 @@ updategeom(void) {
1767 cleanupmons(); 1819 cleanupmons();
1768 selmon = mons = newmons; 1820 selmon = mons = newmons;
1769 selmon = wintomon(root); 1821 selmon = wintomon(root);
1822 return True;
1770} 1823}
1771 1824
1772void 1825void