diff options
| author | Anselm R Garbe <garbeam@gmail.com> | 2008-07-16 18:33:51 +0100 |
|---|---|---|
| committer | Anselm R Garbe <garbeam@gmail.com> | 2008-07-16 18:33:51 +0100 |
| commit | c86ed46a1bbba0635a76d05ebeb839c7fec7f7fc (patch) | |
| tree | 57f5b1346e66a9fd6501ed28ebf5d7c1ea8b3d36 /dwm.c | |
| parent | reverted uint redefinition (diff) | |
| download | dwm-c86ed46a1bbba0635a76d05ebeb839c7fec7f7fc.tar.gz dwm-c86ed46a1bbba0635a76d05ebeb839c7fec7f7fc.zip | |
got rid of compile time xidx configuration, querying mouse pointer instead
Diffstat (limited to 'dwm.c')
| -rw-r--r-- | dwm.c | 45 |
1 files changed, 29 insertions, 16 deletions
| @@ -44,16 +44,17 @@ | |||
| 44 | #endif | 44 | #endif |
| 45 | 45 | ||
| 46 | /* macros */ | 46 | /* macros */ |
| 47 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) | 47 | #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) |
| 48 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) | 48 | #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) |
| 49 | #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) | 49 | #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) |
| 50 | #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) | 50 | #define ISVISIBLE(x) (x->tags & tagset[seltags]) |
| 51 | #define LENGTH(x) (sizeof x / sizeof x[0]) | 51 | #define LENGTH(x) (sizeof x / sizeof x[0]) |
| 52 | #define MAXTAGLEN 16 | 52 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) |
| 53 | #define MOUSEMASK (BUTTONMASK|PointerMotionMask) | 53 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) |
| 54 | #define TAGMASK ((int)((1LL << LENGTH(tags)) - 1)) | 54 | #define MAXTAGLEN 16 |
| 55 | #define TEXTW(x) (textnw(x, strlen(x)) + dc.font.height) | 55 | #define MOUSEMASK (BUTTONMASK|PointerMotionMask) |
| 56 | #define ISVISIBLE(x) (x->tags & tagset[seltags]) | 56 | #define TAGMASK ((int)((1LL << LENGTH(tags)) - 1)) |
| 57 | #define TEXTW(x) (textnw(x, strlen(x)) + dc.font.height) | ||
| 57 | 58 | ||
| 58 | /* enums */ | 59 | /* enums */ |
| 59 | enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ | 60 | enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ |
| @@ -974,7 +975,7 @@ monocle(void) { | |||
| 974 | 975 | ||
| 975 | void | 976 | void |
| 976 | movemouse(const Arg *arg) { | 977 | movemouse(const Arg *arg) { |
| 977 | int x1, y1, ocx, ocy, di, nx, ny; | 978 | int x, y, ocx, ocy, di, nx, ny; |
| 978 | unsigned int dui; | 979 | unsigned int dui; |
| 979 | Client *c; | 980 | Client *c; |
| 980 | Window dummy; | 981 | Window dummy; |
| @@ -988,7 +989,7 @@ movemouse(const Arg *arg) { | |||
| 988 | if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, | 989 | if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, |
| 989 | None, cursor[CurMove], CurrentTime) != GrabSuccess) | 990 | None, cursor[CurMove], CurrentTime) != GrabSuccess) |
| 990 | return; | 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 | for(;;) { | 993 | for(;;) { |
| 993 | XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); | 994 | XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); |
| 994 | switch (ev.type) { | 995 | switch (ev.type) { |
| @@ -1002,8 +1003,8 @@ movemouse(const Arg *arg) { | |||
| 1002 | break; | 1003 | break; |
| 1003 | case MotionNotify: | 1004 | case MotionNotify: |
| 1004 | XSync(dpy, False); | 1005 | XSync(dpy, False); |
| 1005 | nx = ocx + (ev.xmotion.x - x1); | 1006 | nx = ocx + (ev.xmotion.x - x); |
| 1006 | ny = ocy + (ev.xmotion.y - y1); | 1007 | ny = ocy + (ev.xmotion.y - y); |
| 1007 | if(snap && nx >= wx && nx <= wx + ww | 1008 | if(snap && nx >= wx && nx <= wx + ww |
| 1008 | && ny >= wy && ny <= wy + wh) { | 1009 | && ny >= wy && ny <= wy + wh) { |
| 1009 | if(abs(wx - nx) < snap) | 1010 | if(abs(wx - nx) < snap) |
| @@ -1557,12 +1558,24 @@ updatebar(void) { | |||
| 1557 | void | 1558 | void |
| 1558 | updategeom(void) { | 1559 | updategeom(void) { |
| 1559 | #ifdef XINERAMA | 1560 | #ifdef XINERAMA |
| 1560 | int i; | 1561 | int n; |
| 1562 | unsigned int xidx = 0; | ||
| 1561 | XineramaScreenInfo *info = NULL; | 1563 | XineramaScreenInfo *info = NULL; |
| 1562 | 1564 | ||
| 1563 | /* window area geometry */ | 1565 | /* window area geometry */ |
| 1564 | if(XineramaIsActive(dpy)) { | 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 | wx = info[xidx].x_org; | 1579 | wx = info[xidx].x_org; |
| 1567 | wy = showbar && topbar ? info[xidx].y_org + bh : info[xidx].y_org; | 1580 | wy = showbar && topbar ? info[xidx].y_org + bh : info[xidx].y_org; |
| 1568 | ww = info[xidx].width; | 1581 | ww = info[xidx].width; |
