summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2009-02-03 15:00:44 +0100
committerDanny Baumann <dannybaumann@web.de>2009-02-04 08:47:24 +0100
commit289423858bc14eee87f0c2de410179de8be4bf25 (patch)
treec1db1c537574ffc7c668d119db4af062b0cdd1c7 /src
parentbb880adc669404d4c836439d3c1c43f77848b273 (diff)
Map windows that requested not to get focus on top. Rationale is that when not mapping them on top, chances are high the user won't notice the appearance of a new window.
Diffstat (limited to 'src')
-rw-r--r--src/event.c53
-rw-r--r--src/window.c19
2 files changed, 38 insertions, 34 deletions
diff --git a/src/event.c b/src/event.c
index 50bce9ca..a93c1288 100644
--- a/src/event.c
+++ b/src/event.c
@@ -1649,9 +1649,10 @@ handleEvent (CompDisplay *d,
if (w->managed && w->startupId)
{
- Time timestamp = 0;
- int vx, vy, x, y;
- CompScreen *s = w->screen;
+ Time timestamp = 0;
+ int vx, vy, x, y;
+ CompScreen *s = w->screen;
+ CompFocusResult focus;
w->initialTimestampSet = FALSE;
applyStartupProperties (w->screen, w);
@@ -1668,13 +1669,13 @@ handleEvent (CompDisplay *d,
y = w->attrib.y + (s->y - vy) * s->height;
moveWindowToViewportPosition (w, x, y, TRUE);
- if (allowWindowFocus (w, 0,
- w->initialViewportX,
- w->initialViewportY,
- timestamp))
- {
+ focus = allowWindowFocus (w, 0,
+ w->initialViewportX,
+ w->initialViewportY,
+ timestamp);
+
+ if (focus == CompFocusAllowed)
(*w->screen->activateWindow) (w);
- }
}
}
}
@@ -1693,17 +1694,17 @@ handleEvent (CompDisplay *d,
w = findWindowAtDisplay (d, event->xclient.window);
if (w)
{
- Bool focusAllowed = TRUE;
+ CompFocusResult focus = CompFocusAllowed;
/* use focus stealing prevention if request came
from an application */
if (event->xclient.data.l[0] == ClientTypeApplication)
- focusAllowed = allowWindowFocus (w, 0,
- w->screen->x,
- w->screen->y,
- event->xclient.data.l[1]);
+ focus = allowWindowFocus (w, 0,
+ w->screen->x,
+ w->screen->y,
+ event->xclient.data.l[1]);
- if (focusAllowed)
+ if (focus == CompFocusAllowed)
(*w->screen->activateWindow) (w);
}
}
@@ -2030,7 +2031,7 @@ handleEvent (CompDisplay *d,
if (doMapProcessing)
{
- Bool allowFocus;
+ CompFocusResult focus;
CompStackingUpdateMode stackingMode;
if (!w->placed)
@@ -2068,10 +2069,10 @@ handleEvent (CompDisplay *d,
w->placed = TRUE;
}
- allowFocus = allowWindowFocus (w, NO_FOCUS_MASK,
- w->screen->x, w->screen->y, 0);
+ focus = allowWindowFocus (w, NO_FOCUS_MASK,
+ w->screen->x, w->screen->y, 0);
- if (!allowFocus && (w->type & ~NO_FOCUS_MASK))
+ if (focus == CompFocusDenied)
stackingMode = CompStackingUpdateModeInitialMapDeniedFocus;
else
stackingMode = CompStackingUpdateModeInitialMap;
@@ -2083,13 +2084,13 @@ handleEvent (CompDisplay *d,
(*w->screen->leaveShowDesktopMode) (w->screen, w);
- if (allowFocus && !onCurrentDesktop (w))
+ if (focus == CompFocusAllowed && !onCurrentDesktop (w))
setCurrentDesktop (w->screen, w->desktop);
if (!(w->state & CompWindowStateHiddenMask))
showWindow (w);
- if (allowFocus)
+ if (focus == CompFocusAllowed)
moveInputFocusToWindow (w);
}
@@ -2119,8 +2120,9 @@ handleEvent (CompDisplay *d,
if (event->xconfigurerequest.value_mask & CWStackMode)
{
- Window above = None;
- CompWindow *sibling = NULL;
+ Window above = None;
+ CompWindow *sibling = NULL;
+ CompFocusResult focus;
if (event->xconfigurerequest.value_mask & CWSibling)
{
@@ -2130,8 +2132,9 @@ handleEvent (CompDisplay *d,
switch (event->xconfigurerequest.detail) {
case Above:
- if (allowWindowFocus (w, NO_FOCUS_MASK,
- w->screen->x, w->screen->y, 0))
+ focus = allowWindowFocus (w, NO_FOCUS_MASK,
+ w->screen->x, w->screen->y, 0);
+ if (focus == CompFocusAllowed)
{
if (above)
{
diff --git a/src/window.c b/src/window.c
index 85eaa2a4..a64a1d12 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4964,41 +4964,42 @@ isWindowFocusAllowed (CompWindow *w,
return TRUE;
}
-Bool
+CompFocusResult
allowWindowFocus (CompWindow *w,
unsigned int noFocusMask,
unsigned int viewportX,
unsigned int viewportY,
Time timestamp)
{
- Bool retval;
+ Bool status;
if (w->id == w->screen->display->activeWindow)
- return TRUE;
+ return CompFocusAllowed;
/* do not focus windows of these types */
if (w->type & noFocusMask)
- return FALSE;
+ return CompFocusPrevent;
/* window doesn't take focus */
if (!w->inputHint && !(w->protocols & CompWindowProtocolTakeFocusMask))
- return FALSE;
+ return CompFocusPrevent;
if (!timestamp)
{
/* if the window has a 0 timestamp, it explicitly requested no focus */
if (getFocusWindowUsageTimestamp (w, &timestamp) && !timestamp)
- return FALSE;
+ return CompFocusPrevent;
}
- retval = isWindowFocusAllowed (w, viewportX, viewportY, timestamp);
- if (!retval)
+ status = isWindowFocusAllowed (w, viewportX, viewportY, timestamp);
+ if (!status)
{
/* add demands attention state if focus was prevented */
changeWindowState (w, w->state | CompWindowStateDemandsAttentionMask);
+ return CompFocusDenied;
}
- return retval;
+ return CompFocusAllowed;
}
void