1
0

got rid of compile time xidx configuration, querying mouse pointer instead

This commit is contained in:
Anselm R Garbe 2008-07-16 18:33:51 +01:00
parent 9086f98068
commit c86ed46a1b
2 changed files with 29 additions and 20 deletions

View File

@ -13,10 +13,6 @@ static uint snap = 32; /* snap pixel */
static Bool showbar = True; /* False means no bar */ static Bool showbar = True; /* False means no bar */
static Bool topbar = True; /* False means bottom bar */ static Bool topbar = True; /* False means bottom bar */
#ifdef XINERAMA
static uint xidx = 0; /* Xinerama screen index to use */
#endif
/* tagging */ /* tagging */
static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };

45
dwm.c
View File

@ -44,16 +44,17 @@
#endif #endif
/* macros */ /* macros */
#define MAX(a, b) ((a) > (b) ? (a) : (b)) #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
#define MIN(a, b) ((a) < (b) ? (a) : (b)) #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask))
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) #define ISVISIBLE(x) (x->tags & tagset[seltags])
#define LENGTH(x) (sizeof x / sizeof x[0]) #define LENGTH(x) (sizeof x / sizeof x[0])
#define MAXTAGLEN 16 #define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MOUSEMASK (BUTTONMASK|PointerMotionMask) #define MIN(a, b) ((a) < (b) ? (a) : (b))
#define TAGMASK ((int)((1LL << LENGTH(tags)) - 1)) #define MAXTAGLEN 16
#define TEXTW(x) (textnw(x, strlen(x)) + dc.font.height) #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define ISVISIBLE(x) (x->tags & tagset[seltags]) #define TAGMASK ((int)((1LL << LENGTH(tags)) - 1))
#define TEXTW(x) (textnw(x, strlen(x)) + dc.font.height)
/* enums */ /* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
@ -974,7 +975,7 @@ monocle(void) {
void void
movemouse(const Arg *arg) { movemouse(const Arg *arg) {
int x1, y1, ocx, ocy, di, nx, ny; int x, y, ocx, ocy, di, nx, ny;
unsigned int dui; unsigned int dui;
Client *c; Client *c;
Window dummy; Window dummy;
@ -988,7 +989,7 @@ movemouse(const Arg *arg) {
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurMove], CurrentTime) != GrabSuccess) None, cursor[CurMove], CurrentTime) != GrabSuccess)
return; return;
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui);
for(;;) { for(;;) {
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
switch (ev.type) { switch (ev.type) {
@ -1002,8 +1003,8 @@ movemouse(const Arg *arg) {
break; break;
case MotionNotify: case MotionNotify:
XSync(dpy, False); XSync(dpy, False);
nx = ocx + (ev.xmotion.x - x1); nx = ocx + (ev.xmotion.x - x);
ny = ocy + (ev.xmotion.y - y1); ny = ocy + (ev.xmotion.y - y);
if(snap && nx >= wx && nx <= wx + ww if(snap && nx >= wx && nx <= wx + ww
&& ny >= wy && ny <= wy + wh) { && ny >= wy && ny <= wy + wh) {
if(abs(wx - nx) < snap) if(abs(wx - nx) < snap)
@ -1557,12 +1558,24 @@ updatebar(void) {
void void
updategeom(void) { updategeom(void) {
#ifdef XINERAMA #ifdef XINERAMA
int i; int n;
unsigned int xidx = 0;
XineramaScreenInfo *info = NULL; XineramaScreenInfo *info = NULL;
/* window area geometry */ /* window area geometry */
if(XineramaIsActive(dpy)) { if(XineramaIsActive(dpy)) {
info = XineramaQueryScreens(dpy, &i); info = XineramaQueryScreens(dpy, &n);
if(n > 1) {
int di, i, x, y;
unsigned int dui;
Window dummy;
if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui))
for(i = 0; i < n; i++)
if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)) {
xidx = i;
break;
}
}
wx = info[xidx].x_org; wx = info[xidx].x_org;
wy = showbar && topbar ? info[xidx].y_org + bh : info[xidx].y_org; wy = showbar && topbar ? info[xidx].y_org + bh : info[xidx].y_org;
ww = info[xidx].width; ww = info[xidx].width;