From 53aeb801d4a22fc3e80cc1953a52dd492e77165f Mon Sep 17 00:00:00 2001 From: Richard Grenville Date: Sat, 3 Nov 2012 22:02:07 +0800 Subject: Improvement: Focus detection & --mark-ovredir-focused changes - Change focus detection to filter FocusIn/Out events in an alternative way. Could break things, and may be revoked in the future. - Change --mark-ovredir-focused's semantics. Now it determines whether a window is to be unconditionally focused by checking if its client window is the window itself. This resolves a problem in window managers that set frame windows to be override-redirected (Fluxbox and i3?). Yes, I know it's bad to change semantics in this way. --- compton.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/compton.c b/compton.c index 235ef6ed5..8e7500cb2 100644 --- a/compton.c +++ b/compton.c @@ -1992,7 +1992,7 @@ map_win(Display *dpy, Window id, // focused if mark_wmwin_focused is on, or it's over-redirected and // mark_ovredir_focused is on if ((opts.mark_wmwin_focused && !w->client_win) - || (opts.mark_ovredir_focused && w->a.override_redirect)) + || (opts.mark_ovredir_focused && w->id == w->client_win)) w->focused = True; } @@ -2968,12 +2968,14 @@ ev_focus_report(XFocusChangeEvent* ev) { * Events */ +/** + * Determine whether we should respond to a FocusIn/Out + * event. + */ inline static bool ev_focus_accept(XFocusChangeEvent *ev) { - return ev->mode == NotifyGrab - || (ev->mode == NotifyNormal - && (ev->detail == NotifyNonlinear - || ev->detail == NotifyNonlinearVirtual)); + return ev->detail == NotifyNonlinear + || ev->detail == NotifyNonlinearVirtual; } inline static void @@ -2982,6 +2984,9 @@ ev_focus_in(XFocusChangeEvent *ev) { ev_focus_report(ev); #endif + if (!ev_focus_accept(ev)) + return; + win *w = find_win(dpy, ev->window); // To deal with events sent from windows just destroyed @@ -3357,7 +3362,7 @@ usage(void) { "--shadow-exclude condition\n" " Exclude conditions for shadows.\n" "--mark-ovredir-focused\n" - " Mark over-redirect windows as active.\n" + " Mark windows that have no WM frame as active.\n" "--no-fading-openclose\n" " Do not fade on window open/close.\n" "--shadow-ignore-shaped\n" -- cgit v1.2.1