From eacc4339fef37a314e5931c68647e601db569458 Mon Sep 17 00:00:00 2001 From: Danny Baumann Date: Thu, 28 Aug 2008 13:41:35 +0200 Subject: Improve focus stealing prevention. - Allow window focus if currently no window or only the desktop window is focussed. - Rename mode "High" to "Normal" and introduce "High" mode that denies focus attempts of windows not belonging to the active application. - Allow focus attempts of windows of the same application in Low, Normal, High modes. --- src/window.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/window.c b/src/window.c index 2fa54299..9e248e8f 100644 --- a/src/window.c +++ b/src/window.c @@ -4786,6 +4786,19 @@ isWindowFocusAllowed (CompWindow *w, if (level == FOCUS_PREVENTION_LEVEL_VERYHIGH) return FALSE; + active = findWindowAtDisplay (d, d->activeWindow); + + /* no active window */ + if (!active || (active->type & CompWindowTypeDesktopMask)) + return TRUE; + + /* active window belongs to same application */ + if (w->clientLeader == active->clientLeader) + return TRUE; + + if (level == FOCUS_PREVENTION_LEVEL_HIGH) + return FALSE; + /* not in current viewport */ defaultViewportForWindow (w, &vx, &vy); if (vx != s->x || vy != s->y) @@ -4794,16 +4807,15 @@ isWindowFocusAllowed (CompWindow *w, if (!gotTimestamp) { /* unsure as we have nothing to compare - allow focus in low level, - don't allow in high level */ - if (level == FOCUS_PREVENTION_LEVEL_HIGH) + don't allow in normal level */ + if (level == FOCUS_PREVENTION_LEVEL_NORMAL) return FALSE; return TRUE; } /* can't get user time for active window */ - active = findWindowAtDisplay (d, d->activeWindow); - if (!active || !getWindowUserTime (active, &aUserTime)) + if (!getWindowUserTime (active, &aUserTime)) return TRUE; if (XSERVER_TIME_IS_BEFORE (wUserTime, aUserTime)) -- cgit v1.2.3