2004-01-17 21:37:57 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2004-09-21 02:50:02 +04:00
|
|
|
// Copyright (c) 2001-2002, Haiku, Inc.
|
2004-01-17 21:37:57 +03:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
//
|
|
|
|
// File Name: Workspace.cpp
|
2004-06-18 15:50:17 +04:00
|
|
|
// Author: Adi Oanca <adioanca@mymail.ro>
|
2004-01-17 21:37:57 +03:00
|
|
|
// Description: Tracks workspaces
|
|
|
|
//
|
2004-07-11 14:01:01 +04:00
|
|
|
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
// Notes: IMPORTANT WARNING
|
|
|
|
// This object does not use any locking mechanism. It is designed
|
|
|
|
// to be used only by RootLayer class. DO NOT USE from another class!
|
2004-01-17 21:37:57 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2004-11-06 19:54:05 +03:00
|
|
|
#include <AppDefs.h>
|
|
|
|
#include <Message.h>
|
2004-01-12 01:12:55 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <Window.h>
|
|
|
|
|
|
|
|
#include "Workspace.h"
|
|
|
|
#include "Layer.h"
|
|
|
|
#include "WinBorder.h"
|
|
|
|
#include "ServerWindow.h"
|
2004-01-13 04:03:29 +03:00
|
|
|
#include "ServerApp.h"
|
2004-01-12 01:12:55 +03:00
|
|
|
#include "RGBColor.h"
|
|
|
|
#include "Globals.h"
|
|
|
|
#include "FMWList.h"
|
|
|
|
|
2004-01-21 05:58:39 +03:00
|
|
|
//#define DEBUG_WORKSPACE
|
2004-01-12 01:12:55 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG_WORKSPACE
|
|
|
|
# include <stdio.h>
|
|
|
|
# define STRACE(x) printf x
|
|
|
|
#else
|
|
|
|
# define STRACE(x) ;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG_WORKSPACE
|
|
|
|
# include <stdio.h>
|
|
|
|
# define STRACESTREAM() PrintToStream()
|
|
|
|
#else
|
|
|
|
# define STRACESTREAM() ;
|
|
|
|
#endif
|
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-07-11 14:01:01 +04:00
|
|
|
Workspace::Workspace(const uint32 colorspace, int32 ID, const RGBColor& BGColor)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
fID = ID;
|
|
|
|
fSpace = colorspace;
|
|
|
|
fBGColor = BGColor;
|
2004-01-13 04:03:29 +03:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
fBottomItem = NULL;
|
|
|
|
fTopItem = NULL;
|
|
|
|
fCurrentItem= NULL;
|
|
|
|
fFocusItem = NULL;
|
|
|
|
fFrontItem = NULL;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
fVirtualWidth=-1;
|
|
|
|
fVirtualHeight=-1;
|
|
|
|
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: find out more about good default values for display timing and init the structure to them
|
2004-06-26 06:15:48 +04:00
|
|
|
fDisplayTiming.pixel_clock=0;
|
|
|
|
fDisplayTiming.h_display=0;
|
|
|
|
fDisplayTiming.h_sync_start=0;
|
|
|
|
fDisplayTiming.h_sync_end=0;
|
|
|
|
fDisplayTiming.h_total=0;
|
|
|
|
fDisplayTiming.v_display=0;
|
|
|
|
fDisplayTiming.v_sync_start=0;
|
|
|
|
fDisplayTiming.v_sync_end=0;
|
|
|
|
fDisplayTiming.v_total=0;
|
|
|
|
fDisplayTiming.flags=0;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
Workspace::~Workspace(void)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *toast;
|
2004-06-26 06:15:48 +04:00
|
|
|
while(fBottomItem)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
toast = fBottomItem;
|
|
|
|
fBottomItem = fBottomItem->upperItem;
|
|
|
|
|
|
|
|
delete toast;
|
|
|
|
}
|
|
|
|
fBottomItem = NULL;
|
|
|
|
fTopItem = NULL;
|
|
|
|
fCurrentItem = NULL;
|
|
|
|
fFocusItem = NULL;
|
|
|
|
fFrontItem = NULL;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2004-06-26 06:15:48 +04:00
|
|
|
/*
|
|
|
|
Adds layer ptr to workspace's list of WinBorders. After the item is added a
|
|
|
|
*smart* search is performed to set the new front WinBorder. Of course,
|
|
|
|
the first candidate is 'layer', but if it is hidden or it has the
|
|
|
|
B_AVOID_FRONT flag, surely it won't get that status.
|
|
|
|
This method also calls SearchAndSetNewFocus which searches for a WinBorder,
|
|
|
|
to give focus to, having as preferred 'layer'.
|
|
|
|
Remember, some windows having B_AVOID_FOCUS can't have the focus state.
|
|
|
|
*/
|
2004-07-11 14:01:01 +04:00
|
|
|
bool Workspace::AddWinBorder(WinBorder *layer)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2004-07-10 10:28:41 +04:00
|
|
|
if (layer == NULL)
|
|
|
|
debugger("NULL pointer in Workspace::AddLayerPtr\n");
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// allocate a new item
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *item;
|
|
|
|
item = new ListData;
|
|
|
|
|
|
|
|
item->layerPtr = layer;
|
|
|
|
item->upperItem = NULL;
|
|
|
|
item->lowerItem = NULL;
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// insert 'item' at the end. It doesn't matter where we add it,
|
|
|
|
// it will be placed correctly by SearchAndSetNewFront(item->layerPtr);
|
2004-01-12 01:12:55 +03:00
|
|
|
InsertItem(item, NULL);
|
2004-01-13 04:03:29 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
STRACE(("\n*AddLayerPtr(%s) -", layer->GetName()));
|
2004-01-14 18:55:10 +03:00
|
|
|
|
2004-07-10 10:28:41 +04:00
|
|
|
BringToFrontANormalWindow(layer);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 10:28:41 +04:00
|
|
|
// do a *smart* search and set the new 'front'
|
|
|
|
SearchAndSetNewFront(layer);
|
|
|
|
|
|
|
|
// do a *smart* search and set the new 'focus'
|
|
|
|
SearchAndSetNewFocus(layer);
|
2004-01-14 03:26:15 +03:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
return true;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2004-06-26 06:15:48 +04:00
|
|
|
/*
|
|
|
|
Removes a WinBorder from workspace's list. It DOES NOT delete it!
|
|
|
|
If this window was the front/focus one it calls SearchAndSetNew(Front/Focus)
|
|
|
|
to give the respective state to the window below her.
|
|
|
|
*/
|
2004-07-11 14:01:01 +04:00
|
|
|
bool Workspace::RemoveWinBorder(WinBorder *layer)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2004-07-11 14:01:01 +04:00
|
|
|
if (layer == NULL)
|
2004-01-12 01:12:55 +03:00
|
|
|
return false;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
STRACE(("\n*Workspace(%ld)::RemoveLayerPtr(%s)\n", ID(), layer->GetName()));
|
|
|
|
STRACE(("BEFORE ANY opperation:\n"));
|
|
|
|
STRACESTREAM();
|
|
|
|
|
|
|
|
// search to see if this workspace has WinBorder's pointer in its list
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *item = NULL;
|
2004-01-14 03:26:15 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
if((item = HasItem(layer)))
|
|
|
|
{
|
2004-01-17 19:33:22 +03:00
|
|
|
ListData *nextItem = NULL;
|
|
|
|
bool wasFront = false;
|
|
|
|
bool wasFocus = false;
|
|
|
|
|
|
|
|
wasFront = FrontLayer() == layer;
|
|
|
|
wasFocus = FocusLayer() == layer;
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// prepare to set new front/focus if this layer was front/focus
|
2004-01-12 01:12:55 +03:00
|
|
|
nextItem = item->upperItem;
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
if(wasFront)
|
2004-01-17 19:33:22 +03:00
|
|
|
SearchAndSetNewFront(nextItem? nextItem->layerPtr: NULL);
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// remove some windows.
|
|
|
|
if(item && item->layerPtr->fLevel == B_NORMAL_FEEL)
|
2004-01-17 19:33:22 +03:00
|
|
|
{
|
|
|
|
ListData *listItem = item->lowerItem;
|
2004-06-11 22:21:57 +04:00
|
|
|
while(listItem && (listItem->layerPtr->fLevel == B_FLOATING_SUBSET_FEEL
|
2004-06-26 06:15:48 +04:00
|
|
|
|| listItem->layerPtr->fLevel == B_FLOATING_APP_FEEL
|
|
|
|
|| listItem->layerPtr->fLevel == B_MODAL_SUBSET_FEEL))
|
2004-01-17 19:33:22 +03:00
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
// *carefuly* remove the item from the list
|
2004-01-17 19:33:22 +03:00
|
|
|
ListData *itemX = listItem;
|
|
|
|
listItem = listItem->lowerItem;
|
|
|
|
RemoveItem(itemX);
|
|
|
|
delete itemX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RemoveItem(item);
|
|
|
|
delete item;
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACESTREAM();
|
2004-01-14 03:26:15 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// reset some internal variables
|
2004-01-12 01:12:55 +03:00
|
|
|
layer->SetMainWinBorder(NULL);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("Layer %s found and removed from Workspace No %ld\n", layer->GetName(), ID()));
|
2004-01-13 04:03:29 +03:00
|
|
|
|
2004-07-10 10:28:41 +04:00
|
|
|
SearchAndSetNewFocus(nextItem? nextItem->layerPtr: NULL);
|
2004-01-14 03:26:15 +03:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
return true;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
{
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("Layer %s NOT found in Workspace No %ld\n", layer->GetName(), ID()));
|
2004-01-12 01:12:55 +03:00
|
|
|
return false;
|
2004-01-13 04:03:29 +03:00
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
bool Workspace::HideSubsetWindows(WinBorder *layer)
|
|
|
|
{
|
|
|
|
if(!layer)
|
2004-01-17 19:33:22 +03:00
|
|
|
return false;
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// search to see if this workspace has WinBorder's pointer in its list
|
2004-01-17 19:33:22 +03:00
|
|
|
ListData *item = NULL;
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
if((item = HasItem(layer)))
|
|
|
|
{
|
2004-01-17 19:33:22 +03:00
|
|
|
ListData *nextItem = NULL;
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// prepare to set new front/focus if this layer was front/focus
|
2004-01-17 19:33:22 +03:00
|
|
|
nextItem = item->upperItem;
|
|
|
|
|
|
|
|
SearchAndSetNewFront(nextItem? nextItem->layerPtr: NULL);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// we don't care about focus in this method
|
2004-01-17 19:33:22 +03:00
|
|
|
//SearchAndSetNewFocus(nextItem? nextItem->layerPtr: NULL);
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// remove some windows.
|
|
|
|
if(item && item->layerPtr->fLevel == B_NORMAL_FEEL)
|
2004-01-17 19:33:22 +03:00
|
|
|
{
|
|
|
|
ListData *listItem = item->lowerItem;
|
2004-06-11 22:21:57 +04:00
|
|
|
while(listItem && (listItem->layerPtr->fLevel == B_FLOATING_SUBSET_FEEL
|
2004-06-26 06:15:48 +04:00
|
|
|
|| listItem->layerPtr->fLevel == B_FLOATING_APP_FEEL
|
|
|
|
|| listItem->layerPtr->fLevel == B_MODAL_SUBSET_FEEL))
|
2004-01-17 19:33:22 +03:00
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
// carefully remove the item from the list
|
2004-01-17 19:33:22 +03:00
|
|
|
ListData *itemX = listItem;
|
|
|
|
listItem = listItem->lowerItem;
|
|
|
|
RemoveItem(itemX);
|
|
|
|
delete itemX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
{
|
2004-01-17 19:33:22 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
WinBorder *Workspace::FocusLayer() const
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fFocusItem ? fFocusItem->layerPtr : NULL;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
WinBorder *Workspace::FrontLayer() const
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fFrontItem? fFrontItem->layerPtr: NULL;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
WinBorder *Workspace::GoToBottomItem(void)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
fCurrentItem = fBottomItem;
|
|
|
|
return fCurrentItem ? fCurrentItem->layerPtr : NULL;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
WinBorder *Workspace::GoToUpperItem(void)
|
|
|
|
{
|
|
|
|
if(fCurrentItem)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
fCurrentItem = fCurrentItem->upperItem;
|
|
|
|
return fCurrentItem ? fCurrentItem->layerPtr : NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
WinBorder *Workspace::GoToTopItem(void)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
fCurrentItem = fTopItem;
|
|
|
|
return fCurrentItem ? fCurrentItem->layerPtr : NULL;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
WinBorder *Workspace::GoToLowerItem(void)
|
|
|
|
{
|
|
|
|
if(fCurrentItem)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
fCurrentItem = fCurrentItem->lowerItem;
|
|
|
|
return fCurrentItem ? fCurrentItem->layerPtr : NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
bool Workspace::GoToItem(WinBorder *layer)
|
|
|
|
{
|
|
|
|
if(!layer)
|
2004-01-12 01:12:55 +03:00
|
|
|
return false;
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
if(fCurrentItem && fCurrentItem->layerPtr == layer)
|
2004-01-12 01:12:55 +03:00
|
|
|
return true;
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
for( ListData *item = fBottomItem; item != NULL; item = item->upperItem)
|
|
|
|
{
|
|
|
|
if(item->layerPtr == layer)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
fCurrentItem = item;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
ListData *Workspace::HasItem(ListData *item)
|
|
|
|
{
|
|
|
|
for (ListData *itemX = fBottomItem; itemX != NULL; itemX = itemX->upperItem)
|
|
|
|
{
|
|
|
|
if(item == itemX)
|
2004-01-12 01:12:55 +03:00
|
|
|
return itemX;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
ListData *Workspace::HasItem(WinBorder *layer)
|
|
|
|
{
|
|
|
|
for (ListData *item = fBottomItem; item != NULL; item = item->upperItem)
|
|
|
|
{
|
|
|
|
if(item->layerPtr == layer)
|
2004-01-12 01:12:55 +03:00
|
|
|
return item;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-07-10 14:54:20 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
2004-06-26 06:15:48 +04:00
|
|
|
/*
|
|
|
|
This, also is a "smart" method. Firstly this funtionality was in
|
|
|
|
SearchAndSetNewFront, but I've split it for reasons of clarity. Anyway,
|
|
|
|
what is to be noticed is that those 2 methods work hand-in-hand.
|
|
|
|
What FindPlace() litelaly does, isplace* the 'pref' item into its
|
|
|
|
>right< place! If 'pref->layerPtr'(the WinBorder in ListData structure)
|
|
|
|
does not meet some conditions a search for another, valid, WinBorder is
|
|
|
|
being made.
|
|
|
|
|
|
|
|
NOTE: Do NOT be confussed! This method places the preferred windowONLY*!
|
|
|
|
Other windows that need to be placed before it, *WILL* be placed by almost
|
|
|
|
all code found in SearchAndSetNewFront
|
|
|
|
*/
|
|
|
|
ListData *Workspace::FindPlace(ListData *pref)
|
|
|
|
{
|
|
|
|
// if we received a NULL value, we stil have to give 'front' state to some window...
|
|
|
|
if(!pref)
|
2004-01-17 19:33:22 +03:00
|
|
|
pref = HasItem(fBottomItem);
|
|
|
|
else
|
|
|
|
pref = HasItem(pref);
|
2004-01-12 01:12:55 +03:00
|
|
|
|
|
|
|
ListData *item = NULL;
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// search a window that is not hidden and does *not* have B_AVOID_FRONT flag.
|
2004-01-12 01:12:55 +03:00
|
|
|
item = pref;
|
2004-06-26 06:15:48 +04:00
|
|
|
while(pref && item->lowerItem != pref && (pref->upperItem || pref->lowerItem))
|
|
|
|
{
|
|
|
|
if( !(item->layerPtr->Window()->Flags() & B_AVOID_FRONT) && !(item->layerPtr->IsHidden()) )
|
2004-01-12 01:12:55 +03:00
|
|
|
break;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("item: %s - pref: %s\n", item->layerPtr->GetName(), pref->layerPtr->GetName()));
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
if(item == fTopItem)
|
2004-01-12 01:12:55 +03:00
|
|
|
item = fBottomItem;
|
|
|
|
else
|
|
|
|
item = item->upperItem;
|
|
|
|
}
|
2004-01-13 04:03:29 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// if true, it means we have windows with B_AVOID_FRONT flag *only*,
|
|
|
|
// or they are all hidden. Pick one, if you can.
|
|
|
|
if(pref && item->lowerItem == pref)
|
|
|
|
{
|
|
|
|
for (item = fBottomItem; item; item = item->upperItem)
|
|
|
|
{
|
|
|
|
if( !(item->layerPtr->IsHidden()) )
|
2004-01-12 01:12:55 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// if the search took place or not...
|
2004-01-12 01:12:55 +03:00
|
|
|
pref = item;
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// we have exhausted all possibilities to make pref a vaid pointer... so... exit now.
|
|
|
|
if(!pref)
|
2004-01-12 01:12:55 +03:00
|
|
|
return NULL;
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// temporarily remove 'pref' to reinsert it later in the right place
|
2004-01-12 01:12:55 +03:00
|
|
|
RemoveItem(pref);
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// we start searching its place
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *cursor = fBottomItem;
|
2004-01-13 04:03:29 +03:00
|
|
|
int32 feel = pref->layerPtr->Window()->Feel();
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
switch(feel)
|
|
|
|
{
|
|
|
|
case B_NORMAL_WINDOW_FEEL:
|
|
|
|
{
|
|
|
|
while(cursor && cursor->layerPtr->fLevel > B_MODAL_APP_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
cursor = cursor->upperItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
InsertItem(pref, cursor? cursor->lowerItem: NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
case B_SYSTEM_LAST:
|
|
|
|
{
|
|
|
|
while(cursor && cursor->layerPtr->fLevel > pref->layerPtr->fLevel)
|
2004-01-12 01:12:55 +03:00
|
|
|
cursor = cursor->upperItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
InsertItem(pref, cursor? cursor->lowerItem: fTopItem);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case B_SYSTEM_FIRST:
|
|
|
|
case B_FLOATING_ALL_WINDOW_FEEL:
|
|
|
|
case B_MODAL_ALL_WINDOW_FEEL:
|
2004-06-26 06:15:48 +04:00
|
|
|
case B_MODAL_APP_WINDOW_FEEL:
|
|
|
|
{
|
|
|
|
while(cursor && cursor->layerPtr->fLevel > pref->layerPtr->fLevel)
|
2004-01-12 01:12:55 +03:00
|
|
|
cursor = cursor->upperItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
InsertItem(pref, cursor? cursor->lowerItem: NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
case B_FLOATING_SUBSET_WINDOW_FEEL:
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
// place in front of: its main window, other subset windows and in front
|
|
|
|
// of other application's floating windows.
|
|
|
|
// NOTE that this happens only if its main window is the front most one.
|
2004-06-26 06:15:48 +04:00
|
|
|
for(cursor = fBottomItem; cursor; cursor = cursor->upperItem)
|
|
|
|
{
|
|
|
|
if(cursor->layerPtr->fLevel <= pref->layerPtr->fLevel
|
2004-01-12 01:12:55 +03:00
|
|
|
&& (cursor->layerPtr == pref->layerPtr->MainWinBorder()
|
2004-06-26 06:15:48 +04:00
|
|
|
|| cursor->layerPtr->MainWinBorder() == pref->layerPtr->MainWinBorder()) )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if(pref->layerPtr->fLevel == B_FLOATING_SUBSET_FEEL &&
|
|
|
|
cursor->layerPtr->fLevel == B_FLOATING_APP_FEEL)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
if(cursor)
|
2004-01-12 01:12:55 +03:00
|
|
|
InsertItem(pref, cursor? cursor->lowerItem: NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
case B_MODAL_SUBSET_WINDOW_FEEL:
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
// place this SUBSET_MODAL behind APP_MODAL ones if they belong
|
|
|
|
// to the same application OR, in front of all MODAL/NORMAL if
|
|
|
|
// it belongs to another application
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
for(cursor = fBottomItem; cursor; cursor = cursor->upperItem)
|
|
|
|
{
|
|
|
|
if(cursor->layerPtr->fLevel <= pref->layerPtr->fLevel)
|
2004-01-12 01:12:55 +03:00
|
|
|
break;
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
if(pref->layerPtr->fLevel == B_MODAL_SUBSET_FEEL &&
|
|
|
|
cursor->layerPtr->fLevel == B_MODAL_APP_FEEL &&
|
|
|
|
pref->layerPtr->Window()->ClientTeamID() != cursor->layerPtr->Window()->ClientTeamID())
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
break;
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
if(cursor)
|
2004-01-12 01:12:55 +03:00
|
|
|
InsertItem(pref, cursor? cursor->lowerItem: NULL);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
case B_FLOATING_APP_WINDOW_FEEL:
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
// place in front of: its main window, other floating windows
|
|
|
|
// NOTE that this happens only if its main window is the front most one.
|
2004-06-26 06:15:48 +04:00
|
|
|
for(cursor = fBottomItem; cursor; cursor = cursor->upperItem)
|
|
|
|
{
|
|
|
|
if(cursor->layerPtr->fLevel <= pref->layerPtr->fLevel &&
|
|
|
|
pref->layerPtr->Window()->ClientTeamID() == cursor->layerPtr->Window()->ClientTeamID())
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
if(cursor)
|
2004-01-12 01:12:55 +03:00
|
|
|
InsertItem(pref, cursor? cursor->lowerItem: NULL);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pref;
|
|
|
|
}
|
2004-07-10 14:54:20 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
2004-06-26 06:15:48 +04:00
|
|
|
/*
|
|
|
|
This method is the key to correct window arangement
|
|
|
|
With the help of FindPlace it correctly aranges windows. FindPlace, only
|
|
|
|
inserted the window in the correct place, this method also brings all
|
|
|
|
other windows that are supposed to be in front of her - I'm talking here
|
|
|
|
about floating and modal windows.
|
|
|
|
It also cleverly selects the new FINAL front window.
|
2004-01-12 01:12:55 +03:00
|
|
|
*/
|
2004-06-26 06:15:48 +04:00
|
|
|
void Workspace::SearchAndSetNewFront(WinBorder *preferred)
|
|
|
|
{
|
|
|
|
STRACE(("*WS(%ld)::SASNF(%s)\n", ID(), preferred? preferred->GetName(): "NULL"));
|
|
|
|
|
|
|
|
// the new front must not be the same as the previous one.
|
|
|
|
if(fFrontItem && fFrontItem->layerPtr == preferred && !(preferred->IsHidden()))
|
|
|
|
{
|
|
|
|
STRACE(("-WS(%ld)::SASNF(%s) - opperation not needed! Workspace data:",
|
|
|
|
ID(), preferred? preferred->GetName(): "NULL"));
|
|
|
|
STRACESTREAM();
|
|
|
|
STRACE(("#WS(%ld)::SASNF(%s) ENDED 1\n", ID(), preferred? preferred->GetName(): "NULL"));
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
return;
|
2004-01-13 04:03:29 +03:00
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// properly place this 'preferred' WinBorder.
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *lastInserted;
|
|
|
|
lastInserted = FindPlace(HasItem(preferred));
|
|
|
|
preferred = lastInserted? lastInserted->layerPtr: NULL;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
STRACE(("-WS(%ld)::SASNF(%s) - after FindPlace...", ID(), preferred? preferred->GetName(): "NULL"));
|
|
|
|
STRACESTREAM();
|
|
|
|
|
|
|
|
// if the new front layer is the same... there is no point continuing
|
|
|
|
if(fFrontItem == lastInserted)
|
|
|
|
{
|
|
|
|
STRACE(("-WS(%ld)::SASNF(%s) - new front layer is the same as the old one. Stop!", ID(), preferred? preferred->GetName(): "NULL"));
|
|
|
|
STRACESTREAM();
|
|
|
|
STRACE(("#WS(%ld)::SASNF(%s) ENDED 2\n", ID(), preferred? preferred->GetName(): "NULL"));
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
return;
|
2004-01-13 04:03:29 +03:00
|
|
|
}
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
if(!lastInserted)
|
|
|
|
{
|
|
|
|
STRACE(("PAAAAANIC: Workspace::SASNF(): 'lastInserted' IS NULL\n"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
STRACE(("\n&&&&Processing for: %s\n", lastInserted->layerPtr->GetName()));
|
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
if(lastInserted && !(lastInserted->layerPtr->IsHidden()))
|
|
|
|
{
|
2004-01-13 04:03:29 +03:00
|
|
|
int32 prefFeel = preferred->Window()->Feel();
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
if(prefFeel == B_NORMAL_WINDOW_FEEL)
|
|
|
|
{
|
|
|
|
STRACE((" NORMAL Window '%s' -", preferred? preferred->GetName(): "NULL"));
|
|
|
|
|
|
|
|
if(fFrontItem)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
// if they are in the same team...
|
2004-06-26 06:15:48 +04:00
|
|
|
if(preferred->Window()->ClientTeamID() == fFrontItem->layerPtr->Window()->ClientTeamID())
|
|
|
|
{
|
|
|
|
STRACE((" SAME TeamID\n"));
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
// collect subset windows that are common to application's windows...
|
|
|
|
// NOTE: A subset window *can* be added to more than just one window.
|
2004-06-26 06:15:48 +04:00
|
|
|
FMWList commonFMW;
|
|
|
|
FMWList appFMW;
|
|
|
|
FMWList finalFMWList;
|
|
|
|
int32 count, i;
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
// collect floating and modal windows spread across the workspace only if
|
|
|
|
// they are in our window's subset
|
|
|
|
// * also remove them, for repositioning, later.
|
2004-06-26 06:15:48 +04:00
|
|
|
ListData *listItem = fTopItem;
|
|
|
|
while(listItem)
|
|
|
|
{
|
|
|
|
int32 feel = listItem->layerPtr->Window()->Feel();
|
|
|
|
if(feel == B_FLOATING_SUBSET_WINDOW_FEEL || feel == B_MODAL_SUBSET_WINDOW_FEEL)
|
|
|
|
{
|
|
|
|
if(preferred->Window()->fWinFMWList.HasItem(listItem->layerPtr))
|
|
|
|
{
|
|
|
|
commonFMW.AddItem(listItem->layerPtr);
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
// *carefully* remove the item from the list
|
2004-06-26 06:15:48 +04:00
|
|
|
ListData *item = listItem;
|
|
|
|
listItem = listItem->lowerItem;
|
|
|
|
RemoveItem(item);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if(feel == B_FLOATING_SUBSET_WINDOW_FEEL)
|
|
|
|
{
|
|
|
|
// also remove floating windows. Those, SURELY belong to
|
|
|
|
// 'fFrontItem' - this being the *old* front window.
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
// *carefully* remove the item from the list
|
2004-06-26 06:15:48 +04:00
|
|
|
ListData *item = listItem;
|
|
|
|
listItem = listItem->lowerItem;
|
|
|
|
RemoveItem(item);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
listItem = listItem->lowerItem;
|
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else if(feel == B_FLOATING_APP_WINDOW_FEEL || feel == B_MODAL_APP_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
// ALSO collect application's floating and modal windows,
|
|
|
|
// for reinsertion, later.
|
|
|
|
|
|
|
|
if(listItem->layerPtr->Window()->ClientTeamID() ==
|
|
|
|
preferred->Window()->ClientTeamID())
|
|
|
|
{
|
|
|
|
appFMW.AddItem(listItem->layerPtr);
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
// *carefully* remove the item from the list
|
2004-06-26 06:15:48 +04:00
|
|
|
ListData *item = listItem;
|
|
|
|
listItem = listItem->lowerItem;
|
|
|
|
RemoveItem(item);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
listItem = listItem->lowerItem;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-01-14 03:26:15 +03:00
|
|
|
else
|
|
|
|
listItem = listItem->lowerItem;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
// put in the final list, items that are not found in the common list
|
2004-06-26 06:15:48 +04:00
|
|
|
count = preferred->Window()->fWinFMWList.CountItems();
|
|
|
|
for (i=0; i<count; i++)
|
|
|
|
{
|
|
|
|
void *item = preferred->Window()->fWinFMWList.ItemAt(i);
|
|
|
|
|
|
|
|
if(!commonFMW.HasItem(item))
|
|
|
|
finalFMWList.AddItem(item);
|
2004-01-17 19:33:22 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// collapse the 2 lists
|
|
|
|
finalFMWList.AddFMWList(&commonFMW);
|
|
|
|
finalFMWList.AddFMWList(&appFMW);
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
// insert windows found in 'finalFMWList' in Workspace's list.
|
|
|
|
// IF *one* modal is found, do not add floating ones!
|
|
|
|
|
|
|
|
// see if the last WinBorder in the list is a modal window.
|
|
|
|
// OR if the last one in Workspace's list is a modal window...
|
2004-06-26 06:15:48 +04:00
|
|
|
WinBorder *wb = (WinBorder*)finalFMWList.LastItem();
|
|
|
|
bool lastIsModal = false;
|
|
|
|
if( (wb &&
|
|
|
|
(wb->Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL
|
|
|
|
|| wb->Window()->Feel() == B_MODAL_APP_WINDOW_FEEL))
|
|
|
|
|| (fBottomItem &&
|
|
|
|
(fBottomItem->layerPtr->Window()->Feel() == B_MODAL_ALL_WINDOW_FEEL
|
|
|
|
|| fBottomItem->layerPtr->Window()->Feel() == B_SYSTEM_FIRST))
|
|
|
|
)
|
|
|
|
{ lastIsModal = true; }
|
|
|
|
|
|
|
|
// this variable will help us in deciding the new front WinBorder.
|
|
|
|
WinBorder *finalPreferred = preferred;
|
|
|
|
// now insert items found in finalFMWList into Workspace
|
|
|
|
count = finalFMWList.CountItems();
|
|
|
|
for(i=0; i<count; i++)
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
WinBorder *wb = (WinBorder*)finalFMWList.ItemAt(i);
|
|
|
|
if(wb->Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL
|
|
|
|
|| wb->Window()->Feel() == B_FLOATING_APP_WINDOW_FEEL)
|
|
|
|
{
|
|
|
|
// set its new MainWinBorder
|
|
|
|
if(wb->Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL)
|
|
|
|
wb->SetMainWinBorder(preferred);
|
|
|
|
// don't add if the last WinBorder is a modal one.
|
|
|
|
if(lastIsModal)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(wb->Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL)
|
|
|
|
wb->SetMainWinBorder(preferred);
|
|
|
|
// if this modal window is not hidden, give it the front status.
|
|
|
|
if(!(wb->IsHidden()))
|
|
|
|
finalPreferred = wb;
|
|
|
|
}
|
|
|
|
|
|
|
|
// insert item just after the last inserted one.
|
|
|
|
ListData *newItem = new ListData();
|
|
|
|
newItem->layerPtr = wb;
|
|
|
|
newItem->lowerItem = lastInserted->lowerItem;
|
|
|
|
newItem->upperItem = lastInserted;
|
|
|
|
if(lastInserted->lowerItem)
|
|
|
|
lastInserted->lowerItem->upperItem = newItem;
|
|
|
|
lastInserted->lowerItem = newItem;
|
|
|
|
|
|
|
|
if(lastInserted == fBottomItem)
|
|
|
|
fBottomItem = newItem;
|
|
|
|
|
|
|
|
lastInserted = newItem;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
preferred = finalPreferred;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
STRACE((" DIFERRENT TeamID\n"));
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
// remove front window's floating(_SUBSET_/_APP_) windows, if any.
|
2004-06-26 06:15:48 +04:00
|
|
|
ListData *listItem = fFrontItem->lowerItem;
|
|
|
|
|
|
|
|
while(listItem && (listItem->layerPtr->fLevel == B_FLOATING_SUBSET_FEEL
|
|
|
|
|| listItem->layerPtr->fLevel == B_FLOATING_APP_FEEL))
|
|
|
|
{
|
|
|
|
// *carefully* remove the item from the list
|
|
|
|
ListData *item = listItem;
|
|
|
|
listItem = listItem->lowerItem;
|
|
|
|
RemoveItem(item);
|
|
|
|
}
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
// now, jump to et1: to make a 'clean' selecting of
|
|
|
|
// windows to be inserted
|
2004-06-26 06:15:48 +04:00
|
|
|
fFrontItem = NULL;
|
|
|
|
goto et1;
|
|
|
|
} // END: else - if different ClientTeamIDs.
|
|
|
|
|
|
|
|
} // if(fFrontItem) && NORMAL_WINDOW
|
|
|
|
else
|
|
|
|
{
|
|
|
|
STRACE((" NO previous FRONT Item\n"));
|
2004-01-12 01:12:55 +03:00
|
|
|
et1:
|
|
|
|
FMWList finalFMWList;
|
|
|
|
int32 count, i;
|
|
|
|
ListData *listItem = fTopItem;
|
|
|
|
// remove window's subset and application's *modal* windows spread
|
|
|
|
// across Workspace's list, to be insert later, in the corect order.
|
2004-06-26 06:15:48 +04:00
|
|
|
while(listItem)
|
|
|
|
{
|
2004-01-13 04:03:29 +03:00
|
|
|
int32 feel = listItem->layerPtr->Window()->Feel();
|
2004-06-26 06:15:48 +04:00
|
|
|
if((feel == B_MODAL_SUBSET_WINDOW_FEEL
|
2004-01-13 04:03:29 +03:00
|
|
|
&& preferred->Window()->fWinFMWList.HasItem(listItem->layerPtr))
|
2004-01-12 01:12:55 +03:00
|
|
|
|| (feel == B_MODAL_APP_WINDOW_FEEL
|
2004-01-13 04:03:29 +03:00
|
|
|
&& preferred->Window()->ClientTeamID() ==
|
|
|
|
listItem->layerPtr->Window()->ClientTeamID()
|
2004-01-12 01:12:55 +03:00
|
|
|
))
|
|
|
|
{
|
|
|
|
// *carefully* remove the item from the list
|
|
|
|
ListData *item = listItem;
|
|
|
|
listItem = listItem->lowerItem;
|
|
|
|
RemoveItem(item);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
listItem = listItem->lowerItem;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// add to the final list window's subset windows. (..._SUBSET_...)
|
2004-01-13 04:03:29 +03:00
|
|
|
finalFMWList.AddFMWList(&(preferred->Window()->fWinFMWList));
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// also add application's ones. (..._APP_...)
|
2004-01-13 04:03:29 +03:00
|
|
|
finalFMWList.AddFMWList(&(preferred->Window()->App()->fAppFMWList));
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// insert windows found in 'finalFMWList' in Workspace's list.
|
|
|
|
// IF *one* modal is found, do not add floating ones!
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// see if the last WinBorder in the list is a modal window.
|
2004-01-12 01:12:55 +03:00
|
|
|
WinBorder *wb = (WinBorder*)finalFMWList.LastItem();
|
|
|
|
bool lastIsModal = false;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
if( (wb && (wb->Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL ||
|
|
|
|
wb->Window()->Feel() == B_MODAL_APP_WINDOW_FEEL)) ||
|
|
|
|
(fBottomItem && (fBottomItem->layerPtr->Window()->Feel() == B_MODAL_ALL_WINDOW_FEEL ||
|
|
|
|
fBottomItem->layerPtr->Window()->Feel() == B_SYSTEM_FIRST))
|
2004-01-12 01:12:55 +03:00
|
|
|
)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
|
|
|
lastIsModal = true;
|
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// this variable will help us in deciding the new front WinBorder.
|
2004-01-12 01:12:55 +03:00
|
|
|
WinBorder *finalPreferred = preferred;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// now insert items found in finalFMWList into Workspace
|
2004-01-12 01:12:55 +03:00
|
|
|
count = finalFMWList.CountItems();
|
2004-06-26 06:15:48 +04:00
|
|
|
for(i=0; i<count; i++)
|
|
|
|
{
|
|
|
|
WinBorder *wb = (WinBorder*)finalFMWList.ItemAt(i);
|
|
|
|
|
|
|
|
// do not insert floating windows if the last is a modal one.
|
|
|
|
if(wb->Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL ||
|
|
|
|
wb->Window()->Feel() == B_FLOATING_APP_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
// set its new MainWinBorder
|
2004-01-13 04:03:29 +03:00
|
|
|
if(wb->Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
wb->SetMainWinBorder(preferred);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// don't add if the last WinBorder is a modal one.
|
|
|
|
if(lastIsModal)
|
2004-01-12 01:12:55 +03:00
|
|
|
continue;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
{
|
2004-01-13 04:03:29 +03:00
|
|
|
if(wb->Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
wb->SetMainWinBorder(preferred);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// if this modal window is not hidden, give it the front status.
|
|
|
|
if(!(wb->IsHidden()))
|
2004-01-12 01:12:55 +03:00
|
|
|
finalPreferred = wb;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// insert item just after the last inserted one.
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *newItem = new ListData();
|
|
|
|
newItem->layerPtr = wb;
|
|
|
|
newItem->lowerItem = lastInserted->lowerItem;
|
|
|
|
newItem->upperItem = lastInserted;
|
2004-06-26 06:15:48 +04:00
|
|
|
if(lastInserted->lowerItem)
|
2004-01-12 01:12:55 +03:00
|
|
|
lastInserted->lowerItem->upperItem = newItem;
|
|
|
|
lastInserted->lowerItem = newItem;
|
|
|
|
|
|
|
|
if(lastInserted == fBottomItem)
|
|
|
|
fBottomItem = newItem;
|
|
|
|
|
|
|
|
lastInserted = newItem;
|
|
|
|
}
|
|
|
|
preferred = finalPreferred;
|
|
|
|
} // else - if(fFrontItem);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
} // END: if _NORMAL_ window.
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
if( prefFeel == B_FLOATING_SUBSET_WINDOW_FEEL ||
|
|
|
|
prefFeel == B_FLOATING_APP_WINDOW_FEEL ||
|
|
|
|
prefFeel == B_FLOATING_ALL_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
STRACE((" FLOATING Window '%s'\n", preferred? preferred->GetName(): "NULL"));
|
2004-01-12 01:12:55 +03:00
|
|
|
// Do nothing! FindPlace() was called and it has corectly placed our window
|
|
|
|
// We don't have to do noting here.
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
if( prefFeel == B_MODAL_SUBSET_WINDOW_FEEL ||
|
|
|
|
prefFeel == B_MODAL_APP_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
STRACE((" MODAL_APP/SUBSET Window '%s'\n", preferred? preferred->GetName(): "NULL"));
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
FMWList finalMWList;
|
2004-01-13 04:03:29 +03:00
|
|
|
int32 count = 0, i;
|
|
|
|
int32 prefIndex = -1;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
if(fFrontItem && fFrontItem->layerPtr->fLevel == B_NORMAL_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
// remove front window's floating(_SUBSET_/_APP_) windows, if any.
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *listItem = fFrontItem->lowerItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
while(listItem && (listItem->layerPtr->fLevel == B_FLOATING_SUBSET_FEEL ||
|
|
|
|
listItem->layerPtr->fLevel == B_FLOATING_APP_FEEL))
|
|
|
|
{
|
|
|
|
// *carefully* remove the item from the list
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *item = listItem;
|
|
|
|
listItem = listItem->lowerItem;
|
|
|
|
RemoveItem(item);
|
|
|
|
}
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// If this is a MODAL_SUBSET window, search it's place in its MainWinBorder
|
|
|
|
// window subset, and then take all modals after it; then continue talking
|
|
|
|
// modal windoes *only*, from application's set.
|
|
|
|
// If it is a MODAL_APP only search an take windows in/from application's set
|
|
|
|
if(prefFeel == B_MODAL_SUBSET_WINDOW_FEEL)
|
|
|
|
{
|
2004-01-13 04:03:29 +03:00
|
|
|
prefIndex = preferred->MainWinBorder()->Window()->fWinFMWList.IndexOf(preferred);
|
|
|
|
count = preferred->MainWinBorder()->Window()->fWinFMWList.CountItems();
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
if(prefIndex >= 0)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
WinBorder *wb = NULL;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// add modal windows from its main window subset - windows that are
|
|
|
|
// positioned after 'preferred'.
|
2004-01-13 04:03:29 +03:00
|
|
|
FMWList *listPtr = &(preferred->MainWinBorder()->Window()->fWinFMWList);
|
2004-06-26 06:15:48 +04:00
|
|
|
for(i = prefIndex+1; i < count; i++)
|
|
|
|
{
|
|
|
|
// they *all* are modal windows.
|
2004-01-12 01:12:55 +03:00
|
|
|
wb = (WinBorder*)listPtr->ItemAt(i);
|
|
|
|
wb->SetMainWinBorder(preferred);
|
|
|
|
finalMWList.AddItem(wb);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// remove those windows(if in there), for correct re-insertion later.
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *ld = NULL;
|
|
|
|
if((ld = HasItem(wb)))
|
|
|
|
RemoveItem(ld);
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// add modal windows that are found in application's subset
|
2004-01-13 04:03:29 +03:00
|
|
|
count = preferred->Window()->App()->fAppFMWList.CountItems();
|
|
|
|
listPtr = &(preferred->Window()->App()->fAppFMWList);
|
2004-06-26 06:15:48 +04:00
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
wb = (WinBorder*)listPtr->ItemAt(i);
|
2004-06-26 06:15:48 +04:00
|
|
|
if(wb->Window()->Feel() == B_MODAL_APP_WINDOW_FEEL)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
finalMWList.AddItem(wb);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// remove those windows(if in there), for correct re-insertion later.
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *ld = NULL;
|
|
|
|
if((ld = HasItem(wb)))
|
|
|
|
RemoveItem(ld);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
if(prefFeel == B_MODAL_APP_WINDOW_FEEL)
|
|
|
|
{
|
2004-01-13 04:03:29 +03:00
|
|
|
prefIndex = preferred->Window()->App()->fAppFMWList.IndexOf(preferred);
|
|
|
|
count = preferred->Window()->App()->fAppFMWList.CountItems();
|
2004-06-26 06:15:48 +04:00
|
|
|
if(prefIndex >= 0)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
WinBorder *wb = NULL;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// add modal windows from application's subset - windows that are
|
|
|
|
// positioned after 'preferred'.
|
2004-01-13 04:03:29 +03:00
|
|
|
FMWList *listPtr = &(preferred->Window()->App()->fAppFMWList);
|
2004-06-26 06:15:48 +04:00
|
|
|
for(i = prefIndex+1; i < count; i++)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
wb = (WinBorder*)listPtr->ItemAt(i);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// they *all* are modal windows.
|
2004-01-12 01:12:55 +03:00
|
|
|
finalMWList.AddItem(wb);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// remove those windows(if in there), for correct re-insertion later.
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *ld = NULL;
|
|
|
|
if((ld = HasItem(wb)))
|
|
|
|
RemoveItem(ld);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// insert windows found in 'finalMWList' in Workspace's list, after "preferred"
|
2004-01-12 01:12:55 +03:00
|
|
|
count = finalMWList.CountItems();
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// this varable will help us designate the future front.
|
2004-01-12 01:12:55 +03:00
|
|
|
WinBorder *finalPreferred = preferred;
|
2004-06-26 06:15:48 +04:00
|
|
|
for(i=0; i<count; i++)
|
|
|
|
{
|
|
|
|
WinBorder *wb = (WinBorder*)finalMWList.ItemAt(i);
|
|
|
|
|
|
|
|
// wb is surely a modal so... ATM make it the front one.
|
2004-01-12 01:12:55 +03:00
|
|
|
if(!(wb->IsHidden()))
|
|
|
|
finalPreferred = wb;
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// insert item just after the last inserted one.
|
|
|
|
ListData *newItem = new ListData();
|
2004-01-12 01:12:55 +03:00
|
|
|
newItem->layerPtr = wb;
|
|
|
|
newItem->lowerItem = lastInserted->lowerItem;
|
|
|
|
newItem->upperItem = lastInserted;
|
2004-06-26 06:15:48 +04:00
|
|
|
if(lastInserted->lowerItem)
|
2004-01-12 01:12:55 +03:00
|
|
|
lastInserted->lowerItem->upperItem = newItem;
|
|
|
|
lastInserted->lowerItem = newItem;
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
if(lastInserted == fBottomItem)
|
2004-01-12 01:12:55 +03:00
|
|
|
fBottomItem = newItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
lastInserted = newItem;
|
|
|
|
}
|
|
|
|
preferred = finalPreferred;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
if(prefFeel == B_MODAL_ALL_WINDOW_FEEL ||
|
|
|
|
prefFeel == B_SYSTEM_FIRST)
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
STRACE((" MODAL ALL/SYSTEM FIRST Window '%s'\n", preferred? preferred->GetName(): "NULL"));
|
|
|
|
|
|
|
|
// remove all application's floating windows.
|
|
|
|
if(fFrontItem && fFrontItem->layerPtr->fLevel == B_NORMAL_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
|
|
|
ListData *listItem = fFrontItem->lowerItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
while(listItem && (listItem->layerPtr->fLevel == B_FLOATING_SUBSET_FEEL ||
|
|
|
|
listItem->layerPtr->fLevel == B_FLOATING_APP_FEEL))
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
// *carefully* remove the item from the list
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *item = listItem;
|
|
|
|
listItem = listItem->lowerItem;
|
|
|
|
RemoveItem(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else if(prefFeel == B_SYSTEM_LAST)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
; // Do Nothing.
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
// We ***should NOT*** reach this point!
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("SERVER: PANIC: \"%s\": What kind of window is this???\n", preferred? preferred->GetName(): "NULL"));
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
|
|
|
}
|
2004-01-13 04:03:29 +03:00
|
|
|
else
|
|
|
|
STRACE((" The window IS Hidden\n"));
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-01-16 19:09:36 +03:00
|
|
|
ListData *exFrontItem = fFrontItem;
|
|
|
|
ListData *newFrontItem = NULL;
|
2004-06-26 06:15:48 +04:00
|
|
|
if(preferred && fBottomItem)
|
|
|
|
{
|
2004-01-13 04:03:29 +03:00
|
|
|
int32 feel = fBottomItem->layerPtr->Window()->Feel();
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// if preferred is one of these *don't* give front state to it!
|
2004-06-11 22:21:57 +04:00
|
|
|
if(preferred->fLevel == B_FLOATING_SUBSET_FEEL
|
|
|
|
|| preferred->fLevel == B_FLOATING_APP_FEEL
|
|
|
|
|| preferred->fLevel == B_FLOATING_ALL_FEEL)
|
2004-01-16 19:09:36 +03:00
|
|
|
{
|
|
|
|
newFrontItem = exFrontItem;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
if((feel == B_SYSTEM_FIRST || feel == B_MODAL_ALL_WINDOW_FEEL)
|
2004-01-13 04:03:29 +03:00
|
|
|
&& !(fBottomItem->layerPtr->IsHidden()) )
|
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
// if the last in workspace's list is one of these, GIVE focus to it!
|
|
|
|
|
2004-01-13 04:03:29 +03:00
|
|
|
newFrontItem = fBottomItem;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
if(preferred->fLevel == B_SYSTEM_LAST && !(preferred->IsHidden()) )
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
// the SYSTEM_LAST will get the front status, only if it's the only
|
|
|
|
// WinBorder in this workspace.
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
if(fBottomItem->layerPtr == preferred)
|
2004-01-13 04:03:29 +03:00
|
|
|
newFrontItem = HasItem(preferred);
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
if( !(preferred->IsHidden()) )
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
// this is in case of MODAL[APP/SUBSET] and NORMAL windows
|
2004-01-13 04:03:29 +03:00
|
|
|
newFrontItem = HasItem(preferred);
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
{
|
2004-01-13 04:03:29 +03:00
|
|
|
newFrontItem = NULL;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
newFrontItem = NULL;
|
|
|
|
}
|
2004-01-13 04:03:29 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
if(fFrontItem != newFrontItem)
|
|
|
|
{
|
2004-01-13 04:03:29 +03:00
|
|
|
fFrontItem = newFrontItem;
|
2004-08-29 19:01:44 +04:00
|
|
|
|
|
|
|
// TODO: call a method something like WinBorder::MakeFront(true);
|
2004-01-13 04:03:29 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
STRACE(("#WS(%ld)::SASNF(%s) ENDED! Workspace data...", ID(), preferred? preferred->GetName(): "NULL"));
|
|
|
|
STRACESTREAM();
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-01-13 04:03:29 +03:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2004-06-26 06:15:48 +04:00
|
|
|
/*
|
|
|
|
This method performs a simple opperation. It searched the new focus window
|
|
|
|
by walking from front to back, cheking for some things, until all variables
|
|
|
|
correspond.
|
|
|
|
*/
|
|
|
|
void Workspace::SearchAndSetNewFocus(WinBorder *preferred)
|
|
|
|
{
|
|
|
|
STRACE(("*WS(%ld)::SASNFocus(%s)\n", ID(), preferred? preferred->GetName(): "NULL"));
|
|
|
|
|
2004-01-13 04:03:29 +03:00
|
|
|
if(!preferred)
|
|
|
|
preferred = fBottomItem? fBottomItem->layerPtr : NULL;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-01-13 04:03:29 +03:00
|
|
|
bool selectOthers = false;
|
2004-11-06 19:54:05 +03:00
|
|
|
ListData *item=NULL;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
for(item = fBottomItem; item != NULL; item = item->upperItem)
|
|
|
|
{
|
|
|
|
// if this WinBorder doesn't want to have focus... get to the next one
|
|
|
|
if(item->layerPtr->Window()->Flags() & B_AVOID_FOCUS)
|
2004-01-12 01:12:55 +03:00
|
|
|
continue;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
if(preferred && item->layerPtr == preferred)
|
|
|
|
{
|
|
|
|
// our preffered one is hidden so... select another one
|
|
|
|
if(preferred && preferred->IsHidden())
|
|
|
|
{
|
2004-01-13 04:03:29 +03:00
|
|
|
selectOthers = true;
|
|
|
|
continue;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
{
|
2004-01-13 04:03:29 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-01-14 03:26:15 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
if(item->layerPtr->fLevel == B_SYSTEM_FIRST || item->layerPtr->fLevel == B_MODAL_ALL_FEEL)
|
2004-01-14 03:26:15 +03:00
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
break;
|
2004-01-14 03:26:15 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
if(item->layerPtr->fLevel == B_MODAL_APP_FEEL
|
2004-01-14 03:26:15 +03:00
|
|
|
&& (preferred && preferred->Window()->ClientTeamID() == item->layerPtr->Window()->ClientTeamID()))
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
if(item->layerPtr->fLevel == B_MODAL_SUBSET_FEEL
|
2004-01-14 03:26:15 +03:00
|
|
|
&& (preferred && item->layerPtr->MainWinBorder() == preferred))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// select one window, other than a system_last one!
|
|
|
|
if(selectOthers && item->layerPtr->fLevel != B_SYSTEM_LAST)
|
|
|
|
{
|
2004-01-14 03:26:15 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// there are no windows below us to select. take the one from above us.
|
|
|
|
if(selectOthers && !item)
|
|
|
|
{
|
|
|
|
// there HAS to be valid
|
2004-01-13 04:03:29 +03:00
|
|
|
item = HasItem(preferred);
|
2004-06-26 06:15:48 +04:00
|
|
|
if(item)
|
2004-01-13 04:03:29 +03:00
|
|
|
item= item->lowerItem;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// there are NO windows in front of us, and no regular window below us
|
|
|
|
// maybe there is a system_last window...
|
|
|
|
if(!item)
|
2004-01-13 04:03:29 +03:00
|
|
|
item = fTopItem;
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
if(item != fFocusItem)
|
|
|
|
{
|
2004-11-06 19:54:05 +03:00
|
|
|
if(fFocusItem)
|
|
|
|
{
|
|
|
|
ListData *oldItem=fFocusItem;
|
|
|
|
|
|
|
|
oldItem->layerPtr->HighlightDecorator(false);
|
|
|
|
|
|
|
|
BMessage inactive(B_WINDOW_ACTIVATED);
|
|
|
|
inactive.AddInt64("when",system_time());
|
|
|
|
inactive.AddBool("active",false);
|
|
|
|
oldItem->layerPtr->Window()->SendMessageToClient(&inactive);
|
|
|
|
}
|
|
|
|
|
|
|
|
fFocusItem=item;
|
|
|
|
|
|
|
|
if(fFocusItem)
|
|
|
|
{
|
|
|
|
fFocusItem->layerPtr->HighlightDecorator(true);
|
|
|
|
|
|
|
|
BMessage active(B_WINDOW_ACTIVATED);
|
|
|
|
active.AddInt64("when",system_time());
|
|
|
|
active.AddBool("active",true);
|
|
|
|
|
|
|
|
fFocusItem->layerPtr->Window()->SendMessageToClient(&active);
|
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
void Workspace::BringToFrontANormalWindow(WinBorder *layer)
|
|
|
|
{
|
|
|
|
switch (layer->Window()->Feel())
|
|
|
|
{
|
2004-01-17 19:33:22 +03:00
|
|
|
case B_FLOATING_SUBSET_WINDOW_FEEL:
|
2004-06-26 06:15:48 +04:00
|
|
|
case B_MODAL_SUBSET_WINDOW_FEEL:
|
|
|
|
{
|
2004-01-17 19:33:22 +03:00
|
|
|
SearchAndSetNewFront(layer->MainWinBorder());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_FLOATING_APP_WINDOW_FEEL:
|
2004-06-26 06:15:48 +04:00
|
|
|
case B_MODAL_APP_WINDOW_FEEL:
|
|
|
|
{
|
2004-01-17 19:33:22 +03:00
|
|
|
ListData *item = fBottomItem;
|
|
|
|
team_id tid = layer->Window()->ClientTeamID();
|
2004-06-26 06:15:48 +04:00
|
|
|
while(item)
|
|
|
|
{
|
2004-01-17 19:33:22 +03:00
|
|
|
if(item->layerPtr->Window()->ClientTeamID() == tid
|
|
|
|
&& item->layerPtr->Window()->Feel() == B_NORMAL_WINDOW_FEEL)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
item = item->upperItem;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
if(item)
|
2004-01-17 19:33:22 +03:00
|
|
|
SearchAndSetNewFront(item->layerPtr);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-01-17 19:33:22 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
default:
|
|
|
|
{
|
2004-01-17 19:33:22 +03:00
|
|
|
// in case of MODAL/FLOATING_ALL or _NORMAL_ or SYSTEM_FIRST/LAST do nothing!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// This method moves a window to the back of its subset.
|
|
|
|
void Workspace::MoveToBack(WinBorder *newLast)
|
|
|
|
{
|
|
|
|
STRACE(("\n!MoveToBack(%s) -", newLast? newLast->GetName(): "NULL"));
|
|
|
|
|
|
|
|
// does the list have this element?
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *item = HasItem(newLast);
|
2004-06-26 06:15:48 +04:00
|
|
|
if(item)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *listItem = NULL;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
switch(item->layerPtr->fLevel)
|
|
|
|
{
|
|
|
|
case B_FLOATING_ALL_FEEL:
|
|
|
|
{
|
|
|
|
STRACE((" B_FLOATING_ALL_FEEL window\n"));
|
|
|
|
|
|
|
|
// search the place where we should insert it later
|
2004-01-12 01:12:55 +03:00
|
|
|
listItem = item->upperItem;
|
2004-06-11 22:21:57 +04:00
|
|
|
while(listItem && (listItem->layerPtr->fLevel == item->layerPtr->fLevel))
|
2004-01-12 01:12:55 +03:00
|
|
|
listItem = listItem->upperItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// those 2 flags form a 'virtual' set, so even if FLOATING_APP
|
|
|
|
// has a greater priority than FLOATING_SUBSET, it is still moved
|
|
|
|
// behind FLOATING_SUBSET.
|
2004-01-12 01:12:55 +03:00
|
|
|
case B_FLOATING_SUBSET_FEEL:
|
2004-06-26 06:15:48 +04:00
|
|
|
case B_FLOATING_APP_FEEL:
|
|
|
|
{
|
|
|
|
STRACE((" B_FLOATING_SUBSET_FEEL/B_FLOATING_APP_FEEL window\n"));
|
|
|
|
|
|
|
|
// search the place where we should insert it later
|
2004-01-12 01:12:55 +03:00
|
|
|
listItem = item->upperItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
while(listItem && (listItem->layerPtr->fLevel == B_FLOATING_SUBSET_FEEL ||
|
|
|
|
listItem->layerPtr->fLevel == B_FLOATING_APP_FEEL))
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
listItem = listItem->upperItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// the same like with floating window. Those 2 and NORMAL form a'virtual' set.
|
2004-01-12 01:12:55 +03:00
|
|
|
case B_MODAL_SUBSET_FEEL:
|
2004-06-26 06:15:48 +04:00
|
|
|
case B_MODAL_APP_FEEL:
|
|
|
|
{
|
|
|
|
STRACE((" B_MODAL_SUBSET_FEEL/B_MODAL_APP_FEEL window\n"));
|
|
|
|
|
|
|
|
// search the place where we should insert it later
|
2004-01-12 01:12:55 +03:00
|
|
|
listItem = item->upperItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
while(listItem && (listItem->layerPtr->fLevel == B_MODAL_SUBSET_FEEL ||
|
|
|
|
listItem->layerPtr->fLevel == B_MODAL_APP_FEEL ||
|
|
|
|
listItem->layerPtr->fLevel == B_NORMAL_FEEL))
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
listItem = listItem->upperItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// here is the simplest, we use the priority levels.
|
|
|
|
case B_NORMAL_FEEL:
|
|
|
|
{
|
|
|
|
STRACE((" B_NORMAL_FEEL window\n"));
|
2004-01-12 01:12:55 +03:00
|
|
|
listItem = item->upperItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
while(listItem && (listItem->layerPtr->fLevel >= item->layerPtr->fLevel))
|
2004-01-12 01:12:55 +03:00
|
|
|
listItem = listItem->upperItem;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
if((listItem && item->lowerItem == listItem->lowerItem)
|
2004-01-12 01:12:55 +03:00
|
|
|
|| (listItem == NULL && item == fTopItem))
|
|
|
|
{
|
|
|
|
// do nothing! The window will be in the same position it is now.
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// if it's a normal window, first remove any floating windows,
|
|
|
|
// it or its application has
|
|
|
|
if(newLast->fLevel == B_NORMAL_FEEL && fFrontItem->layerPtr == newLast)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *iter = item->lowerItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
while(iter && (iter->layerPtr->fLevel == B_FLOATING_SUBSET_FEEL ||
|
|
|
|
iter->layerPtr->fLevel == B_FLOATING_APP_FEEL))
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
// *carefully* remove the item from the list
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *itemX = iter;
|
|
|
|
iter = iter->lowerItem;
|
|
|
|
RemoveItem(itemX);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
WinBorder *nextPreferred = item->upperItem? item->upperItem->layerPtr: NULL;
|
|
|
|
bool wasFront = fFrontItem->layerPtr == newLast;
|
|
|
|
bool wasFocus = fFocusItem->layerPtr == newLast;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// remove item
|
2004-01-12 01:12:55 +03:00
|
|
|
RemoveItem(item);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
// insert in the new, right' position.
|
2004-01-12 01:12:55 +03:00
|
|
|
InsertItem(item, listItem? listItem->lowerItem: fTopItem);
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
if(wasFront)
|
2004-01-12 01:12:55 +03:00
|
|
|
SearchAndSetNewFront(nextPreferred);
|
2004-06-26 06:15:48 +04:00
|
|
|
if(wasFocus)
|
2004-01-12 01:12:55 +03:00
|
|
|
SearchAndSetNewFocus(nextPreferred);
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
STRACESTREAM();
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
STRACE((" this operation was not needed\n"));
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
void Workspace::SetLocalSpace(const uint32 colorspace)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
fSpace = colorspace;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
uint32 Workspace::LocalSpace() const
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fSpace;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
void Workspace::SetBGColor(const RGBColor &c)
|
|
|
|
{
|
|
|
|
fBGColor = c;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
RGBColor Workspace::BGColor(void) const
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fBGColor;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2004-06-26 06:15:48 +04:00
|
|
|
/*!
|
|
|
|
\brief Retrieves settings from a container message passed to PutSettings
|
|
|
|
\param A BMessage containing data from a PutSettings() call
|
|
|
|
|
|
|
|
This function will place default values whenever a particular setting cannot
|
|
|
|
be found.
|
|
|
|
*/
|
|
|
|
void Workspace::GetSettings(const BMessage &msg)
|
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement GetSettings
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2004-06-26 06:15:48 +04:00
|
|
|
//! Sets workspace settings to defaults
|
|
|
|
void Workspace::GetDefaultSettings(void)
|
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement GetDefaultSettings
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2004-06-26 06:15:48 +04:00
|
|
|
/*!
|
|
|
|
\brief Places the screen settings for the workspace in the passed BMessage
|
|
|
|
\param msg BMessage pointer to receive the settings
|
|
|
|
\param index The index number of the workspace in the desktop
|
|
|
|
|
|
|
|
This function will fail if passed a NULL pointer. The settings for the workspace are
|
|
|
|
saved in a BMessage
|
|
|
|
|
|
|
|
The format is as follows:
|
|
|
|
int32 "index" -> workspace index
|
|
|
|
display_timing "display_timing" -> fDisplayTiming (see Accelerant.h)
|
|
|
|
uint32 "color_space" -> color space of the workspace
|
|
|
|
rgb_color "bgcolor" -> background color of the workspace
|
|
|
|
int16 "virtual_width" -> virtual width of the workspace
|
|
|
|
int16 "virtual_height" -> virtual height of the workspace
|
|
|
|
int32 "flags" -> workspace flags
|
|
|
|
*/
|
|
|
|
void Workspace::PutSettings(BMessage *msg, const int32 &index) const
|
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement PutSettings
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2004-06-26 06:15:48 +04:00
|
|
|
/*!
|
|
|
|
\brief Places default settings for the workspace in the passed BMessage
|
|
|
|
\param msg BMessage pointer to receive the settings
|
|
|
|
\param index The index number of the workspace in the desktop
|
|
|
|
*/
|
|
|
|
void Workspace::PutDefaultSettings(BMessage *msg, const int32 &index)
|
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement PutDefaultSettings
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Debug method
|
2004-06-26 06:15:48 +04:00
|
|
|
void Workspace::PrintToStream() const
|
|
|
|
{
|
2004-01-13 04:03:29 +03:00
|
|
|
printf("\nWorkspace %ld hierarchy shown from back to front:\n", fID);
|
2004-06-26 06:15:48 +04:00
|
|
|
for (ListData *item = fTopItem; item != NULL; item = item->lowerItem)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
WinBorder *wb = (WinBorder*)item->layerPtr;
|
|
|
|
printf("\tName: %s\t%s", wb->GetName(), wb->IsHidden()?"Hidden\t": "NOT Hidden");
|
2004-06-26 06:15:48 +04:00
|
|
|
if(wb->Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_FLOATING_SUBSET_WINDOW_FEEL");
|
2004-06-26 06:15:48 +04:00
|
|
|
if(wb->Window()->Feel() == B_FLOATING_APP_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_FLOATING_APP_WINDOW_FEEL");
|
2004-06-26 06:15:48 +04:00
|
|
|
if(wb->Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_FLOATING_ALL_WINDOW_FEEL");
|
2004-06-26 06:15:48 +04:00
|
|
|
if(wb->Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_MODAL_SUBSET_WINDOW_FEEL");
|
2004-06-26 06:15:48 +04:00
|
|
|
if(wb->Window()->Feel() == B_MODAL_APP_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_MODAL_APP_WINDOW_FEEL");
|
2004-06-26 06:15:48 +04:00
|
|
|
if(wb->Window()->Feel() == B_MODAL_ALL_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_MODAL_ALL_WINDOW_FEEL");
|
2004-06-26 06:15:48 +04:00
|
|
|
if(wb->Window()->Feel() == B_NORMAL_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_NORMAL_WINDOW_FEEL");
|
2004-06-26 06:15:48 +04:00
|
|
|
if(wb->Window()->Feel() == B_SYSTEM_LAST)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_SYSTEM_LAST");
|
2004-06-26 06:15:48 +04:00
|
|
|
if(wb->Window()->Feel() == B_SYSTEM_FIRST)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_SYSTEM_FIRST");
|
|
|
|
}
|
|
|
|
printf("Focus Layer:\t%s\n", fFocusItem? fFocusItem->layerPtr->GetName(): "NULL");
|
|
|
|
printf("Front Layer:\t%s\n", fFrontItem? fFrontItem->layerPtr->GetName(): "NULL");
|
|
|
|
// printf("Current Layer:\t%s\n", fCurrentItem? fCurrentItem->layerPtr->GetName(): "NULL");
|
|
|
|
// printf("Top Layer:\t%s\n", fTopItem? fTopItem->layerPtr->GetName(): "NULL");
|
|
|
|
// printf("Bottom Layer:\t%s\n", fBottomItem? fBottomItem->layerPtr->GetName(): "NULL");
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Debug method
|
2004-06-26 06:15:48 +04:00
|
|
|
void Workspace::PrintItem(ListData *item) const
|
|
|
|
{
|
2004-01-13 04:03:29 +03:00
|
|
|
printf("ListData members:\n");
|
2004-06-26 06:15:48 +04:00
|
|
|
if(item)
|
|
|
|
{
|
2004-01-13 04:03:29 +03:00
|
|
|
printf("WinBorder:\t%s\n", item->layerPtr? item->layerPtr->GetName(): "NULL");
|
|
|
|
printf("UpperItem:\t%s\n", item->upperItem? item->upperItem->layerPtr->GetName(): "NULL");
|
|
|
|
printf("LowerItem:\t%s\n", item->lowerItem? item->lowerItem->layerPtr->GetName(): "NULL");
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("NULL item\n");
|
2004-01-13 04:03:29 +03:00
|
|
|
}
|
|
|
|
}
|
2004-07-10 14:54:20 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// PRIVATE
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Workspace::InsertItem(ListData *item, ListData *before)
|
|
|
|
{
|
|
|
|
// insert before one other item;
|
|
|
|
if(before)
|
|
|
|
{
|
|
|
|
if(before->upperItem)
|
|
|
|
before->upperItem->lowerItem = item;
|
|
|
|
item->upperItem = before->upperItem;
|
|
|
|
before->upperItem = item;
|
|
|
|
item->lowerItem = before;
|
|
|
|
|
|
|
|
// if we're inserting at top of the stack, change it accordingly.
|
|
|
|
if(fTopItem == before)
|
|
|
|
fTopItem = item;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// insert item at bottom.
|
|
|
|
item->upperItem = fBottomItem;
|
|
|
|
if(fBottomItem)
|
|
|
|
fBottomItem->lowerItem = item;
|
|
|
|
|
|
|
|
fBottomItem = item;
|
|
|
|
|
|
|
|
if(!fTopItem)
|
|
|
|
fTopItem = item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Workspace::RemoveItem(ListData *item)
|
|
|
|
{
|
|
|
|
if(!item)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(fBottomItem == item)
|
|
|
|
fBottomItem = item->upperItem;
|
|
|
|
else
|
|
|
|
item->lowerItem->upperItem = item->upperItem;
|
|
|
|
|
|
|
|
if(fTopItem == item)
|
|
|
|
fTopItem = item->lowerItem;
|
|
|
|
else
|
|
|
|
item->upperItem->lowerItem = item->lowerItem;
|
|
|
|
|
|
|
|
// set all these to NULL to avoid confusion later.
|
|
|
|
|
|
|
|
item->upperItem = NULL;
|
|
|
|
item->lowerItem = NULL;
|
|
|
|
|
|
|
|
if(fFocusItem == item)
|
|
|
|
{
|
|
|
|
fFocusItem->layerPtr->HighlightDecorator(false);
|
|
|
|
fFocusItem = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(fFrontItem == item)
|
|
|
|
fFrontItem = NULL;
|
|
|
|
|
|
|
|
if(fCurrentItem == item)
|
|
|
|
fCurrentItem = NULL;
|
|
|
|
}
|
|
|
|
|
2004-09-21 02:50:02 +04:00
|
|
|
//----------------------------------------------------------------------------------
|