detect active monitor using input focus
This commit is contained in:
parent
3af80cd7d8
commit
f1848a3ef0
17
dmenu.c
17
dmenu.c
@ -473,7 +473,7 @@ void
|
|||||||
setup(void) {
|
setup(void) {
|
||||||
int x, y, screen = DefaultScreen(dc->dpy);
|
int x, y, screen = DefaultScreen(dc->dpy);
|
||||||
Window root = RootWindow(dc->dpy, screen);
|
Window root = RootWindow(dc->dpy, screen);
|
||||||
XSetWindowAttributes wa;
|
XSetWindowAttributes swa;
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
int n;
|
int n;
|
||||||
XineramaScreenInfo *info;
|
XineramaScreenInfo *info;
|
||||||
@ -494,8 +494,13 @@ setup(void) {
|
|||||||
if((info = XineramaQueryScreens(dc->dpy, &n))) {
|
if((info = XineramaQueryScreens(dc->dpy, &n))) {
|
||||||
int i, di;
|
int i, di;
|
||||||
unsigned int du;
|
unsigned int du;
|
||||||
Window dw;
|
Window w, dw;
|
||||||
|
XWindowAttributes wa;
|
||||||
|
|
||||||
|
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);
|
XQueryPointer(dc->dpy, root, &dw, &dw, &x, &y, &di, &di, &du);
|
||||||
for(i = 0; i < n-1; i++)
|
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))
|
if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height))
|
||||||
@ -517,13 +522,13 @@ setup(void) {
|
|||||||
match(False);
|
match(False);
|
||||||
|
|
||||||
/* menu window */
|
/* menu window */
|
||||||
wa.override_redirect = True;
|
swa.override_redirect = True;
|
||||||
wa.background_pixmap = ParentRelative;
|
swa.background_pixmap = ParentRelative;
|
||||||
wa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||||
win = XCreateWindow(dc->dpy, root, x, y, mw, mh, 0,
|
win = XCreateWindow(dc->dpy, root, x, y, mw, mh, 0,
|
||||||
DefaultDepth(dc->dpy, screen), CopyFromParent,
|
DefaultDepth(dc->dpy, screen), CopyFromParent,
|
||||||
DefaultVisual(dc->dpy, screen),
|
DefaultVisual(dc->dpy, screen),
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
CWOverrideRedirect | CWBackPixmap | CWEventMask, &swa);
|
||||||
|
|
||||||
XMapRaised(dc->dpy, win);
|
XMapRaised(dc->dpy, win);
|
||||||
resizedc(dc, mw, mh);
|
resizedc(dc, mw, mh);
|
||||||
|
Loading…
Reference in New Issue
Block a user