new desktop management code

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6059 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca
2004-01-13 01:03:29 +00:00
parent c2d66a0f49
commit 037eadad77
3 changed files with 299 additions and 192 deletions
+33 -53
View File
@@ -1,91 +1,75 @@
#include <stdio.h> #include <stdio.h>
#include <List.h>
#include "FMWList.h" #include "FMWList.h"
#include "WinBorder.h" #include "WinBorder.h"
#include "ServerWindow.h" #include "ServerWindow.h"
FMWList::FMWList() FMWList::FMWList(){
{
} }
FMWList::~FMWList() FMWList::~FMWList(){
{
//printf("~FMWList()\n"); //printf("~FMWList()\n");
// if (fList.CountItems() > 0) // if (fList.CountItems() > 0)
// printf("SERVER: WARNING: FMWList NOT empty in destructor!\n"); // printf("SERVER: WARNING: FMWList NOT empty in destructor!\n");
} }
void FMWList::AddItem(void* item) void FMWList::AddItem(void* item){
{ int32 feelItem = ((WinBorder*)item)->Window()->Feel();;
int32 feelItem = ((WinBorder*)item)->Window()->GetFeel();
int32 feelTemp = 0; int32 feelTemp = 0;
int32 location = 0; int32 location = 0;
for(int32 i=0; i<fList.CountItems(); i++) for(int32 i=0; i<fList.CountItems(); i++){
{
location = i + 1; location = i + 1;
feelTemp = ((WinBorder*)fList.ItemAt(i))->Window()->GetFeel(); feelTemp = ((WinBorder*)fList.ItemAt(i))->Window()->Feel();
// in short: if 'item' is a floating window
// in short: if 'item' is a floating window and 'temp' is a modal one, then
// we have found the place for our window('wb')
if( (feelItem == B_FLOATING_SUBSET_WINDOW_FEEL || if( (feelItem == B_FLOATING_SUBSET_WINDOW_FEEL ||
feelItem == B_FLOATING_APP_WINDOW_FEEL || feelItem == B_FLOATING_APP_WINDOW_FEEL ||
feelItem == B_FLOATING_ALL_WINDOW_FEEL) feelItem == B_FLOATING_ALL_WINDOW_FEEL)
&& && // and 'temp' a modal one
(feelTemp == B_MODAL_SUBSET_WINDOW_FEEL || (feelTemp == B_MODAL_SUBSET_WINDOW_FEEL ||
feelTemp == B_MODAL_APP_WINDOW_FEEL || feelTemp == B_MODAL_APP_WINDOW_FEEL ||
feelTemp == B_MODAL_ALL_WINDOW_FEEL) feelTemp == B_MODAL_ALL_WINDOW_FEEL)
) )
{ // means we found the place for our window('wb')
location--; { location--; break; }
break;
}
} }
fList.AddItem(item, location); fList.AddItem(item, location);
} }
bool FMWList::HasItem(void* item) const bool FMWList::HasItem(void* item) const{
{
return fList.HasItem(item); return fList.HasItem(item);
} }
bool FMWList::RemoveItem(void* item) bool FMWList::RemoveItem(void* item){
{
return fList.RemoveItem(item); return fList.RemoveItem(item);
} }
void* FMWList::ItemAt(int32 i) const void* FMWList::ItemAt(int32 i) const{
{
return fList.ItemAt(i); return fList.ItemAt(i);
} }
int32 FMWList::CountItems() const int32 FMWList::CountItems() const{
{
return fList.CountItems(); return fList.CountItems();
} }
void* FMWList::LastItem() const void* FMWList::LastItem() const{
{
return fList.LastItem(); return fList.LastItem();
} }
void* FMWList::FirstItem() const void* FMWList::FirstItem() const{
{
return fList.FirstItem(); return fList.FirstItem();
} }
int32 FMWList::IndexOf(void *item) int32 FMWList::IndexOf(void *item){
{
return fList.IndexOf(item); return fList.IndexOf(item);
} }
void FMWList::AddFMWList(FMWList *list) void FMWList::AddFMWList(FMWList *list){
{
int32 i = 0; int32 i = 0;
for(i=0; i<fList.CountItems(); i++) for(i=0; i<fList.CountItems(); i++){
{ int32 feel = ((WinBorder*)fList.ItemAt(i))->Window()->Feel();
int32 feel = ((WinBorder*)fList.ItemAt(i))->Window()->GetFeel();
if(feel == B_MODAL_SUBSET_WINDOW_FEEL || if(feel == B_MODAL_SUBSET_WINDOW_FEEL ||
feel == B_MODAL_APP_WINDOW_FEEL || feel == B_MODAL_APP_WINDOW_FEEL ||
feel == B_MODAL_ALL_WINDOW_FEEL) feel == B_MODAL_ALL_WINDOW_FEEL)
@@ -95,47 +79,43 @@ void FMWList::AddFMWList(FMWList *list)
} }
int32 j = 0; int32 j = 0;
for(j=0; j<list->CountItems(); j++) for(j=0; j<list->CountItems(); j++){
{
void *item = list->ItemAt(j); void *item = list->ItemAt(j);
int32 feel = ((WinBorder*)item)->Window()->GetFeel(); int32 feel = ((WinBorder*)item)->Window()->Feel();
if(feel == B_MODAL_SUBSET_WINDOW_FEEL || if(feel == B_MODAL_SUBSET_WINDOW_FEEL ||
feel == B_MODAL_APP_WINDOW_FEEL || feel == B_MODAL_APP_WINDOW_FEEL ||
feel == B_MODAL_ALL_WINDOW_FEEL) feel == B_MODAL_ALL_WINDOW_FEEL)
{ {
fList.AddItem(item, fList.CountItems()); fList.AddItem(item, fList.CountItems());
} }
else else{
{
fList.AddItem(item, i); fList.AddItem(item, i);
i++; i++;
} }
} }
} }
void FMWList::PrintToStream() const void FMWList::PrintToStream() const{
{
printf("Floating and modal windows list:\n"); printf("Floating and modal windows list:\n");
WinBorder *wb = NULL; WinBorder *wb = NULL;
for (int32 i=0; i<fList.CountItems(); i++) for (int32 i=0; i<fList.CountItems(); i++){
{
wb = (WinBorder*)fList.ItemAt(i); wb = (WinBorder*)fList.ItemAt(i);
printf("\t%s", wb->GetName()); printf("\t%s", wb->GetName());
if (wb->Window()->GetFeel() == B_FLOATING_SUBSET_WINDOW_FEEL) if (wb->Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL)
printf("\t%s\n", "B_FLOATING_SUBSET_WINDOW_FEEL"); printf("\t%s\n", "B_FLOATING_SUBSET_WINDOW_FEEL");
if (wb->Window()->GetFeel() == B_FLOATING_APP_WINDOW_FEEL) if (wb->Window()->Feel() == B_FLOATING_APP_WINDOW_FEEL)
printf("\t%s\n", "B_FLOATING_APP_WINDOW_FEEL"); printf("\t%s\n", "B_FLOATING_APP_WINDOW_FEEL");
if (wb->Window()->GetFeel() == B_FLOATING_ALL_WINDOW_FEEL) if (wb->Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL)
printf("\t%s\n", "B_FLOATING_ALL_WINDOW_FEEL"); printf("\t%s\n", "B_FLOATING_ALL_WINDOW_FEEL");
if (wb->Window()->GetFeel() == B_MODAL_SUBSET_WINDOW_FEEL) if (wb->Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL)
printf("\t%s\n", "B_MODAL_SUBSET_WINDOW_FEEL"); printf("\t%s\n", "B_MODAL_SUBSET_WINDOW_FEEL");
if (wb->Window()->GetFeel() == B_MODAL_APP_WINDOW_FEEL) if (wb->Window()->Feel() == B_MODAL_APP_WINDOW_FEEL)
printf("\t%s\n", "B_MODAL_APP_WINDOW_FEEL"); printf("\t%s\n", "B_MODAL_APP_WINDOW_FEEL");
if (wb->Window()->GetFeel() == B_MODAL_ALL_WINDOW_FEEL) if (wb->Window()->Feel() == B_MODAL_ALL_WINDOW_FEEL)
printf("\t%s\n", "B_MODAL_ALL_WINDOW_FEEL"); printf("\t%s\n", "B_MODAL_ALL_WINDOW_FEEL");
// this should NOT happen // this should NOT happen
if (wb->Window()->GetFeel() == B_NORMAL_WINDOW_FEEL) if (wb->Window()->Feel() == B_NORMAL_WINDOW_FEEL)
printf("\t%s\n", "B_NORMAL_WINDOW_FEEL"); printf("\t%s\n", "B_NORMAL_WINDOW_FEEL");
} }
} }
+253 -136
View File
@@ -1,18 +1,18 @@
#include <stdio.h> #include <stdio.h>
#include <Window.h> #include <Window.h>
#include "ServerApp.h"
#include "Workspace.h" #include "Workspace.h"
#include "Layer.h" #include "Layer.h"
#include "WinBorder.h" #include "WinBorder.h"
#include "ServerWindow.h" #include "ServerWindow.h"
#include "ServerApp.h"
#include "RGBColor.h" #include "RGBColor.h"
#include "Globals.h" #include "Globals.h"
#include "FMWList.h" #include "FMWList.h"
#include "RootLayer.h" #include "RootLayer.h"
#include "Desktop.h" #include "Desktop.h"
//#define DEBUG_WORKSPACE #define DEBUG_WORKSPACE
#ifdef DEBUG_WORKSPACE #ifdef DEBUG_WORKSPACE
# include <stdio.h> # include <stdio.h>
@@ -29,10 +29,12 @@
#endif #endif
Workspace::Workspace(const uint32 colorspace, int32 ID, const RGBColor& BGColor){ Workspace::Workspace(const uint32 colorspace, int32 ID, const RGBColor& BGColor, RootLayer* owner){
fID = ID; fID = ID;
fSpace = colorspace; fSpace = colorspace;
fBGColor = BGColor; fBGColor = BGColor;
fOwner = owner;
fBottomItem = NULL; fBottomItem = NULL;
fTopItem = NULL; fTopItem = NULL;
@@ -61,7 +63,7 @@ Workspace::~Workspace(){
* a *smart* search is performed to set the new front WinBorder. Of course, * 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 * 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. * B_AVOID_FRONT flag, surely it won't get that status.
* This method also calls SearchAndSerNewFocus witch searches for a WinBorder, * This method also calls SearchAndSetNewFocus witch searches for a WinBorder,
* to give focus to, having as preferred 'layer'. * to give focus to, having as preferred 'layer'.
* Remember, some windows having B_AVOID_FOCUS can't have the focus state. * Remember, some windows having B_AVOID_FOCUS can't have the focus state.
*/ */
@@ -77,13 +79,13 @@ bool Workspace::AddLayerPtr(WinBorder* layer){
// insert 'item' at the end. It doesn't matter where we add it, // insert 'item' at the end. It doesn't matter where we add it,
// it will be placed correctly by SearchAndSetNewFront(item->layerPtr); // it will be placed correctly by SearchAndSetNewFront(item->layerPtr);
InsertItem(item, NULL); InsertItem(item, NULL);
STRACE(("\n*AddLayerPtr(%s) -", layer->GetName())); STRACE(("\n*AddLayerPtr(%s) -", layer->GetName()));
// do a *smart* search and set the new 'front' // do a *smart* search and set the new 'front'
SearchAndSetNewFront(layer); SearchAndSetNewFront(layer);
// do a *smart* search and set the new 'focus' // do a *smart* search and set the new 'focus'
SearchAndSetNewFocus(layer); SearchAndSetNewFocus(layer);
//STRACESTREAM();
STRACESTREAM();
return true; return true;
} }
/* Removes a WinBorder from workspace's list. It DOES NOT delete it! /* Removes a WinBorder from workspace's list. It DOES NOT delete it!
@@ -94,8 +96,9 @@ STRACESTREAM();
bool Workspace::RemoveLayerPtr(WinBorder* layer){ bool Workspace::RemoveLayerPtr(WinBorder* layer){
if (!layer) if (!layer)
return false; return false;
STRACE(("\n#RemoveLayerPtr(%s)\n", layer->GetName())); 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 // search to see if this workspace has WinBorder's pointer in its list
ListData *item = NULL; ListData *item = NULL;
if ((item = HasItem(layer))){ if ((item = HasItem(layer))){
@@ -104,13 +107,13 @@ STRACE(("\n#RemoveLayerPtr(%s)\n", layer->GetName()));
// prepare to set new front/focus if this layer was front/focus // prepare to set new front/focus if this layer was front/focus
nextItem = item->upperItem; nextItem = item->upperItem;
wasFront = fFrontItem->layerPtr == layer; wasFront = fFrontItem? fFrontItem->layerPtr == layer: false;
wasFocus = fFrontItem->layerPtr == layer; wasFocus = fFocusItem? fFocusItem->layerPtr == layer: false;
// remove any floating window our window may have // remove any floating window our window may have
ListData *listItem = item->lowerItem; ListData *listItem = item->lowerItem;
while(listItem && (listItem->layerPtr->GetServerFeel() == B_FLOATING_SUBSET_FEEL while(listItem && (listItem->layerPtr->_level == B_FLOATING_SUBSET_FEEL
|| listItem->layerPtr->GetServerFeel() == B_FLOATING_APP_FEEL)) || listItem->layerPtr->_level == B_FLOATING_APP_FEEL))
{ // *carefully* remove the item from the list { // *carefully* remove the item from the list
ListData *itemX = listItem; ListData *itemX = listItem;
listItem = listItem->lowerItem; listItem = listItem->lowerItem;
@@ -123,36 +126,44 @@ STRACE(("\n#RemoveLayerPtr(%s)\n", layer->GetName()));
// reset some internal variables // reset some internal variables
layer->SetMainWinBorder(NULL); layer->SetMainWinBorder(NULL);
// its RootLayer is set to NULL by Layer::RemoveChild(layer); // its RootLayer is set to NULL by Layer::RemoveChild(layer);
STRACESTREAM(); printf("Layer %s found and removed from Workspace No %ld\n", layer->GetName(), ID());
if (wasFront) if (wasFront)
SearchAndSetNewFront(nextItem? nextItem->layerPtr: NULL); SearchAndSetNewFront(nextItem? nextItem->layerPtr: NULL);
if (wasFocus) if (wasFocus)
SearchAndSetNewFocus(nextItem? nextItem->layerPtr: NULL); SearchAndSetNewFocus(nextItem? nextItem->layerPtr: NULL);
STRACE(("AFTER opperations...\n"));
STRACESTREAM();
// delete item struct, we no longer need that // delete item struct, we no longer need that
delete item; delete item;
return true; return true;
} }
else else{
printf("Layer %s NOT found in Workspace No %ld\n", layer->GetName(), ID());
return false; return false;
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool Workspace::SetFocusLayer(WinBorder* layer){ WinBorder* Workspace::SetFocusLayer(WinBorder* layer){
SearchAndSetNewFocus(layer); SearchAndSetNewFocus(layer);
return true; return fFocusItem? fFocusItem->layerPtr : NULL;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
WinBorder* Workspace::FocusLayer() const{ WinBorder* Workspace::FocusLayer() const{
return fFocusItem ? fFocusItem->layerPtr : NULL; return fFocusItem ? fFocusItem->layerPtr : NULL;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool Workspace::SetFrontLayer(WinBorder* layer){ WinBorder* Workspace::SetFrontLayer(WinBorder* layer){
STRACE(("\n@SetFrontLayer( %s )\n", layer? layer->GetName(): "NULL")); STRACE(("\n@Workspace(%ld)::SetFrontLayer( %s )\n", ID(), layer? layer->GetName(): "NULL"));
SearchAndSetNewFront(layer); SearchAndSetNewFront(layer);
STRACESTREAM(); //TODO: *****!*!*!*!*!*!*!**!***REMOVE this! For Test purposes only!
return true; if(fOwner->ActiveWorkspace() == this)
fOwner->DoInvalidate(BRegion(fOwner->Bounds()), NULL);
//----------------
// TODO: if (desktop->FrontWinBorder() != layer) REBUILD & INVALIDATE!
return fFrontItem? fFrontItem->layerPtr: NULL;;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
WinBorder* Workspace::FrontLayer() const{ WinBorder* Workspace::FrontLayer() const{
@@ -204,6 +215,24 @@ bool Workspace::GoToItem(WinBorder* layer){
return false; return false;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
WinBorder* Workspace::SearchLayerUnderPoint(BPoint pt){
// TODO: implement correctly one you have clipping code working
// For the moment, take windows from front to back and see in witch one 'pt' falls
WinBorder *target = NULL;
opLock.Lock();
printf("Searching (%f,%f) in...\n", pt.x, pt.y);
for( WinBorder *wb = GoToBottomItem(); wb; wb = GoToUpperItem()){
wb->PrintToStream();
if (!wb->IsHidden() && wb->HasPoint(pt)){
printf("%s - SELECTED!\n", wb->GetName());
target = wb;
break;
}
}
opLock.Unlock();
return target;
}
//---------------------------------------------------------------------------
void Workspace::InsertItem(ListData* item, ListData* before){ void Workspace::InsertItem(ListData* item, ListData* before){
// insert before one other item; // insert before one other item;
if (before){ if (before){
@@ -299,8 +328,8 @@ ListData* Workspace::FindPlace(ListData* pref){
// search a window that is not hidden and does *not* have B_AVOID_FRONT flag. // search a window that is not hidden and does *not* have B_AVOID_FRONT flag.
item = pref; item = pref;
while(pref && item->lowerItem != pref){ while(pref && item->lowerItem != pref && (pref->upperItem || pref->lowerItem)){
if ( !(item->layerPtr->Window()->GetFlags() & B_AVOID_FRONT) && !(item->layerPtr->IsHidden()) ) if ( !(item->layerPtr->Window()->Flags() & B_AVOID_FRONT) && !(item->layerPtr->IsHidden()) )
break; break;
if (item == fTopItem) if (item == fTopItem)
@@ -308,7 +337,9 @@ ListData* Workspace::FindPlace(ListData* pref){
else else
item = item->upperItem; item = item->upperItem;
} }
// if true, it means we have windows with B_AVOID_FRONT flag *only*, so pick one.
// 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){ if (pref && item->lowerItem == pref){
for (item = fBottomItem; item; item = item->upperItem){ for (item = fBottomItem; item; item = item->upperItem){
if ( !(item->layerPtr->IsHidden()) ) if ( !(item->layerPtr->IsHidden()) )
@@ -328,11 +359,11 @@ ListData* Workspace::FindPlace(ListData* pref){
// we start searching its place // we start searching its place
ListData *cursor = fBottomItem; ListData *cursor = fBottomItem;
int32 feel = pref->layerPtr->Window()->GetFeel(); int32 feel = pref->layerPtr->Window()->Feel();
switch(feel){ switch(feel){
case B_NORMAL_WINDOW_FEEL:{ case B_NORMAL_WINDOW_FEEL:{
while(cursor && cursor->layerPtr->GetServerFeel() > B_MODAL_APP_FEEL){ while(cursor && cursor->layerPtr->_level > B_MODAL_APP_FEEL){
cursor = cursor->upperItem; cursor = cursor->upperItem;
} }
InsertItem(pref, cursor? cursor->lowerItem: NULL); InsertItem(pref, cursor? cursor->lowerItem: NULL);
@@ -340,7 +371,7 @@ ListData* Workspace::FindPlace(ListData* pref){
} }
case B_SYSTEM_LAST:{ case B_SYSTEM_LAST:{
while(cursor && cursor->layerPtr->GetServerFeel() > pref->layerPtr->GetServerFeel()){ while(cursor && cursor->layerPtr->_level > pref->layerPtr->_level){
cursor = cursor->upperItem; cursor = cursor->upperItem;
} }
InsertItem(pref, cursor? cursor->lowerItem: fTopItem); InsertItem(pref, cursor? cursor->lowerItem: fTopItem);
@@ -351,7 +382,7 @@ ListData* Workspace::FindPlace(ListData* pref){
case B_FLOATING_ALL_WINDOW_FEEL: case B_FLOATING_ALL_WINDOW_FEEL:
case B_MODAL_ALL_WINDOW_FEEL: case B_MODAL_ALL_WINDOW_FEEL:
case B_MODAL_APP_WINDOW_FEEL:{ case B_MODAL_APP_WINDOW_FEEL:{
while(cursor && cursor->layerPtr->GetServerFeel() > pref->layerPtr->GetServerFeel()){ while(cursor && cursor->layerPtr->_level > pref->layerPtr->_level){
cursor = cursor->upperItem; cursor = cursor->upperItem;
} }
InsertItem(pref, cursor? cursor->lowerItem: NULL); InsertItem(pref, cursor? cursor->lowerItem: NULL);
@@ -363,13 +394,13 @@ ListData* Workspace::FindPlace(ListData* pref){
// NOTE that this happens only if its main window is the front most one. // NOTE that this happens only if its main window is the front most one.
case B_FLOATING_SUBSET_WINDOW_FEEL:{ case B_FLOATING_SUBSET_WINDOW_FEEL:{
for(cursor = fBottomItem; cursor; cursor = cursor->upperItem){ for(cursor = fBottomItem; cursor; cursor = cursor->upperItem){
if (cursor->layerPtr->GetServerFeel() <= pref->layerPtr->GetServerFeel() if (cursor->layerPtr->_level <= pref->layerPtr->_level
&& (cursor->layerPtr == pref->layerPtr->MainWinBorder() && (cursor->layerPtr == pref->layerPtr->MainWinBorder()
|| cursor->layerPtr->MainWinBorder() == pref->layerPtr->MainWinBorder()) || cursor->layerPtr->MainWinBorder() == pref->layerPtr->MainWinBorder())
) )
{ break; } { break; }
else if(pref->layerPtr->GetServerFeel() == B_FLOATING_SUBSET_FEEL else if(pref->layerPtr->_level == B_FLOATING_SUBSET_FEEL
&& cursor->layerPtr->GetServerFeel() == B_FLOATING_APP_FEEL) && cursor->layerPtr->_level == B_FLOATING_APP_FEEL)
{ break; } { break; }
} }
if (cursor) if (cursor)
@@ -382,12 +413,12 @@ ListData* Workspace::FindPlace(ListData* pref){
// it belongs to another application // it belongs to another application
case B_MODAL_SUBSET_WINDOW_FEEL:{ case B_MODAL_SUBSET_WINDOW_FEEL:{
for(cursor = fBottomItem; cursor; cursor = cursor->upperItem){ for(cursor = fBottomItem; cursor; cursor = cursor->upperItem){
if (cursor->layerPtr->GetServerFeel() <= pref->layerPtr->GetServerFeel()) if (cursor->layerPtr->_level <= pref->layerPtr->_level)
break; break;
else if(pref->layerPtr->GetServerFeel() == B_MODAL_SUBSET_FEEL else if(pref->layerPtr->_level == B_MODAL_SUBSET_FEEL
&& cursor->layerPtr->GetServerFeel() == B_MODAL_APP_FEEL && cursor->layerPtr->_level == B_MODAL_APP_FEEL
&& pref->layerPtr->Window()->GetClientTeamID() && pref->layerPtr->Window()->ClientTeamID()
!= cursor->layerPtr->Window()->GetClientTeamID()) != cursor->layerPtr->Window()->ClientTeamID())
break; break;
} }
if (cursor) if (cursor)
@@ -399,9 +430,9 @@ ListData* Workspace::FindPlace(ListData* pref){
// NOTE that this happens only if its main window is the front most one. // NOTE that this happens only if its main window is the front most one.
case B_FLOATING_APP_WINDOW_FEEL:{ case B_FLOATING_APP_WINDOW_FEEL:{
for(cursor = fBottomItem; cursor; cursor = cursor->upperItem){ for(cursor = fBottomItem; cursor; cursor = cursor->upperItem){
if (cursor->layerPtr->GetServerFeel() <= pref->layerPtr->GetServerFeel() if (cursor->layerPtr->_level <= pref->layerPtr->_level
&& pref->layerPtr->Window()->GetClientTeamID() == && pref->layerPtr->Window()->ClientTeamID() ==
cursor->layerPtr->Window()->GetClientTeamID()) cursor->layerPtr->Window()->ClientTeamID())
{ break; } { break; }
} }
@@ -422,9 +453,17 @@ ListData* Workspace::FindPlace(ListData* pref){
*/ */
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void Workspace::SearchAndSetNewFront(WinBorder* preferred){ void Workspace::SearchAndSetNewFront(WinBorder* preferred){
STRACE(("*WS(%ld)::SASNF(%s)\n", ID(), preferred? preferred->GetName(): "NULL"));
opLock.Lock();
// the new front must not be the same as the previous one. // the new front must not be the same as the previous one.
if (fFrontItem && fFrontItem->layerPtr == preferred) 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"));
opLock.Unlock();
return; return;
}
// properly place this 'preferred' WinBorder. // properly place this 'preferred' WinBorder.
ListData *lastInserted; ListData *lastInserted;
@@ -432,17 +471,29 @@ void Workspace::SearchAndSetNewFront(WinBorder* preferred){
preferred = lastInserted? lastInserted->layerPtr: NULL; preferred = lastInserted? lastInserted->layerPtr: NULL;
// if the new front layer is the same... there is no point continuing // if the new front layer is the same... there is no point continuing
if(fFrontItem == lastInserted) 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"));
opLock.Unlock();
return; return;
}
if(!lastInserted){
printf("PAAAAANIC: Workspace::SASNF(): 'lastInserted' IS NULL\n");
}
else{
printf("\n&&&&Processing for: %s\n", lastInserted->layerPtr->GetName());
}
if (lastInserted && !(lastInserted->layerPtr->IsHidden())){ if (lastInserted && !(lastInserted->layerPtr->IsHidden())){
int32 prefFeel = preferred->Window()->GetFeel(); int32 prefFeel = preferred->Window()->Feel();
if (prefFeel == B_NORMAL_WINDOW_FEEL){ if (prefFeel == B_NORMAL_WINDOW_FEEL){
STRACE((" NORMAL Window '%s' -", preferred->GetName())); STRACE((" NORMAL Window '%s' -", preferred? preferred->GetName(): "NULL"));
if (fFrontItem){ if (fFrontItem){
// if they are in the same team... // if they are in the same team...
if (preferred->Window()->GetClientTeamID() == fFrontItem->layerPtr->Window()->GetClientTeamID()){ if (preferred->Window()->ClientTeamID() == fFrontItem->layerPtr->Window()->ClientTeamID()){
STRACE((" SAME TeamID\n")); STRACE((" SAME TeamID\n"));
// collect subset windows that are common to application's windows... // collect subset windows that are common to application's windows...
// NOTE: A subset window *can* be added to more than just one window. // NOTE: A subset window *can* be added to more than just one window.
@@ -455,9 +506,9 @@ STRACE((" SAME TeamID\n"));
// * also remove them, for repositioning, later. // * also remove them, for repositioning, later.
ListData *listItem = fTopItem; ListData *listItem = fTopItem;
while(listItem){ while(listItem){
int32 feel = listItem->layerPtr->Window()->GetFeel(); int32 feel = listItem->layerPtr->Window()->Feel();
if (feel == B_FLOATING_SUBSET_WINDOW_FEEL || feel == B_MODAL_SUBSET_WINDOW_FEEL){ if (feel == B_FLOATING_SUBSET_WINDOW_FEEL || feel == B_MODAL_SUBSET_WINDOW_FEEL){
if(preferred->Window()->GetFMWList()->HasItem(listItem->layerPtr)){ if(preferred->Window()->fWinFMWList.HasItem(listItem->layerPtr)){
commonFMW.AddItem(listItem->layerPtr); commonFMW.AddItem(listItem->layerPtr);
// *carefully* remove the item from the list // *carefully* remove the item from the list
ListData *item = listItem; ListData *item = listItem;
@@ -478,8 +529,8 @@ STRACE((" SAME TeamID\n"));
// ALSO collect application's floating and modal windows, // ALSO collect application's floating and modal windows,
// for reinsertion, later. // for reinsertion, later.
else if (feel == B_FLOATING_APP_WINDOW_FEEL || feel == B_MODAL_APP_WINDOW_FEEL){ else if (feel == B_FLOATING_APP_WINDOW_FEEL || feel == B_MODAL_APP_WINDOW_FEEL){
if(listItem->layerPtr->Window()->GetClientTeamID() == if(listItem->layerPtr->Window()->ClientTeamID() ==
preferred->Window()->GetClientTeamID()) preferred->Window()->ClientTeamID())
{ {
appFMW.AddItem(listItem->layerPtr); appFMW.AddItem(listItem->layerPtr);
// *carefully* remove the item from the list // *carefully* remove the item from the list
@@ -491,10 +542,11 @@ STRACE((" SAME TeamID\n"));
else else
listItem = listItem->lowerItem; listItem = listItem->lowerItem;
} }
// put in the final list, items that are not found in the common list // put in the final list, items that are not found in the common list
count = preferred->Window()->GetFMWList()->CountItems(); count = preferred->Window()->fWinFMWList.CountItems();
for (i=0; i<count; i++){ for (i=0; i<count; i++){
void *item = preferred->Window()->GetFMWList()->ItemAt(i); void *item = preferred->Window()->fWinFMWList.ItemAt(i);
if (commonFMW.HasItem(item)){ } if (commonFMW.HasItem(item)){ }
else else
finalFMWList.AddItem(item); finalFMWList.AddItem(item);
@@ -511,11 +563,11 @@ STRACE((" SAME TeamID\n"));
WinBorder *wb = (WinBorder*)finalFMWList.LastItem(); WinBorder *wb = (WinBorder*)finalFMWList.LastItem();
bool lastIsModal = false; bool lastIsModal = false;
if ( (wb && if ( (wb &&
(wb->Window()->GetFeel() == B_MODAL_SUBSET_WINDOW_FEEL (wb->Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL
|| wb->Window()->GetFeel() == B_MODAL_APP_WINDOW_FEEL)) || wb->Window()->Feel() == B_MODAL_APP_WINDOW_FEEL))
|| (fBottomItem && || (fBottomItem &&
(fBottomItem->layerPtr->Window()->GetFeel() == B_MODAL_ALL_WINDOW_FEEL (fBottomItem->layerPtr->Window()->Feel() == B_MODAL_ALL_WINDOW_FEEL
|| fBottomItem->layerPtr->Window()->GetFeel() == B_SYSTEM_FIRST)) || fBottomItem->layerPtr->Window()->Feel() == B_SYSTEM_FIRST))
) )
{ lastIsModal = true; } { lastIsModal = true; }
@@ -525,18 +577,18 @@ STRACE((" SAME TeamID\n"));
count = finalFMWList.CountItems(); count = finalFMWList.CountItems();
for(i=0; i<count; i++){ for(i=0; i<count; i++){
WinBorder *wb = (WinBorder*)finalFMWList.ItemAt(i); WinBorder *wb = (WinBorder*)finalFMWList.ItemAt(i);
if(wb->Window()->GetFeel() == B_FLOATING_SUBSET_WINDOW_FEEL if(wb->Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL
|| wb->Window()->GetFeel() == B_FLOATING_APP_WINDOW_FEEL) || wb->Window()->Feel() == B_FLOATING_APP_WINDOW_FEEL)
{ {
// set its new MainWinBorder // set its new MainWinBorder
if(wb->Window()->GetFeel() == B_FLOATING_SUBSET_WINDOW_FEEL) if(wb->Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL)
wb->SetMainWinBorder(preferred); wb->SetMainWinBorder(preferred);
// don't add if the last WinBorder is a modal one. // don't add if the last WinBorder is a modal one.
if (lastIsModal) if (lastIsModal)
continue; continue;
} }
else{ else{
if(wb->Window()->GetFeel() == B_MODAL_SUBSET_WINDOW_FEEL) if(wb->Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL)
wb->SetMainWinBorder(preferred); wb->SetMainWinBorder(preferred);
// if this modal window is not hidden, give it the front status. // if this modal window is not hidden, give it the front status.
if (!(wb->IsHidden())) if (!(wb->IsHidden()))
@@ -563,8 +615,8 @@ STRACE((" SAME TeamID\n"));
STRACE((" DIFERRENT TeamID\n")); STRACE((" DIFERRENT TeamID\n"));
// remove front window's floating(_SUBSET_/_APP_) windows, if any. // remove front window's floating(_SUBSET_/_APP_) windows, if any.
ListData *listItem = fFrontItem->lowerItem; ListData *listItem = fFrontItem->lowerItem;
while(listItem && (listItem->layerPtr->GetServerFeel() == B_FLOATING_SUBSET_FEEL while(listItem && (listItem->layerPtr->_level == B_FLOATING_SUBSET_FEEL
|| listItem->layerPtr->GetServerFeel() == B_FLOATING_APP_FEEL)) || listItem->layerPtr->_level == B_FLOATING_APP_FEEL))
{ // *carefully* remove the item from the list { // *carefully* remove the item from the list
ListData *item = listItem; ListData *item = listItem;
listItem = listItem->lowerItem; listItem = listItem->lowerItem;
@@ -585,12 +637,12 @@ STRACE((" NO previous FRONT Item\n"));
// remove window's subset and application's *modal* windows spread // remove window's subset and application's *modal* windows spread
// across Workspace's list, to be insert later, in the corect order. // across Workspace's list, to be insert later, in the corect order.
while(listItem){ while(listItem){
int32 feel = listItem->layerPtr->Window()->GetFeel(); int32 feel = listItem->layerPtr->Window()->Feel();
if ((feel == B_MODAL_SUBSET_WINDOW_FEEL if ((feel == B_MODAL_SUBSET_WINDOW_FEEL
&& preferred->Window()->GetFMWList()->HasItem(listItem->layerPtr)) && preferred->Window()->fWinFMWList.HasItem(listItem->layerPtr))
|| (feel == B_MODAL_APP_WINDOW_FEEL || (feel == B_MODAL_APP_WINDOW_FEEL
&& preferred->Window()->GetClientTeamID() == && preferred->Window()->ClientTeamID() ==
listItem->layerPtr->Window()->GetClientTeamID() listItem->layerPtr->Window()->ClientTeamID()
)) ))
{ {
// *carefully* remove the item from the list // *carefully* remove the item from the list
@@ -601,12 +653,10 @@ STRACE((" NO previous FRONT Item\n"));
else else
listItem = listItem->lowerItem; listItem = listItem->lowerItem;
} }
// add to the final list window's subset windows. (..._SUBSET_...) // add to the final list window's subset windows. (..._SUBSET_...)
finalFMWList.AddFMWList( preferred->Window()->GetFMWList() ); finalFMWList.AddFMWList(&(preferred->Window()->fWinFMWList));
// also add application's ones. (..._APP_...) // also add application's ones. (..._APP_...)
finalFMWList.AddFMWList(preferred->Window()->GetApp()->GetFMWList()); finalFMWList.AddFMWList(&(preferred->Window()->App()->fAppFMWList));
// insert windows found in 'finalFMWList' in Workspace's list. // insert windows found in 'finalFMWList' in Workspace's list.
// IF *one* modal is found, do not add floating ones! // IF *one* modal is found, do not add floating ones!
@@ -614,11 +664,11 @@ STRACE((" NO previous FRONT Item\n"));
WinBorder *wb = (WinBorder*)finalFMWList.LastItem(); WinBorder *wb = (WinBorder*)finalFMWList.LastItem();
bool lastIsModal = false; bool lastIsModal = false;
if ( (wb && if ( (wb &&
(wb->Window()->GetFeel() == B_MODAL_SUBSET_WINDOW_FEEL (wb->Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL
|| wb->Window()->GetFeel() == B_MODAL_APP_WINDOW_FEEL)) || wb->Window()->Feel() == B_MODAL_APP_WINDOW_FEEL))
|| (fBottomItem && || (fBottomItem &&
(fBottomItem->layerPtr->Window()->GetFeel() == B_MODAL_ALL_WINDOW_FEEL (fBottomItem->layerPtr->Window()->Feel() == B_MODAL_ALL_WINDOW_FEEL
|| fBottomItem->layerPtr->Window()->GetFeel() == B_SYSTEM_FIRST)) || fBottomItem->layerPtr->Window()->Feel() == B_SYSTEM_FIRST))
) )
{ lastIsModal = true; } { lastIsModal = true; }
@@ -629,18 +679,18 @@ STRACE((" NO previous FRONT Item\n"));
for(i=0; i<count; i++){ for(i=0; i<count; i++){
WinBorder *wb = (WinBorder*)finalFMWList.ItemAt(i); WinBorder *wb = (WinBorder*)finalFMWList.ItemAt(i);
// do not insert floating windows if the last is a modal one. // do not insert floating windows if the last is a modal one.
if(wb->Window()->GetFeel() == B_FLOATING_SUBSET_WINDOW_FEEL if(wb->Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL
|| wb->Window()->GetFeel() == B_FLOATING_APP_WINDOW_FEEL) || wb->Window()->Feel() == B_FLOATING_APP_WINDOW_FEEL)
{ {
// set its new MainWinBorder // set its new MainWinBorder
if(wb->Window()->GetFeel() == B_FLOATING_SUBSET_WINDOW_FEEL) if(wb->Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL)
wb->SetMainWinBorder(preferred); wb->SetMainWinBorder(preferred);
// don't add if the last WinBorder is a modal one. // don't add if the last WinBorder is a modal one.
if (lastIsModal) if (lastIsModal)
continue; continue;
} }
else{ else{
if(wb->Window()->GetFeel() == B_MODAL_SUBSET_WINDOW_FEEL) if(wb->Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL)
wb->SetMainWinBorder(preferred); wb->SetMainWinBorder(preferred);
// if this modal window is not hidden, give it the front status. // if this modal window is not hidden, give it the front status.
if (!(wb->IsHidden())) if (!(wb->IsHidden()))
@@ -667,24 +717,24 @@ STRACE((" NO previous FRONT Item\n"));
|| prefFeel == B_FLOATING_APP_WINDOW_FEEL || prefFeel == B_FLOATING_APP_WINDOW_FEEL
|| prefFeel == B_FLOATING_ALL_WINDOW_FEEL) || prefFeel == B_FLOATING_ALL_WINDOW_FEEL)
{ {
STRACE((" FLOATING Window '%s'\n", preferred->GetName())); STRACE((" FLOATING Window '%s'\n", preferred? preferred->GetName(): "NULL"));
// Do nothing! FindPlace() was called and it has corectly placed our window // Do nothing! FindPlace() was called and it has corectly placed our window
// We don't have to do noting here. // We don't have to do noting here.
} }
else if( prefFeel == B_MODAL_SUBSET_WINDOW_FEEL else if( prefFeel == B_MODAL_SUBSET_WINDOW_FEEL
|| prefFeel == B_MODAL_APP_WINDOW_FEEL) || prefFeel == B_MODAL_APP_WINDOW_FEEL)
{ {
STRACE((" MODAL_APP/SUBSET Window '%s'\n", preferred->GetName())); STRACE((" MODAL_APP/SUBSET Window '%s'\n", preferred? preferred->GetName(): "NULL"));
FMWList finalMWList; FMWList finalMWList;
int32 count, i; int32 count = 0, i;
int32 prefIndex; int32 prefIndex = -1;
if (fFrontItem && fFrontItem->layerPtr->GetServerFeel() == B_NORMAL_FEEL) if (fFrontItem && fFrontItem->layerPtr->_level == B_NORMAL_FEEL)
{ {
// remove front window's floating(_SUBSET_/_APP_) windows, if any. // remove front window's floating(_SUBSET_/_APP_) windows, if any.
ListData *listItem = fFrontItem->lowerItem; ListData *listItem = fFrontItem->lowerItem;
while(listItem && (listItem->layerPtr->GetServerFeel() == B_FLOATING_SUBSET_FEEL while(listItem && (listItem->layerPtr->_level == B_FLOATING_SUBSET_FEEL
|| listItem->layerPtr->GetServerFeel() == B_FLOATING_APP_FEEL)) || listItem->layerPtr->_level == B_FLOATING_APP_FEEL))
{ // *carefully* remove the item from the list { // *carefully* remove the item from the list
ListData *item = listItem; ListData *item = listItem;
listItem = listItem->lowerItem; listItem = listItem->lowerItem;
@@ -697,13 +747,13 @@ STRACE((" MODAL_APP/SUBSET Window '%s'\n", preferred->GetName()));
// modal windoes *only*, from application's set. // modal windoes *only*, from application's set.
// If it is a MODAL_APP only search an take windows in/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){ if (prefFeel == B_MODAL_SUBSET_WINDOW_FEEL){
prefIndex = preferred->MainWinBorder()->Window()->GetFMWList()->IndexOf(preferred); prefIndex = preferred->MainWinBorder()->Window()->fWinFMWList.IndexOf(preferred);
count = preferred->MainWinBorder()->Window()->GetFMWList()->CountItems(); count = preferred->MainWinBorder()->Window()->fWinFMWList.CountItems();
if (prefIndex >= 0){ if (prefIndex >= 0){
WinBorder *wb = NULL; WinBorder *wb = NULL;
// add modal windows from its main window subset - windows that are // add modal windows from its main window subset - windows that are
// positioned after 'preferred'. // positioned after 'preferred'.
FMWList *listPtr = preferred->MainWinBorder()->Window()->GetFMWList(); FMWList *listPtr = &(preferred->MainWinBorder()->Window()->fWinFMWList);
for(i = prefIndex+1; i < count; i++){ for(i = prefIndex+1; i < count; i++){
// they *all* are modal windows. // they *all* are modal windows.
wb = (WinBorder*)listPtr->ItemAt(i); wb = (WinBorder*)listPtr->ItemAt(i);
@@ -715,11 +765,11 @@ STRACE((" MODAL_APP/SUBSET Window '%s'\n", preferred->GetName()));
RemoveItem(ld); RemoveItem(ld);
} }
// add modal windows that are found in application's subset // add modal windows that are found in application's subset
count = preferred->Window()->GetApp()->GetFMWList()->CountItems(); count = preferred->Window()->App()->fAppFMWList.CountItems();
listPtr = preferred->Window()->GetApp()->GetFMWList(); listPtr = &(preferred->Window()->App()->fAppFMWList);
for(i = 0; i < count; i++){ for(i = 0; i < count; i++){
wb = (WinBorder*)listPtr->ItemAt(i); wb = (WinBorder*)listPtr->ItemAt(i);
if (wb->Window()->GetFeel() == B_MODAL_APP_WINDOW_FEEL){ if (wb->Window()->Feel() == B_MODAL_APP_WINDOW_FEEL){
finalMWList.AddItem(wb); finalMWList.AddItem(wb);
// remove those windows(if in there), for correct re-insertion later. // remove those windows(if in there), for correct re-insertion later.
ListData *ld = NULL; ListData *ld = NULL;
@@ -730,13 +780,13 @@ STRACE((" MODAL_APP/SUBSET Window '%s'\n", preferred->GetName()));
} }
} }
else if(prefFeel == B_MODAL_APP_WINDOW_FEEL){ else if(prefFeel == B_MODAL_APP_WINDOW_FEEL){
prefIndex = preferred->Window()->GetApp()->GetFMWList()->IndexOf(preferred); prefIndex = preferred->Window()->App()->fAppFMWList.IndexOf(preferred);
count = preferred->Window()->GetApp()->GetFMWList()->CountItems(); count = preferred->Window()->App()->fAppFMWList.CountItems();
if (prefIndex >= 0){ if (prefIndex >= 0){
WinBorder *wb = NULL; WinBorder *wb = NULL;
// add modal windows from application's subset - windows that are // add modal windows from application's subset - windows that are
// positioned after 'preferred'. // positioned after 'preferred'.
FMWList *listPtr = preferred->Window()->GetApp()->GetFMWList(); FMWList *listPtr = &(preferred->Window()->App()->fAppFMWList);
for(i = prefIndex+1; i < count; i++){ for(i = prefIndex+1; i < count; i++){
wb = (WinBorder*)listPtr->ItemAt(i); wb = (WinBorder*)listPtr->ItemAt(i);
// they *all* are modal windows. // they *all* are modal windows.
@@ -779,14 +829,14 @@ STRACE((" MODAL_APP/SUBSET Window '%s'\n", preferred->GetName()));
else if(prefFeel == B_MODAL_ALL_WINDOW_FEEL else if(prefFeel == B_MODAL_ALL_WINDOW_FEEL
|| prefFeel == B_SYSTEM_FIRST) || prefFeel == B_SYSTEM_FIRST)
{ {
STRACE((" MODAL ALL/SYSTEM FIRST Window '%s'\n", preferred->GetName())); STRACE((" MODAL ALL/SYSTEM FIRST Window '%s'\n", preferred? preferred->GetName(): "NULL"));
// remove all application's floating windows. // remove all application's floating windows.
if (fFrontItem && fFrontItem->layerPtr->GetServerFeel() == B_NORMAL_FEEL) if (fFrontItem && fFrontItem->layerPtr->_level == B_NORMAL_FEEL)
{ {
ListData *listItem = fFrontItem->lowerItem; ListData *listItem = fFrontItem->lowerItem;
while(listItem && while(listItem &&
(listItem->layerPtr->GetServerFeel() == B_FLOATING_SUBSET_FEEL (listItem->layerPtr->_level == B_FLOATING_SUBSET_FEEL
|| listItem->layerPtr->GetServerFeel() == B_FLOATING_APP_FEEL)) || listItem->layerPtr->_level == B_FLOATING_APP_FEEL))
{ {
// *carefully* remove the item from the list // *carefully* remove the item from the list
ListData *item = listItem; ListData *item = listItem;
@@ -800,34 +850,52 @@ STRACE((" MODAL ALL/SYSTEM FIRST Window '%s'\n", preferred->GetName()));
} }
else{ else{
// We ***should NOT*** reach this point! // We ***should NOT*** reach this point!
printf("SERVER: PANIC: \"%s\": What kind of window is this???\n", preferred->GetName()); printf("SERVER: PANIC: \"%s\": What kind of window is this???\n", preferred? preferred->GetName(): "NULL");
} }
} }
else
STRACE((" The window IS Hidden\n"));
ListData *newFrontItem = NULL;
if(preferred){ if(preferred){
int32 feel = fBottomItem->layerPtr->Window()->GetFeel(); int32 feel = fBottomItem->layerPtr->Window()->Feel();
// if preferred is one of these *don't* give front state to it! // if preferred is one of these *don't* give front state to it!
if(preferred->GetServerFeel() == B_FLOATING_SUBSET_FEEL if(preferred->_level == B_FLOATING_SUBSET_FEEL
|| preferred->GetServerFeel() == B_FLOATING_APP_FEEL || preferred->_level == B_FLOATING_APP_FEEL
|| preferred->GetServerFeel() == B_FLOATING_ALL_FEEL) || preferred->_level == B_FLOATING_ALL_FEEL)
{ } { }
// if the last in workspace's list is one of these, GIVE focus to it! // if the last in workspace's list is one of these, GIVE focus to it!
else if(feel == B_SYSTEM_FIRST || feel == B_MODAL_ALL_WINDOW_FEEL){ else if((feel == B_SYSTEM_FIRST || feel == B_MODAL_ALL_WINDOW_FEEL)
fFrontItem = fBottomItem; && !(fBottomItem->layerPtr->IsHidden()) )
{
newFrontItem = fBottomItem;
} }
// the SYSTEM_LAST will get the front status, only if it's the only // the SYSTEM_LAST will get the front status, only if it's the only
// WinBorder in this workspace. // WinBorder in this workspace.
else if (preferred->GetServerFeel() == B_SYSTEM_LAST){ else if (preferred->_level == B_SYSTEM_LAST
&& !(preferred->IsHidden()) )
{
if(fBottomItem->layerPtr == preferred) if(fBottomItem->layerPtr == preferred)
fFrontItem = HasItem(preferred); newFrontItem = HasItem(preferred);
} }
// this is in case of MODAL[APP/SUBSET] and NORMAL windows // this is in case of MODAL[APP/SUBSET] and NORMAL windows
else if ( !(preferred->IsHidden()) ){
newFrontItem = HasItem(preferred);
}
else{ else{
fFrontItem = HasItem(preferred); newFrontItem = NULL;
} }
} }
else{ fFrontItem = NULL; } else{ newFrontItem = NULL; }
if (fFrontItem != newFrontItem){
fFrontItem = newFrontItem;
// TODO: call a method like... WinBorder::MakeFront(true);
}
opLock.Unlock();
STRACE(("#WS(%ld)::SASNF(%s) ENDED! Workspace data...", ID(), preferred? preferred->GetName(): "NULL"));
STRACESTREAM();
} }
/* This method performs a simple opperation. It searched the new focus window /* 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 * by walking from front to back, cheking for some things, until all variables
@@ -835,24 +903,59 @@ STRACE((" MODAL ALL/SYSTEM FIRST Window '%s'\n", preferred->GetName()));
*/ */
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void Workspace::SearchAndSetNewFocus(WinBorder* preferred){ void Workspace::SearchAndSetNewFocus(WinBorder* preferred){
return; // TODO: remove!
// return;
opLock.Lock();
if(!preferred)
preferred = fBottomItem? fBottomItem->layerPtr : NULL;
bool selectOthers = false;
ListData *item = NULL; ListData *item = NULL;
for(item = fBottomItem; item != NULL; item = item->upperItem){ for(item = fBottomItem; item != NULL; item = item->upperItem){
// if this WinBorder doesn't want to have focus... get to the next one // if this WinBorder doesn't want to have focus... get to the next one
if (item->layerPtr->Window()->GetFlags() & B_AVOID_FOCUS) if (item->layerPtr->Window()->Flags() & B_AVOID_FOCUS)
continue; continue;
// this means there is no modal window before our preferred one. // this means there is no modal window before our preferred one.
if (item->layerPtr == preferred) if (item->layerPtr == preferred)
// our preffered one is hidden so... select another one
if (preferred && preferred->IsHidden()){
selectOthers = true;
continue;
}
else{
break;
}
// select one window, other than a system_last one!
if (selectOthers && item->layerPtr->_level != B_SYSTEM_LAST)
break; break;
// we now chose a modal window to give focus to // we now chose a modal window to give focus to
if (item->layerPtr->GetServerFeel() == B_SYSTEM_FIRST if (item->layerPtr->_level == B_SYSTEM_FIRST
|| item->layerPtr->GetServerFeel() == B_MODAL_ALL_FEEL || item->layerPtr->_level == B_MODAL_ALL_FEEL
|| item->layerPtr->GetServerFeel() == B_MODAL_APP_FEEL || item->layerPtr->_level == B_MODAL_APP_FEEL
|| item->layerPtr->GetServerFeel() == B_MODAL_SUBSET_FEEL) || item->layerPtr->_level == B_MODAL_SUBSET_FEEL)
{ {
break; break;
} }
} }
// there are no windows below us to select. take the one from above us.
if(selectOthers && !item){
// there HAS to be a
item = HasItem(preferred);
if (item)
item= item->lowerItem;
}
// there are NO windows in front of us, and no regular window below us
// maybe there is a system_last window...
if(!item){
item = fTopItem;
}
if (item != fFocusItem){ if (item != fFocusItem){
// TODO: item->ColorTabInGrey & send message to client // TODO: item->ColorTabInGrey & send message to client
@@ -860,6 +963,8 @@ void Workspace::SearchAndSetNewFocus(WinBorder* preferred){
// TODO: Rebuild & Redraw. // TODO: Rebuild & Redraw.
fFocusItem = item; fFocusItem = item;
} }
opLock.Unlock();
} }
/* The method moves a window to the back of its subset. /* The method moves a window to the back of its subset.
*/ */
@@ -871,12 +976,12 @@ STRACE(("\n!MoveToBack(%s) -", newLast? newLast->GetName(): "NULL"));
if(item){ if(item){
ListData *listItem = NULL; ListData *listItem = NULL;
switch(item->layerPtr->GetServerFeel()){ switch(item->layerPtr->_level){
case B_FLOATING_ALL_FEEL:{ case B_FLOATING_ALL_FEEL:{
STRACE((" B_FLOATING_ALL_FEEL window\n")); STRACE((" B_FLOATING_ALL_FEEL window\n"));
// search the place where we should insert it later // search the place where we should insert it later
listItem = item->upperItem; listItem = item->upperItem;
while(listItem && (listItem->layerPtr->GetServerFeel() == item->layerPtr->GetServerFeel())) while(listItem && (listItem->layerPtr->_level == item->layerPtr->_level))
listItem = listItem->upperItem; listItem = listItem->upperItem;
break; break;
@@ -891,8 +996,8 @@ STRACE((" B_FLOATING_SUBSET_FEEL/B_FLOATING_APP_FEEL window\n"));
// search the place where we should insert it later // search the place where we should insert it later
listItem = item->upperItem; listItem = item->upperItem;
while(listItem && while(listItem &&
(listItem->layerPtr->GetServerFeel() == B_FLOATING_SUBSET_FEEL (listItem->layerPtr->_level == B_FLOATING_SUBSET_FEEL
|| listItem->layerPtr->GetServerFeel() == B_FLOATING_APP_FEEL)) || listItem->layerPtr->_level == B_FLOATING_APP_FEEL))
listItem = listItem->upperItem; listItem = listItem->upperItem;
break; break;
@@ -905,9 +1010,9 @@ STRACE((" B_MODAL_SUBSET_FEEL/B_MODAL_APP_FEEL window\n"));
// search the place where we should insert it later // search the place where we should insert it later
listItem = item->upperItem; listItem = item->upperItem;
while(listItem && while(listItem &&
(listItem->layerPtr->GetServerFeel() == B_MODAL_SUBSET_FEEL (listItem->layerPtr->_level == B_MODAL_SUBSET_FEEL
|| listItem->layerPtr->GetServerFeel() == B_MODAL_APP_FEEL || listItem->layerPtr->_level == B_MODAL_APP_FEEL
|| listItem->layerPtr->GetServerFeel() == B_NORMAL_FEEL)) || listItem->layerPtr->_level == B_NORMAL_FEEL))
listItem = listItem->upperItem; listItem = listItem->upperItem;
break; break;
@@ -917,7 +1022,7 @@ STRACE((" B_MODAL_SUBSET_FEEL/B_MODAL_APP_FEEL window\n"));
case B_NORMAL_FEEL:{ case B_NORMAL_FEEL:{
STRACE((" B_NORMAL_FEEL window\n")); STRACE((" B_NORMAL_FEEL window\n"));
listItem = item->upperItem; listItem = item->upperItem;
while(listItem && (listItem->layerPtr->GetServerFeel() >= item->layerPtr->GetServerFeel())){ while(listItem && (listItem->layerPtr->_level >= item->layerPtr->_level)){
listItem = listItem->upperItem; listItem = listItem->upperItem;
} }
@@ -933,11 +1038,11 @@ STRACE((" B_NORMAL_FEEL window\n"));
else{ else{
// if it's a normal window, first remove any floating windows, // if it's a normal window, first remove any floating windows,
// it or its application has // it or its application has
if(newLast->GetServerFeel() == B_NORMAL_FEEL && fFrontItem->layerPtr == newLast){ if(newLast->_level == B_NORMAL_FEEL && fFrontItem->layerPtr == newLast){
ListData *iter = item->lowerItem; ListData *iter = item->lowerItem;
while(iter && while(iter &&
(iter->layerPtr->GetServerFeel() == B_FLOATING_SUBSET_FEEL (iter->layerPtr->_level == B_FLOATING_SUBSET_FEEL
|| iter->layerPtr->GetServerFeel() == B_FLOATING_APP_FEEL)) || iter->layerPtr->_level == B_FLOATING_APP_FEEL))
{ {
// *carefully* remove the item from the list // *carefully* remove the item from the list
ListData *itemX = iter; ListData *itemX = iter;
@@ -985,27 +1090,27 @@ RGBColor Workspace::BGColor(void) const{
// Debug methods!!! // Debug methods!!!
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void Workspace::PrintToStream() const{ void Workspace::PrintToStream() const{
printf("Workspace %ld hierarchy shown from back to front:\n", fID); printf("\nWorkspace %ld hierarchy shown from back to front:\n", fID);
for (ListData *item = fTopItem; item != NULL; item = item->lowerItem){ for (ListData *item = fTopItem; item != NULL; item = item->lowerItem){
WinBorder *wb = (WinBorder*)item->layerPtr; WinBorder *wb = (WinBorder*)item->layerPtr;
printf("\tName: %s\t%s", wb->GetName(), wb->IsHidden()?"Hidden\t": "NOT Hidden"); printf("\tName: %s\t%s", wb->GetName(), wb->IsHidden()?"Hidden\t": "NOT Hidden");
if (wb->Window()->GetFeel() == B_FLOATING_SUBSET_WINDOW_FEEL) if (wb->Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL)
printf("\t%s\n", "B_FLOATING_SUBSET_WINDOW_FEEL"); printf("\t%s\n", "B_FLOATING_SUBSET_WINDOW_FEEL");
if (wb->Window()->GetFeel() == B_FLOATING_APP_WINDOW_FEEL) if (wb->Window()->Feel() == B_FLOATING_APP_WINDOW_FEEL)
printf("\t%s\n", "B_FLOATING_APP_WINDOW_FEEL"); printf("\t%s\n", "B_FLOATING_APP_WINDOW_FEEL");
if (wb->Window()->GetFeel() == B_FLOATING_ALL_WINDOW_FEEL) if (wb->Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL)
printf("\t%s\n", "B_FLOATING_ALL_WINDOW_FEEL"); printf("\t%s\n", "B_FLOATING_ALL_WINDOW_FEEL");
if (wb->Window()->GetFeel() == B_MODAL_SUBSET_WINDOW_FEEL) if (wb->Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL)
printf("\t%s\n", "B_MODAL_SUBSET_WINDOW_FEEL"); printf("\t%s\n", "B_MODAL_SUBSET_WINDOW_FEEL");
if (wb->Window()->GetFeel() == B_MODAL_APP_WINDOW_FEEL) if (wb->Window()->Feel() == B_MODAL_APP_WINDOW_FEEL)
printf("\t%s\n", "B_MODAL_APP_WINDOW_FEEL"); printf("\t%s\n", "B_MODAL_APP_WINDOW_FEEL");
if (wb->Window()->GetFeel() == B_MODAL_ALL_WINDOW_FEEL) if (wb->Window()->Feel() == B_MODAL_ALL_WINDOW_FEEL)
printf("\t%s\n", "B_MODAL_ALL_WINDOW_FEEL"); printf("\t%s\n", "B_MODAL_ALL_WINDOW_FEEL");
if (wb->Window()->GetFeel() == B_NORMAL_WINDOW_FEEL) if (wb->Window()->Feel() == B_NORMAL_WINDOW_FEEL)
printf("\t%s\n", "B_NORMAL_WINDOW_FEEL"); printf("\t%s\n", "B_NORMAL_WINDOW_FEEL");
if (wb->Window()->GetFeel() == B_SYSTEM_LAST) if (wb->Window()->Feel() == B_SYSTEM_LAST)
printf("\t%s\n", "B_SYSTEM_LAST"); printf("\t%s\n", "B_SYSTEM_LAST");
if (wb->Window()->GetFeel() == B_SYSTEM_FIRST) if (wb->Window()->Feel() == B_SYSTEM_FIRST)
printf("\t%s\n", "B_SYSTEM_FIRST"); printf("\t%s\n", "B_SYSTEM_FIRST");
} }
printf("Focus Layer:\t%s\n", fFocusItem? fFocusItem->layerPtr->GetName(): "NULL"); printf("Focus Layer:\t%s\n", fFocusItem? fFocusItem->layerPtr->GetName(): "NULL");
@@ -1014,3 +1119,15 @@ void Workspace::PrintToStream() const{
// printf("Top Layer:\t%s\n", fTopItem? fTopItem->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"); // printf("Bottom Layer:\t%s\n", fBottomItem? fBottomItem->layerPtr->GetName(): "NULL");
} }
//---------------------------------------------------------------------------
void Workspace::PrintItem(ListData *item) const{
printf("ListData members:\n");
if (item){
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");
}
else{
printf("NULL item!!!\n");
}
}
+13 -3
View File
@@ -2,11 +2,13 @@
#define _WORKSPACE_H_ #define _WORKSPACE_H_
#include <SupportDefs.h> #include <SupportDefs.h>
#include <Locker.h>
#include "RGBColor.h" #include "RGBColor.h"
class WinBorder; class WinBorder;
class RBGColor; class RBGColor;
class RootLayer;
struct ListData{ struct ListData{
WinBorder *layerPtr; WinBorder *layerPtr;
@@ -19,14 +21,15 @@ class Workspace
public: public:
Workspace(const uint32 colorspace, Workspace(const uint32 colorspace,
int32 ID, int32 ID,
const RGBColor& BGColor); const RGBColor& BGColor,
RootLayer* owner);
~Workspace(); ~Workspace();
bool AddLayerPtr(WinBorder* layer); bool AddLayerPtr(WinBorder* layer);
bool RemoveLayerPtr(WinBorder* layer); bool RemoveLayerPtr(WinBorder* layer);
bool SetFocusLayer(WinBorder* layer); WinBorder* SetFocusLayer(WinBorder* layer);
WinBorder* FocusLayer() const; WinBorder* FocusLayer() const;
bool SetFrontLayer(WinBorder* layer); WinBorder* SetFrontLayer(WinBorder* layer);
WinBorder* FrontLayer() const; WinBorder* FrontLayer() const;
void MoveToBack(WinBorder* newLast); void MoveToBack(WinBorder* newLast);
@@ -37,6 +40,8 @@ public:
WinBorder* GoToLowerItem(); WinBorder* GoToLowerItem();
bool GoToItem(WinBorder* layer); bool GoToItem(WinBorder* layer);
WinBorder* SearchLayerUnderPoint(BPoint pt);
void SetLocalSpace(const uint32 colorspace); void SetLocalSpace(const uint32 colorspace);
uint32 LocalSpace() const; uint32 LocalSpace() const;
@@ -49,6 +54,7 @@ public:
// uint32 Flags(void) const; // uint32 Flags(void) const;
// debug methods // debug methods
void PrintToStream() const; void PrintToStream() const;
void PrintItem(ListData *item) const;
private: private:
@@ -66,6 +72,10 @@ private:
// uint32 fFlags; // uint32 fFlags;
RGBColor fBGColor; RGBColor fBGColor;
BLocker opLock;
RootLayer *fOwner;
ListData *fBottomItem, // first visible onscreen ListData *fBottomItem, // first visible onscreen
*fTopItem, // the last visible(or covered by other Layers) *fTopItem, // the last visible(or covered by other Layers)
*fCurrentItem, // pointer to the currect element in the list *fCurrentItem, // pointer to the currect element in the list