aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnselm R Garbe <garbeam@gmail.com>2008-07-16 18:38:53 +0100
committerAnselm R Garbe <garbeam@gmail.com>2008-07-16 18:38:53 +0100
commit4d8a646958fa2e0c8fe9d8da3dd26357e8bb4317 (patch)
tree5263258edb252d83e2da8dfcddbd1ed2e2283ac5
parentb89a9501c75744f1393ec943ca520c8b59501610 (diff)
got rid of compile time xidx, grabbing the mouse pointer instead, falling back to screen 0 if no pointer available
-rw-r--r--config.h5
-rw-r--r--dmenu.c23
2 files changed, 17 insertions, 11 deletions
diff --git a/config.h b/config.h
index a2c3fa4..3e6c616 100644
--- a/config.h
+++ b/config.h
@@ -6,9 +6,4 @@ static const char *normbgcolor = "#cccccc";
6static const char *normfgcolor = "#000000"; 6static const char *normfgcolor = "#000000";
7static const char *selbgcolor = "#0066ff"; 7static const char *selbgcolor = "#0066ff";
8static const char *selfgcolor = "#ffffff"; 8static const char *selfgcolor = "#ffffff";
9
10static unsigned int spaceitem = 30; /* px between menu items */ 9static unsigned int spaceitem = 30; /* px between menu items */
11
12#ifdef XINERAMA
13static unsigned int xidx = 0; /* Xinerama screen index to use */
14#endif
diff --git a/dmenu.c b/dmenu.c
index 33b1a89..e487333 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -16,7 +16,8 @@
16#endif 16#endif
17 17
18/* macros */ 18/* macros */
19#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) 19#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
20#define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
20 21
21/* enums */ 22/* enums */
22enum { ColFG, ColBG, ColLast }; 23enum { ColFG, ColBG, ColLast };
@@ -585,7 +586,7 @@ run(void) {
585 586
586void 587void
587setup(Bool topbar) { 588setup(Bool topbar) {
588 int i, j, x, y; 589 int i, j, n, x, y;
589 XModifierKeymap *modmap; 590 XModifierKeymap *modmap;
590 XSetWindowAttributes wa; 591 XSetWindowAttributes wa;
591#if XINERAMA 592#if XINERAMA
@@ -618,10 +619,20 @@ setup(Bool topbar) {
618 mh = dc.font.height + 2; 619 mh = dc.font.height + 2;
619#if XINERAMA 620#if XINERAMA
620 if(XineramaIsActive(dpy)) { 621 if(XineramaIsActive(dpy)) {
621 info = XineramaQueryScreens(dpy, &i); 622 i = 0;
622 x = info[xidx].x_org; 623 info = XineramaQueryScreens(dpy, &n);
623 y = topbar ? info[xidx].y_org : info[xidx].y_org + info[xidx].height - mh; 624 if(n > 1) {
624 mw = info[xidx].width; 625 int di;
626 unsigned int dui;
627 Window dummy;
628 if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui))
629 for(i = 0; i < n; i++)
630 if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height))
631 break;
632 }
633 x = info[i].x_org;
634 y = topbar ? info[i].y_org : info[i].y_org + info[i].height - mh;
635 mw = info[i].width;
625 XFree(info); 636 XFree(info);
626 } 637 }
627 else 638 else