summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2008-08-28 13:41:35 +0200
committerDanny Baumann <dannybaumann@web.de>2008-08-28 13:41:35 +0200
commiteacc4339fef37a314e5931c68647e601db569458 (patch)
tree8ed0d2d57570439c29cc84d7af3e7434c39a6aed /src
parentee34bc128fdeb81f5cdf570b902b59923a5b479c (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/window.c20
1 files changed, 16 insertions, 4 deletions
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))