void TTracker::OpenContainerWindow(Model *model, BMessage *originalRefsList, OpenSelector openSelector, uint32 openFlags, bool checkAlreadyOpen, const BMessage *stateMessage) { AutoLock<WindowList> lock(&fWindowList); BContainerWindow *window = NULL; if (checkAlreadyOpen && openSelector != kRunOpenWithWindow) // find out if window already open window = FindContainerWindow(model->NodeRef()); bool someWindowActivated = false; uint32 workspace = (uint32)(1 << current_workspace()); int32 windowCount = 0; while (window) { // At least one window open, just pull to front // make sure we don't jerk workspaces around uint32 windowWorkspaces = window->Workspaces(); if (windowWorkspaces & workspace) { window->Activate(); someWindowActivated = true; } window = FindContainerWindow(model->NodeRef(), ++windowCount); } if (someWindowActivated) { delete model; return; } // If no window was actiated, (none in the current workspace // we open a new one. if (openSelector == kRunOpenWithWindow) { BMessage *refList = NULL; if (!originalRefsList) { // when passing just a single model, stuff it's entry in a single // element list anyway ASSERT(model); refList = new BMessage; refList->AddRef("refs", model->EntryRef()); delete model; model = NULL; } else // clone the message, window adopts it for it's own use refList = new BMessage(*originalRefsList); window = new OpenWithContainerWindow(refList, &fWindowList); } else if (model->IsRoot()) { // window will adopt the model window = new BVolumeWindow(&fWindowList, openFlags); } else if (model->IsQuery()) { // window will adopt the model window = new BQueryContainerWindow(&fWindowList, openFlags); } else // window will adopt the model window = new BContainerWindow(&fWindowList, openFlags); if (model) window->CreatePoseView(model); BMessage restoreStateMessage(kRestoreState); if (stateMessage) restoreStateMessage.AddMessage("state", stateMessage); window->PostMessage(&restoreStateMessage); }
void TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList, OpenSelector openSelector, uint32 openFlags, bool checkAlreadyOpen, const BMessage* stateMessage) { AutoLock<WindowList> lock(&fWindowList); BContainerWindow* window = NULL; const node_ref* modelNodeRef = model->NodeRef(); if (checkAlreadyOpen && openSelector != kRunOpenWithWindow) { // find out if window already open window = FindContainerWindow(modelNodeRef); } bool someWindowActivated = false; uint32 workspace = (uint32)(1 << current_workspace()); int32 windowCount = 0; while (window != NULL) { if ((window->Workspaces() & workspace) != 0 && (dynamic_cast<BDeskWindow*>(window) == NULL || !TrackerSettings().SingleWindowBrowse())) { // We found at least one window that is open and is not Desktop // or we're in spatial mode, activate it and make sure we don't // jerk the workspaces around. window->Activate(); someWindowActivated = true; } window = FindContainerWindow(model->NodeRef(), ++windowCount); } if (someWindowActivated) { delete model; return; } // If no window was activated (none in the current workspace), // we open a new one. if (openSelector == kRunOpenWithWindow) { BMessage* refList = NULL; if (originalRefsList == NULL) { // when passing just a single model, stuff it's entry in a single // element list anyway ASSERT(model != NULL); refList = new BMessage; refList->AddRef("refs", model->EntryRef()); delete model; model = NULL; } else { // clone the message, window adopts it for it's own use refList = new BMessage(*originalRefsList); } window = new OpenWithContainerWindow(refList, &fWindowList); } else if (model->IsQuery()) { // window will adopt the model window = new BQueryContainerWindow(&fWindowList, openFlags); } else if (model->IsVirtualDirectory()) { // window will adopt the model window = new VirtualDirectoryWindow(&fWindowList, openFlags); } else { // window will adopt the model window = new BContainerWindow(&fWindowList, openFlags); } if (model != NULL) window->CreatePoseView(model); BMessage restoreStateMessage(kRestoreState); if (stateMessage != NULL) restoreStateMessage.AddMessage("state", stateMessage); window->PostMessage(&restoreStateMessage); }