diff -r c2e77ee26371 dmenu.c
--- a/dmenu.c	Fri Jan 07 18:55:00 2011 +0000
+++ b/dmenu.c	Sun Mar 13 00:02:06 2011 +0100
@@ -495,11 +495,16 @@
 	mh = (lines + 1) * bh;
 #ifdef XINERAMA
 	if((info = XineramaQueryScreens(dc->dpy, &n))) {
-		int i, di;
-		unsigned int du;
-		Window dw;
-
-		XQueryPointer(dc->dpy, root, &dw, &dw, &x, &y, &di, &di, &du);
+		int i;
+		Window dw, chi;
+        XWindowAttributes fwa;
+        int revert;
+        
+        XGetInputFocus(dc->dpy, &dw, &revert);
+        XGetWindowAttributes(dc->dpy, dw, &fwa);
+        XTranslateCoordinates(dc->dpy, dw, fwa.root, fwa.x, fwa.y, &x, &y, &chi);
+        x = x + fwa.width / 2;
+        y = y + fwa.width / 2;
 		for(i = 0; i < n; i++)
 			if((monitor == info[i].screen_number)
 			|| (monitor < 0 && INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)))
