got rid of compile time xidx configuration, querying mouse pointer instead
c86ed46a
2 file(s) · +29 −20
| 13 | 13 | static Bool showbar = True; /* False means no bar */ |
|
| 14 | 14 | static Bool topbar = True; /* False means bottom bar */ |
|
| 15 | 15 | ||
| 16 | - | #ifdef XINERAMA |
|
| 17 | - | static uint xidx = 0; /* Xinerama screen index to use */ |
|
| 18 | - | #endif |
|
| 19 | - | ||
| 20 | 16 | /* tagging */ |
|
| 21 | 17 | static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; |
|
| 22 | 18 |
| 44 | 44 | #endif |
|
| 45 | 45 | ||
| 46 | 46 | /* macros */ |
|
| 47 | - | #define MAX(a, b) ((a) > (b) ? (a) : (b)) |
|
| 48 | - | #define MIN(a, b) ((a) < (b) ? (a) : (b)) |
|
| 49 | - | #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) |
|
| 50 | - | #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) |
|
| 51 | - | #define LENGTH(x) (sizeof x / sizeof x[0]) |
|
| 52 | - | #define MAXTAGLEN 16 |
|
| 53 | - | #define MOUSEMASK (BUTTONMASK|PointerMotionMask) |
|
| 54 | - | #define TAGMASK ((int)((1LL << LENGTH(tags)) - 1)) |
|
| 55 | - | #define TEXTW(x) (textnw(x, strlen(x)) + dc.font.height) |
|
| 56 | - | #define ISVISIBLE(x) (x->tags & tagset[seltags]) |
|
| 47 | + | #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) |
|
| 48 | + | #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) |
|
| 49 | + | #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) |
|
| 50 | + | #define ISVISIBLE(x) (x->tags & tagset[seltags]) |
|
| 51 | + | #define LENGTH(x) (sizeof x / sizeof x[0]) |
|
| 52 | + | #define MAX(a, b) ((a) > (b) ? (a) : (b)) |
|
| 53 | + | #define MIN(a, b) ((a) < (b) ? (a) : (b)) |
|
| 54 | + | #define MAXTAGLEN 16 |
|
| 55 | + | #define MOUSEMASK (BUTTONMASK|PointerMotionMask) |
|
| 56 | + | #define TAGMASK ((int)((1LL << LENGTH(tags)) - 1)) |
|
| 57 | + | #define TEXTW(x) (textnw(x, strlen(x)) + dc.font.height) |
|
| 57 | 58 | ||
| 58 | 59 | /* enums */ |
|
| 59 | 60 | enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ |
|
| 974 | 975 | ||
| 975 | 976 | void |
|
| 976 | 977 | movemouse(const Arg *arg) { |
|
| 977 | - | int x1, y1, ocx, ocy, di, nx, ny; |
|
| 978 | + | int x, y, ocx, ocy, di, nx, ny; |
|
| 978 | 979 | unsigned int dui; |
|
| 979 | 980 | Client *c; |
|
| 980 | 981 | Window dummy; |
|
| 988 | 989 | if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, |
|
| 989 | 990 | None, cursor[CurMove], CurrentTime) != GrabSuccess) |
|
| 990 | 991 | return; |
|
| 991 | - | XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); |
|
| 992 | + | XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui); |
|
| 992 | 993 | for(;;) { |
|
| 993 | 994 | XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); |
|
| 994 | 995 | switch (ev.type) { |
|
| 1002 | 1003 | break; |
|
| 1003 | 1004 | case MotionNotify: |
|
| 1004 | 1005 | XSync(dpy, False); |
|
| 1005 | - | nx = ocx + (ev.xmotion.x - x1); |
|
| 1006 | - | ny = ocy + (ev.xmotion.y - y1); |
|
| 1006 | + | nx = ocx + (ev.xmotion.x - x); |
|
| 1007 | + | ny = ocy + (ev.xmotion.y - y); |
|
| 1007 | 1008 | if(snap && nx >= wx && nx <= wx + ww |
|
| 1008 | 1009 | && ny >= wy && ny <= wy + wh) { |
|
| 1009 | 1010 | if(abs(wx - nx) < snap) |
|
| 1557 | 1558 | void |
|
| 1558 | 1559 | updategeom(void) { |
|
| 1559 | 1560 | #ifdef XINERAMA |
|
| 1560 | - | int i; |
|
| 1561 | + | int n; |
|
| 1562 | + | unsigned int xidx = 0; |
|
| 1561 | 1563 | XineramaScreenInfo *info = NULL; |
|
| 1562 | 1564 | ||
| 1563 | 1565 | /* window area geometry */ |
|
| 1564 | 1566 | if(XineramaIsActive(dpy)) { |
|
| 1565 | - | info = XineramaQueryScreens(dpy, &i); |
|
| 1567 | + | info = XineramaQueryScreens(dpy, &n); |
|
| 1568 | + | if(n > 1) { |
|
| 1569 | + | int di, i, x, y; |
|
| 1570 | + | unsigned int dui; |
|
| 1571 | + | Window dummy; |
|
| 1572 | + | if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui)) |
|
| 1573 | + | for(i = 0; i < n; i++) |
|
| 1574 | + | if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)) { |
|
| 1575 | + | xidx = i; |
|
| 1576 | + | break; |
|
| 1577 | + | } |
|
| 1578 | + | } |
|
| 1566 | 1579 | wx = info[xidx].x_org; |
|
| 1567 | 1580 | wy = showbar && topbar ? info[xidx].y_org + bh : info[xidx].y_org; |
|
| 1568 | 1581 | ww = info[xidx].width; |
|