Xinqi Bao's Git
projects
/
dmenu.git
/ commitdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (parent:
3af80cd
)
detect active monitor using input focus
author
Connor Lane Smith <
[email protected]
>
Mon, 19 Sep 2011 17:15:03 +0000
(18:15 +0100)
committer
Connor Lane Smith <
[email protected]
>
Mon, 19 Sep 2011 17:15:03 +0000
(18:15 +0100)
dmenu.c
patch
|
blob
|
history
diff --git
a/dmenu.c
b/dmenu.c
index
fd98d54
..
6c1407d
100644
(file)
--- a/
dmenu.c
+++ b/
dmenu.c
@@
-473,7
+473,7
@@
void
setup(void) {
int x, y, screen = DefaultScreen(dc->dpy);
Window root = RootWindow(dc->dpy, screen);
setup(void) {
int x, y, screen = DefaultScreen(dc->dpy);
Window root = RootWindow(dc->dpy, screen);
- XSetWindowAttributes wa;
+ XSetWindowAttributes
s
wa;
#ifdef XINERAMA
int n;
XineramaScreenInfo *info;
#ifdef XINERAMA
int n;
XineramaScreenInfo *info;
@@
-494,9
+494,14
@@
setup(void) {
if((info = XineramaQueryScreens(dc->dpy, &n))) {
int i, di;
unsigned int du;
if((info = XineramaQueryScreens(dc->dpy, &n))) {
int i, di;
unsigned int du;
- Window dw;
+ Window w, dw;
+ XWindowAttributes wa;
- XQueryPointer(dc->dpy, root, &dw, &dw, &x, &y, &di, &di, &du);
+ XGetInputFocus(dc->dpy, &w, &di);
+ if(w != root && XGetWindowAttributes(dc->dpy, w, &wa))
+ XTranslateCoordinates(dc->dpy, root, root, wa.x, wa.y, &x, &y, &dw);
+ else
+ XQueryPointer(dc->dpy, root, &dw, &dw, &x, &y, &di, &di, &du);
for(i = 0; i < n-1; i++)
if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height))
break;
for(i = 0; i < n-1; i++)
if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height))
break;
@@
-517,13
+522,13
@@
setup(void) {
match(False);
/* menu window */
match(False);
/* menu window */
- wa.override_redirect = True;
- wa.background_pixmap = ParentRelative;
- wa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
+
s
wa.override_redirect = True;
+
s
wa.background_pixmap = ParentRelative;
+
s
wa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
win = XCreateWindow(dc->dpy, root, x, y, mw, mh, 0,
DefaultDepth(dc->dpy, screen), CopyFromParent,
DefaultVisual(dc->dpy, screen),
win = XCreateWindow(dc->dpy, root, x, y, mw, mh, 0,
DefaultDepth(dc->dpy, screen), CopyFromParent,
DefaultVisual(dc->dpy, screen),
- CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
+ CWOverrideRedirect | CWBackPixmap | CWEventMask, &
s
wa);
XMapRaised(dc->dpy, win);
resizedc(dc, mw, mh);
XMapRaised(dc->dpy, win);
resizedc(dc, mw, mh);