diff --git a/widget.c b/widget.c index d737e41..f5c84d6 100644 --- a/widget.c +++ b/widget.c @@ -58,6 +58,8 @@ typedef struct _WidgetDisplay MatchExpHandlerChangedProc matchExpHandlerChanged; MatchInitExpProc matchInitExp; + Window lastActiveWindow; + Atom compizWidgetAtom; } WidgetDisplay; @@ -231,7 +233,10 @@ static void widgetSetWidgetLayerMapState (CompScreen *s, Bool map) { - CompWindow *w; + CompWindow *w, *highest = NULL; + unsigned int highestActiveNum = 0; + + WIDGET_DISPLAY (s->display); for (w = s->windows; w; w = w->next) { @@ -240,8 +245,26 @@ widgetSetWidgetLayerMapState (CompScreen *s, if (!ww->isWidget) continue; + if (w->activeNum > highestActiveNum) + { + highest = w; + highestActiveNum = w->activeNum; + } + widgetUpdateWidgetMapState (w, map); } + + if (map && highest) + { + wd->lastActiveWindow = s->display->activeWindow; + moveInputFocusToWindow (highest); + } + else if (!map) + { + w = findWindowAtDisplay (s->display, wd->lastActiveWindow); + if (w) + moveInputFocusToWindow (w); + } } static Bool