From a8f4e1d0fdc01577fb71a008cc41fe5f261fd380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 12 Aug 2008 17:33:32 +0000 Subject: [PATCH] * _ActivateApp() did not lock the window list while traversing it. * It will now first iterate through the windows on the current workspace to choose the topmost window of this team (for this, it would be nice to have a sorted list over all windows/workspaces). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26950 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Desktop.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 6d8a6560ae..8df7da5c02 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -667,10 +667,26 @@ Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) status_t Desktop::_ActivateApp(team_id team) { - status_t status = B_BAD_TEAM_ID; + // search for an unhidden window in the current workspace + + LockSingleWindow(); + + for (Window* window = _CurrentWindows().LastWindow(); window != NULL; + window = window->PreviousWindow(fCurrentWorkspace)) { + if (!window->IsHidden() && window->IsNormal() + && window->ServerWindow()->ClientTeam() == team) { + ActivateWindow(window); + UnlockSingleWindow(); + return B_OK; + } + } + + UnlockSingleWindow(); // search for an unhidden window to give focus to + AutoWriteLocker locker(fWindowLock); + for (Window* window = fAllWindows.FirstWindow(); window != NULL; window = window->NextWindow(kAllWindowList)) { // if window is a normal window of the team, and not hidden, @@ -682,7 +698,7 @@ Desktop::_ActivateApp(team_id team) } } - return status; + return B_BAD_VALUE; }