From 72994381f2e4cd59054bdd908248e6f60d960fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 8 Dec 2005 14:45:42 +0000 Subject: [PATCH] Windows currently being dragged now follow workspace switches. Desktop::_ChangeWindowWorkspaces() and SetWorkspace() didn't lock the window list, but should have. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15421 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Desktop.cpp | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index ae2a093dd6..e495019480 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -579,8 +579,29 @@ Desktop::SetWorkspace(int32 index) if (index < 0 || index >= settings.WorkspacesCount() || index == fCurrentWorkspace) return; + WriteLockWindows(); + int32 previousIndex = fCurrentWorkspace; + if (fMouseEventWindow != NULL) { + // the window currently being dragged will follow us to this workspace + // if it's not already on it + if (!fMouseEventWindow->OnWorkspace(index)) { + fWorkspaces[index].Windows().AddWindow(fMouseEventWindow); + fMouseEventWindow->SetWorkspaces((fMouseEventWindow->Workspaces() + | workspace_to_workspaces(index)) + & ~workspace_to_workspaces(previousIndex)); + fWorkspaces[previousIndex].Windows().RemoveWindow(fMouseEventWindow); + } else { + // make sure it's frontmost + fWorkspaces[index].Windows().RemoveWindow(fMouseEventWindow); + fWorkspaces[index].Windows().AddWindow(fMouseEventWindow, + fMouseEventWindow->Frontmost(fWorkspaces[index].Windows().FirstWindow(), index)); + } + + fMouseEventWindow->Anchor(index).position = fMouseEventWindow->Frame().LeftTop(); + } + // build region of windows that are no longer visible in the new workspace BRegion dirty; @@ -640,7 +661,7 @@ Desktop::SetWorkspace(int32 index) for (WindowLayer* window = _CurrentWindows().FirstWindow(); window != NULL; window = window->NextWindow(index)) { - if (window->OnWorkspace(previousIndex)) { + if (window->OnWorkspace(previousIndex) || window == fMouseEventWindow) { // this window was visible before, and is already handled in the above loop continue; } @@ -652,7 +673,9 @@ Desktop::SetWorkspace(int32 index) SetFocusWindow(FrontWindow()); MarkDirty(dirty); + //_WindowsChanged(); + WriteUnlockWindows(); } @@ -1117,8 +1140,9 @@ void Desktop::_ChangeWindowWorkspaces(WindowLayer* window, uint32 oldWorkspaces, uint32 newWorkspaces) { - // apply changes to the workspaces' window list - // (and RootLayer, for the current workspace) + // apply changes to the workspaces' window lists + + WriteLockWindows(); for (int32 i = 0; i < kMaxWorkspaces; i++) { if (workspaces_on_workspace(i, oldWorkspaces)) { @@ -1145,6 +1169,8 @@ Desktop::_ChangeWindowWorkspaces(WindowLayer* window, uint32 oldWorkspaces, } } } + + WriteUnlockWindows(); } @@ -1152,12 +1178,14 @@ void Desktop::SetWindowWorkspaces(WindowLayer* window, uint32 workspaces) { BAutolock _(this); - + if (workspaces == B_CURRENT_WORKSPACE) workspaces = workspace_to_workspaces(CurrentWorkspace()); + WriteLockWindows(); _ChangeWindowWorkspaces(window, window->Workspaces(), workspaces); window->SetWorkspaces(workspaces); + WriteUnlockWindows(); }