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
This commit is contained in:
Axel Dörfler
2005-12-08 14:45:42 +00:00
parent 799c100e79
commit 72994381f2
+32 -4
View File
@@ -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();
}