diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/event.c | 53 | ||||
-rw-r--r-- | src/window.c | 19 |
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, ×tamp) && !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 |