diff options
| -rw-r--r-- | config.def.h | 4 | ||||
| -rw-r--r-- | dwm.c | 45 |
2 files changed, 29 insertions, 20 deletions
diff --git a/config.def.h b/config.def.h index d408e70..eaf773d 100644 --- a/config.def.h +++ b/config.def.h | |||
| @@ -13,10 +13,6 @@ static uint snap = 32; /* snap pixel */ | |||
| 13 | static Bool showbar = True; /* False means no bar */ | 13 | static Bool showbar = True; /* False means no bar */ |
| 14 | static Bool topbar = True; /* False means bottom bar */ | 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 | /* tagging */ | 16 | /* tagging */ |
| 21 | static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; | 17 | static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; |
| 22 | 18 | ||
| @@ -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; |
