From a93dac27981fce0e2fdd4a1924beb3b5d5e7b7a5 Mon Sep 17 00:00:00 2001 From: Connor Lane Smith Date: Mon, 26 Sep 2011 22:39:59 +0100 Subject: fix focus handling (thanks roman) --- tabbed.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'tabbed.c') diff --git a/tabbed.c b/tabbed.c index 6aa98e4..56c9d6b 100644 --- a/tabbed.c +++ b/tabbed.c @@ -94,7 +94,6 @@ static void die(const char *errstr, ...); static void drawbar(); static void drawtext(const char *text, unsigned long col[ColLast]); static void *emallocz(size_t size); -static void enternotify(const XEvent *e); static void expose(const XEvent *e); static void focus(Client *c); static void focusin(const XEvent *e); @@ -134,7 +133,6 @@ static void (*handler[LASTEvent]) (const XEvent *) = { [ConfigureRequest] = configurerequest, [CreateNotify] = createnotify, [DestroyNotify] = destroynotify, - [EnterNotify] = enternotify, [Expose] = expose, [FocusIn] = focusin, [KeyPress] = keypress, @@ -367,11 +365,6 @@ emallocz(size_t size) { return p; } -void -enternotify(const XEvent *e) { - focus(sel); -} - void expose(const XEvent *e) { const XExposeEvent *ev = &e->xexpose; @@ -390,6 +383,7 @@ focus(Client *c) { } resize(c, ww, wh - bh); XRaiseWindow(dpy, c->win); + XSetInputFocus(dpy, c->win, RevertToParent, CurrentTime); sendxembed(c, XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT, 0, 0); sendxembed(c, XEMBED_WINDOW_ACTIVATE, 0, 0, 0); XStoreName(dpy, win, c->name); @@ -402,7 +396,15 @@ focus(Client *c) { void focusin(const XEvent *e) { - focus(sel); + const XFocusChangeEvent *ev = &e->xfocus; + int dummy; + Window focused; + + if(ev->mode != NotifyUngrab) { + XGetInputFocus(dpy, &focused, &dummy); + if(focused == win) + focus(sel); + } } void -- cgit v1.2.3