ServerApp now maintains a list of all windows, ServerWindow's AS_DELETE_WINDOW

will update it automatically.
Renamed ServerWindow::fName to fTitle, made it a pointer - it will now just
adopt the title pointer that came from AS_CREATE_WINDOW.
Just another cleanup round: renamed Layer::GetName() to Name(), no
more layer->fName->String() accesses.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13239 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-06-23 18:48:10 +00:00
parent fcb006dcf5
commit a38e46a046
10 changed files with 322 additions and 341 deletions

View File

@ -518,13 +518,13 @@ Desktop::PrintToStream(void)
printf("RootLayer List:\n=======\n");
for (int32 i = 0; i < fRootLayerList.CountItems(); i++) {
printf("\t%s\n", ((RootLayer*)fRootLayerList.ItemAt(i))->GetName());
printf("\t%s\n", ((RootLayer*)fRootLayerList.ItemAt(i))->Name());
((RootLayer*)fRootLayerList.ItemAt(i))->PrintToStream();
printf("-------\n");
}
printf("=======\nActive RootLayer: %s\n",
fActiveRootLayer ? fActiveRootLayer->GetName() : "NULL");
fActiveRootLayer ? fActiveRootLayer->Name() : "NULL");
// printf("Active WinBorder: %s\n", fActiveWinBorder? fActiveWinBorder->Name(): "NULL");
printf("Screen List:\n");

View File

@ -99,7 +99,7 @@ Layer::Layer(BRect frame, const char* name, int32 token,
fClipReg(&fVisible2),
#endif
fServerWin(NULL),
fName(new BString(name)),
fName(name),
fViewToken(token),
fFlags(flags),
@ -132,15 +132,14 @@ CRITICAL(helper);
if (!fDriver)
CRITICAL("You MUST have a valid driver to init a Layer object\n");
STRACE(("Layer(%s) successfuly created\n", GetName()));
STRACE(("Layer(%s) successfuly created\n", Name()));
}
//! Destructor frees all allocated heap space
Layer::~Layer()
{
delete fLayerData;
delete fName;
// TODO: uncomment!
//PruneTree();
@ -159,7 +158,7 @@ Layer::~Layer()
void
Layer::AddChild(Layer* layer, ServerWindow* serverWin)
{
STRACE(("Layer(%s)::AddChild(%s) START\n", GetName(), layer->GetName()));
STRACE(("Layer(%s)::AddChild(%s) START\n", Name(), layer->Name()));
if (layer->fParent != NULL) {
printf("ERROR: AddChild(): Layer already has a parent\n");
@ -183,7 +182,7 @@ Layer::AddChild(Layer* layer, ServerWindow* serverWin)
// they will be set when the RootLayer for this tree will be added
// to the main tree structure.
if (!fRootLayer) {
STRACE(("Layer(%s)::AddChild(%s) END\n", GetName(), layer->GetName()));
STRACE(("Layer(%s)::AddChild(%s) END\n", Name(), layer->Name()));
return;
}
@ -233,7 +232,7 @@ Layer::AddChild(Layer* layer, ServerWindow* serverWin)
}
}
STRACE(("Layer(%s)::AddChild(%s) END\n", GetName(), layer->GetName()));
STRACE(("Layer(%s)::AddChild(%s) END\n", Name(), layer->Name()));
}
/*!
@ -246,7 +245,7 @@ Layer::AddChild(Layer* layer, ServerWindow* serverWin)
void
Layer::RemoveChild(Layer *layer)
{
STRACE(("Layer(%s)::RemoveChild(%s) START\n", GetName(), layer->GetName()));
STRACE(("Layer(%s)::RemoveChild(%s) START\n", Name(), layer->Name()));
if (!layer->fParent) {
printf("ERROR: RemoveChild(): Layer doesn't have a fParent\n");
@ -330,7 +329,7 @@ Layer::RemoveChild(Layer *layer)
}
}
}
STRACE(("Layer(%s)::RemoveChild(%s) END\n", GetName(), layer->GetName()));
STRACE(("Layer(%s)::RemoveChild(%s) END\n", Name(), layer->Name()));
}
//! Removes the calling layer from the tree
@ -476,7 +475,7 @@ Layer::BottomChild() const
void
Layer::RebuildFullRegion(void)
{
STRACE(("Layer(%s)::RebuildFullRegion()\n", GetName()));
STRACE(("Layer(%s)::RebuildFullRegion()\n", Name()));
if (fParent)
fFull.Set(fParent->ConvertToTop(fFrame ));
@ -501,8 +500,8 @@ Layer::RebuildFullRegion(void)
void
Layer::StartRebuildRegions( const BRegion& reg, Layer *target, uint32 action, BPoint& pt)
{
STRACE(("Layer(%s)::StartRebuildRegions() START\n", GetName()));
RBTRACE(("\n\nLayer(%s)::StartRebuildRegions() START\n", GetName()));
STRACE(("Layer(%s)::StartRebuildRegions() START\n", Name()));
RBTRACE(("\n\nLayer(%s)::StartRebuildRegions() START\n", Name()));
if (!fParent)
fFullVisible = fFull;
@ -519,7 +518,7 @@ Layer::StartRebuildRegions( const BRegion& reg, Layer *target, uint32 action, BP
}
#ifdef DEBUG_LAYER_REBUILD
printf("\nSRR: Layer(%s) ALMOST done regions:\n", GetName());
printf("\nSRR: Layer(%s) ALMOST done regions:\n", Name());
printf("\tVisible Region:\n");
fVisible.PrintToStream();
printf("\tFull Visible Region:\n");
@ -536,7 +535,7 @@ Layer::StartRebuildRegions( const BRegion& reg, Layer *target, uint32 action, BP
fRootLayer->fRedrawReg.Include(&redrawReg);
#ifdef DEBUG_LAYER_REBUILD
printf("\nLayer(%s)::StartRebuildRegions() DONE. Results:\n", GetName());
printf("\nLayer(%s)::StartRebuildRegions() DONE. Results:\n", Name());
printf("\tRedraw Region:\n");
fRootLayer->fRedrawReg.PrintToStream();
printf("\tCopy Region:\n");
@ -547,15 +546,15 @@ Layer::StartRebuildRegions( const BRegion& reg, Layer *target, uint32 action, BP
printf("\n");
#endif
STRACE(("Layer(%s)::StartRebuildRegions() END\n", GetName()));
RBTRACE(("Layer(%s)::StartRebuildRegions() END\n", GetName()));
STRACE(("Layer(%s)::StartRebuildRegions() END\n", Name()));
RBTRACE(("Layer(%s)::StartRebuildRegions() END\n", Name()));
}
// RebuildRegions
void
Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOffset)
{
STRACE(("Layer(%s)::RebuildRegions() START\n", GetName()));
STRACE(("Layer(%s)::RebuildRegions() START\n", Name()));
// TODO:/NOTE: this method must be executed as quickly as possible.
@ -578,14 +577,14 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
RRLabel1:
switch(action) {
case B_LAYER_NONE: {
RBTRACE(("1) Layer(%s): Action B_LAYER_NONE\n", GetName()));
STRACE(("1) Layer(%s): Action B_LAYER_NONE\n", GetName()));
RBTRACE(("1) Layer(%s): Action B_LAYER_NONE\n", Name()));
STRACE(("1) Layer(%s): Action B_LAYER_NONE\n", Name()));
oldRegion = fVisible;
break;
}
case B_LAYER_MOVE: {
RBTRACE(("1) Layer(%s): Action B_LAYER_MOVE\n", GetName()));
STRACE(("1) Layer(%s): Action B_LAYER_MOVE\n", GetName()));
RBTRACE(("1) Layer(%s): Action B_LAYER_MOVE\n", Name()));
STRACE(("1) Layer(%s): Action B_LAYER_MOVE\n", Name()));
oldRegion = fFullVisible;
fFrame.OffsetBy(pt.x, pt.y);
fFull.OffsetBy(pt.x, pt.y);
@ -598,15 +597,15 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
break;
}
case B_LAYER_SIMPLE_MOVE: {
RBTRACE(("1) Layer(%s): Action B_LAYER_SIMPLE_MOVE\n", GetName()));
STRACE(("1) Layer(%s): Action B_LAYER_SIMPLE_MOVE\n", GetName()));
RBTRACE(("1) Layer(%s): Action B_LAYER_SIMPLE_MOVE\n", Name()));
STRACE(("1) Layer(%s): Action B_LAYER_SIMPLE_MOVE\n", Name()));
fFull.OffsetBy(pt.x, pt.y);
break;
}
case B_LAYER_RESIZE: {
RBTRACE(("1) Layer(%s): Action B_LAYER_RESIZE\n", GetName()));
STRACE(("1) Layer(%s): Action B_LAYER_RESIZE\n", GetName()));
RBTRACE(("1) Layer(%s): Action B_LAYER_RESIZE\n", Name()));
STRACE(("1) Layer(%s): Action B_LAYER_RESIZE\n", Name()));
oldRegion = fVisible;
fFrame.right += pt.x;
@ -621,8 +620,8 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
break;
}
case B_LAYER_MASK_RESIZE: {
RBTRACE(("1) Layer(%s): Action B_LAYER_MASK_RESIZE\n", GetName()));
STRACE(("1) Layer(%s): Action B_LAYER_MASK_RESIZE\n", GetName()));
RBTRACE(("1) Layer(%s): Action B_LAYER_MASK_RESIZE\n", Name()));
STRACE(("1) Layer(%s): Action B_LAYER_MASK_RESIZE\n", Name()));
oldRegion = fVisible;
BPoint offset, rSize;
@ -665,7 +664,7 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
if (!IsHidden()) {
#ifdef DEBUG_LAYER_REBUILD
printf("Layer(%s) real action START\n", GetName());
printf("Layer(%s) real action START\n", Name());
fFull.PrintToStream();
#endif
fFullVisible.MakeEmpty();
@ -721,7 +720,7 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
lay->RebuildRegions(reg, newAction, newPt, newOffset);
#ifdef DEBUG_LAYER_REBUILD
printf("\nLayer(%s) ALMOST done regions:\n", GetName());
printf("\nLayer(%s) ALMOST done regions:\n", Name());
printf("\tVisible Region:\n");
fVisible.PrintToStream();
printf("\tFull Visible Region:\n");
@ -731,7 +730,7 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
if(!IsHidden()) {
switch(action) {
case B_LAYER_NONE: {
RBTRACE(("2) Layer(%s): Action B_LAYER_NONE\n", GetName()));
RBTRACE(("2) Layer(%s): Action B_LAYER_NONE\n", Name()));
BRegion r(fVisible);
if (oldRegion.CountRects() > 0)
r.Exclude(&oldRegion);
@ -741,7 +740,7 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
break;
}
case B_LAYER_MOVE: {
RBTRACE(("2) Layer(%s): Action B_LAYER_MOVE\n", GetName()));
RBTRACE(("2) Layer(%s): Action B_LAYER_MOVE\n", Name()));
BRegion redrawReg;
BRegion *copyReg = new BRegion();
BRegion screenReg(fRootLayer->Bounds());
@ -769,7 +768,7 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
break;
}
case B_LAYER_RESIZE: {
RBTRACE(("2) Layer(%s): Action B_LAYER_RESIZE\n", GetName()));
RBTRACE(("2) Layer(%s): Action B_LAYER_RESIZE\n", Name()));
BRegion redrawReg;
redrawReg = fVisible;
@ -780,7 +779,7 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
break;
}
case B_LAYER_MASK_RESIZE: {
RBTRACE(("2) Layer(%s): Action B_LAYER_MASK_RESIZE\n", GetName()));
RBTRACE(("2) Layer(%s): Action B_LAYER_MASK_RESIZE\n", Name()));
BRegion redrawReg;
BRegion *copyReg = new BRegion();
@ -803,7 +802,7 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
break;
}
default:
RBTRACE(("2) Layer(%s): Action default\n", GetName()));
RBTRACE(("2) Layer(%s): Action default\n", Name()));
break;
}
}
@ -813,14 +812,14 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
}
*/
STRACE(("Layer(%s)::RebuildRegions() END\n", GetName()));
STRACE(("Layer(%s)::RebuildRegions() END\n", Name()));
}
// ResizeOthers
uint32
Layer::ResizeOthers(float x, float y, BPoint coords[], BPoint *ptOffset)
{
STRACE(("Layer(%s)::ResizeOthers() START\n", GetName()));
STRACE(("Layer(%s)::ResizeOthers() START\n", Name()));
uint32 rmask = fResizeMode;
// offset
@ -856,7 +855,7 @@ Layer::ResizeOthers(float x, float y, BPoint coords[], BPoint *ptOffset)
// illegal flag. Do nothing.
}
STRACE(("Layer(%s)::ResizeOthers() END\n", GetName()));
STRACE(("Layer(%s)::ResizeOthers() END\n", Name()));
return 0UL;
}
@ -866,7 +865,7 @@ Layer::ResizeOthers(float x, float y, BPoint coords[], BPoint *ptOffset)
void
Layer::Redraw(const BRegion& reg, Layer *startFrom)
{
STRACE(("Layer(%s)::Redraw();\n", GetName()));
STRACE(("Layer(%s)::Redraw();\n", Name()));
if (IsHidden())
// this layer has nothing visible on screen, so bail out.
return;
@ -876,7 +875,7 @@ Layer::Redraw(const BRegion& reg, Layer *startFrom)
if (pReg->CountRects() > 0)
RequestDraw(reg, startFrom);
STRACE(("Layer(%s)::Redraw() ENDED\n", GetName()));
STRACE(("Layer(%s)::Redraw() ENDED\n", Name()));
}
// Draw
@ -884,7 +883,7 @@ void
Layer::Draw(const BRect &rect)
{
#ifdef DEBUG_LAYER
printf("Layer(%s)::Draw: ", GetName());
printf("Layer(%s)::Draw: ", Name());
rect.PrintToStream();
#endif
@ -916,7 +915,7 @@ Layer::EmptyGlobals()
void
Layer::Show(bool invalidate)
{
STRACE(("Layer(%s)::Show()\n", GetName()));
STRACE(("Layer(%s)::Show()\n", Name()));
if(!IsHidden())
return;
@ -942,7 +941,7 @@ SendViewCoordUpdateMsg();
void
Layer::Hide(bool invalidate)
{
STRACE(("Layer(%s)::Hide()\n", GetName()));
STRACE(("Layer(%s)::Hide()\n", Name()));
if (IsHidden())
return;
@ -980,7 +979,7 @@ void
Layer::PopState()
{
if (fLayerData->prevState == NULL) {
fprintf(stderr, "WARNING: User called BView(%s)::PopState(), but there is NO state on stack!\n", fName->String());
fprintf(stderr, "WARNING: User called BView(%s)::PopState(), but there is NO state on stack!\n", Name());
return;
}
@ -1012,7 +1011,7 @@ Layer::Frame(void) const
void
Layer::MoveBy(float x, float y)
{
STRACE(("Layer(%s)::MoveBy() START\n", GetName()));
STRACE(("Layer(%s)::MoveBy() START\n", Name()));
if (!fParent) {
CRITICAL("ERROR: in Layer::MoveBy()! - No parent!\n");
return;
@ -1025,14 +1024,14 @@ Layer::MoveBy(float x, float y)
msg.Attach<float>(y);
GetRootLayer()->EnqueueMessage(msg);
STRACE(("Layer(%s)::MoveBy() END\n", GetName()));
STRACE(("Layer(%s)::MoveBy() END\n", Name()));
}
//! Resize the layer by the specified amount, complete with redraw
void
Layer::ResizeBy(float x, float y)
{
STRACE(("Layer(%s)::ResizeBy() START\n", GetName()));
STRACE(("Layer(%s)::ResizeBy() START\n", Name()));
if (!fParent) {
printf("ERROR: in Layer::ResizeBy()! - No parent!\n");
@ -1046,7 +1045,7 @@ Layer::ResizeBy(float x, float y)
msg.Attach<float>(y);
GetRootLayer()->EnqueueMessage(msg);
STRACE(("Layer(%s)::ResizeBy() END\n", GetName()));
STRACE(("Layer(%s)::ResizeBy() END\n", Name()));
}
// BoundsOrigin
@ -1241,22 +1240,24 @@ Layer::PruneTree(void)
void
Layer::PrintToStream()
{
printf("\n----------- Layer %s -----------\n",fName->String());
printf("\t Parent: %s\n", fParent? fParent->GetName():"NULL");
printf("\n----------- Layer %s -----------\n", Name());
printf("\t Parent: %s\n", fParent ? fParent->Name() : "<no parent>");
printf("\t us: %s\t ls: %s\n",
fUpperSibling? fUpperSibling->GetName():"NULL",
fLowerSibling? fLowerSibling->GetName():"NULL");
fUpperSibling ? fUpperSibling->Name() : "<none>",
fLowerSibling ? fLowerSibling->Name() : "<none>");
printf("\t topChild: %s\t bottomChild: %s\n",
fTopChild? fTopChild->GetName():"NULL",
fBottomChild? fBottomChild->GetName():"NULL");
fTopChild ? fTopChild->Name() : "<none>",
fBottomChild ? fBottomChild->Name() : "<none>");
printf("Frame: (%f, %f, %f, %f)", fFrame.left, fFrame.top, fFrame.right, fFrame.bottom);
printf("Token: %ld\n",fViewToken);
printf("Token: %ld\n", fViewToken);
printf("Hidden - direct: %s\n", fHidden?"true":"false");
printf("Hidden - indirect: %s\n", IsHidden()?"true":"false");
printf("ResizingMode: %lx\n", fResizeMode);
printf("Flags: %lx\n", fFlags);
if (fLayerData)
fLayerData->PrintToStream();
else
@ -1267,25 +1268,29 @@ Layer::PrintToStream()
void
Layer::PrintNode()
{
printf("-----------\nLayer %s\n",fName->String());
if(fParent)
printf("Parent: %s (%p)\n",fParent->GetName(), fParent);
printf("-----------\nLayer %s\n", Name());
if (fParent)
printf("Parent: %s (%p)\n", fParent->Name(), fParent);
else
printf("Parent: NULL\n");
if(fUpperSibling)
printf("Upper sibling: %s (%p)\n",fUpperSibling->GetName(), fUpperSibling);
if (fUpperSibling)
printf("Upper sibling: %s (%p)\n", fUpperSibling->Name(), fUpperSibling);
else
printf("Upper sibling: NULL\n");
if(fLowerSibling)
printf("Lower sibling: %s (%p)\n",fLowerSibling->GetName(), fLowerSibling);
if (fLowerSibling)
printf("Lower sibling: %s (%p)\n", fLowerSibling->Name(), fLowerSibling);
else
printf("Lower sibling: NULL\n");
if(fTopChild)
printf("Top child: %s (%p)\n",fTopChild->GetName(), fTopChild);
if (fTopChild)
printf("Top child: %s (%p)\n", fTopChild->Name(), fTopChild);
else
printf("Top child: NULL\n");
if(fBottomChild)
printf("Bottom child: %s (%p)\n",fBottomChild->GetName(), fBottomChild);
if (fBottomChild)
printf("Bottom child: %s (%p)\n", fBottomChild->Name(), fBottomChild);
else
printf("Bottom child: NULL\n");
#ifndef NEW_CLIPPING
@ -1298,9 +1303,9 @@ void
Layer::PrintTree()
{
printf("\n Tree structure:\n");
printf("\t%s\t%s\n", GetName(), IsHidden()? "Hidden": "NOT hidden");
printf("\t%s\t%s\n", Name(), IsHidden()? "Hidden": "NOT hidden");
for(Layer *lay = BottomChild(); lay != NULL; lay = UpperSibling())
printf("\t%s\t%s\n", lay->GetName(), lay->IsHidden()? "Hidden": "NOT hidden");
printf("\t%s\t%s\n", lay->Name(), lay->IsHidden()? "Hidden": "NOT hidden");
}
// UpdateStart
@ -1362,7 +1367,7 @@ Layer::move_layer(float x, float y)
BRect rect(fFull.Frame().OffsetByCopy(pt));
if (!fParent) {
printf("no parent in Layer::move_layer() (%s)\n", GetName());
printf("no parent in Layer::move_layer() (%s)\n", Name());
fFrameAction = B_LAYER_ACTION_NONE;
return;
}
@ -1396,7 +1401,7 @@ Layer::resize_layer(float x, float y)
rect.bottom += y;
if (!fParent) {
printf("no parent in Layer::resize_layer() (%s)\n", GetName());
printf("no parent in Layer::resize_layer() (%s)\n", Name());
fFrameAction = B_LAYER_ACTION_NONE;
return;
}
@ -1426,7 +1431,7 @@ Layer::FullInvalidate(const BRect &rect)
void
Layer::FullInvalidate(const BRegion& region)
{
STRACE(("Layer(%s)::FullInvalidate():\n", GetName()));
STRACE(("Layer(%s)::FullInvalidate():\n", Name()));
#ifdef DEBUG_LAYER
region.PrintToStream();
@ -1445,7 +1450,7 @@ Layer::FullInvalidate(const BRegion& region)
void
Layer::Invalidate(const BRegion& region)
{
STRACE(("Layer(%s)::Invalidate():\n", GetName()));
STRACE(("Layer(%s)::Invalidate():\n", Name()));
#ifdef DEBUG_LAYER
region.PrintToStream();
printf("\n");
@ -1464,8 +1469,8 @@ Layer::Invalidate(const BRegion& region)
void
Layer::RequestDraw(const BRegion &reg, Layer *startFrom)
{
STRACE(("Layer(%s)::RequestDraw()\n", GetName()));
printf("Layer(%s)::RequestDraw()\n", GetName());
STRACE(("Layer(%s)::RequestDraw()\n", Name()));
printf("Layer(%s)::RequestDraw()\n", Name());
//if (fClassID == AS_ROOTLAYER_CLASS)
// debugger("z");
// do not redraw any child until you must

View File

@ -92,8 +92,9 @@ class Layer {
virtual Layer* UpperSibling() const;
virtual Layer* BottomChild() const;
const char* GetName() const
{ return (fName) ? fName->String() : NULL; }
const char* Name() const
{ return fName.String(); }
#ifndef NEW_CLIPPING
virtual void RebuildFullRegion();
void StartRebuildRegions(const BRegion& reg,
@ -291,7 +292,7 @@ class Layer {
BRegion* fClipReg;
ServerWindow* fServerWin;
BString* fName;
BString fName;
int32 fViewToken;
uint32 fFlags;
uint32 fResizeMode;

View File

@ -239,7 +239,7 @@ RootLayer::WorkingThread(void *data)
#endif
oneRootLayer->Unlock();
STRACE(("info: RootLayer(%s)::WorkingThread listening on port %ld.\n", oneRootLayer->GetName(), oneRootLayer->fListenPort));
STRACE(("info: RootLayer(%s)::WorkingThread listening on port %ld.\n", oneRootLayer->Name(), oneRootLayer->fListenPort));
for (;;) {
err = messageQueue.GetNextMessage(code);
if (err < B_OK) {
@ -381,7 +381,7 @@ printf("Adi: new message\n");
break;
}
default:
printf("RootLayer(%s)::WorkingThread received unexpected code %lx\n", oneRootLayer->GetName(), code);
printf("RootLayer(%s)::WorkingThread received unexpected code %lx\n", oneRootLayer->Name(), code);
break;
}
@ -410,7 +410,7 @@ RootLayer::GoInvalidate(const Layer *layer, const BRegion &region)
void RootLayer::invalidate_layer(Layer *layer, const BRegion &region)
{
// NOTE: our thread (WorkingThread) is locked here.
STRACE(("RootLayer::invalidate_layer(%s)\n", layer->GetName()));
STRACE(("RootLayer::invalidate_layer(%s)\n", layer->Name()));
if (layer->fParent)
layer = layer->fParent;
@ -641,7 +641,7 @@ void RootLayer::RemoveSubsetWinBorder(WinBorder *winBorder, WinBorder *fromWinBo
// NOTE: This must be called by RootLayer's thread!!!!
bool RootLayer::SetActiveWorkspace(int32 index)
{
STRACE(("RootLayer(%s)::SetActiveWorkspace(%ld)\n", GetName(), index));
STRACE(("RootLayer(%s)::SetActiveWorkspace(%ld)\n", Name(), index));
// nice try!
if (index >= fWsCount || index == fActiveWksIndex || index < 0)
@ -1900,7 +1900,7 @@ RootLayer::DragMessage(void) const
void
RootLayer::PrintToStream()
{
printf("\nRootLayer '%s' internals:\n", GetName());
printf("\nRootLayer '%s' internals:\n", Name());
printf("Screen list:\n");
for(int32 i=0; i<fScreenPtrList.CountItems(); i++)
printf("\t%ld\n", ((Screen*)fScreenPtrList.ItemAt(i))->ScreenNumber());

View File

@ -14,11 +14,10 @@
#include <AppDefs.h>
#include <List.h>
#include <String.h>
#include <Autolock.h>
#include <SysCursor.h>
#include <ColorSet.h>
#include <RGBColor.h>
#include <stdio.h>
#include <string.h>
#include <ScrollBar.h>
#include <Shape.h>
#include <ServerProtocol.h>
@ -45,10 +44,12 @@
#include "LayerData.h"
#include "Utils.h"
#include <stdio.h>
#include <string.h>
//#define DEBUG_SERVERAPP
#ifdef DEBUG_SERVERAPP
# include <stdio.h>
# define STRACE(x) printf x
#else
# define STRACE(x) ;
@ -57,7 +58,6 @@
//#define DEBUG_SERVERAPP_FONT
#ifdef DEBUG_SERVERAPP_FONT
# include <stdio.h>
# define FTRACE(x) printf x
#else
# define FTRACE(x) ;
@ -77,13 +77,13 @@ static const uint32 kMsgAppQuit = 'appQ';
ServerApp::ServerApp(port_id clientReplyPort, port_id clientLooperPort,
team_id clientTeam, int32 handlerID, const char* signature)
:
fLockSem(-1),
fClientReplyPort(clientReplyPort),
fMessagePort(-1),
fClientLooperPort(clientLooperPort),
fSignature(signature),
fThread(-1),
fClientTeam(clientTeam),
fWindowListLock("window list"),
fAppCursor(NULL),
fCursorHidden(false),
fIsActive(false),
@ -94,11 +94,10 @@ ServerApp::ServerApp(port_id clientReplyPort, port_id clientLooperPort,
if (fSignature == "")
fSignature = "application/no-signature";
fLockSem = create_sem(1, Signature());
if (fLockSem < B_OK)
return;
char name[B_OS_NAME_LENGTH];
snprintf(name, sizeof(name), "a<%s", Signature());
fMessagePort = create_port(DEFAULT_MONITOR_PORT_SIZE, Signature());
fMessagePort = create_port(DEFAULT_MONITOR_PORT_SIZE, name);
if (fMessagePort < B_OK)
return;
@ -154,7 +153,6 @@ ServerApp::~ServerApp(void)
// there should be a way that this ServerApp be attached to a particular
// RootLayer to know which RootLayer's cursor to modify.
gDesktop->ActiveRootLayer()->GetCursorManager().RemoveAppCursors(fClientTeam);
delete_sem(fLockSem);
STRACE(("#ServerApp %s:~ServerApp()\n", fSignature.String()));
@ -176,8 +174,8 @@ ServerApp::InitCheck()
if (fClientReplyPort < B_OK)
return fClientReplyPort;
if (fLockSem < B_OK)
return fLockSem;
if (fWindowListLock.Sem() < B_OK)
return fWindowListLock.Sem();
return B_OK;
}
@ -390,7 +388,7 @@ ServerApp::_MessageLooper()
uint32 look;
uint32 feel;
uint32 flags;
uint32 wkspaces;
uint32 workspaces;
int32 token = B_NULL_TOKEN;
port_id sendPort = -1;
port_id looperPort = -1;
@ -400,24 +398,31 @@ ServerApp::_MessageLooper()
receiver.Read<uint32>(&look);
receiver.Read<uint32>(&feel);
receiver.Read<uint32>(&flags);
receiver.Read<uint32>(&wkspaces);
receiver.Read<uint32>(&workspaces);
receiver.Read<int32>(&token);
receiver.Read<port_id>(&sendPort);
receiver.Read<port_id>(&looperPort);
if (receiver.ReadString(&title) != B_OK)
break;
STRACE(("ServerApp %s: Got 'New Window' message, trying to do smething...\n", Signature()));
STRACE(("ServerApp %s: Got 'New Window' message, trying to do smething...\n",
Signature()));
// ServerWindow constructor will reply with port_id of a newly created port
ServerWindow *sw = new ServerWindow(title, this, sendPort, looperPort, token);
sw->Init(frame, look, feel, flags, wkspaces);
ServerWindow *window = new ServerWindow(title, this, sendPort, looperPort,
token);
window->Init(frame, look, feel, flags, workspaces);
if (fWindowListLock.Lock()) {
fWindowList.AddItem(window);
fWindowListLock.Unlock();
}
STRACE(("\nServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n",
app->fSignature.String(), title, frame.left, frame.top,
frame.right, frame.bottom));
free(title);
// We don't have to free the title, as it's owned by the ServerWindow now
break;
}
@ -467,7 +472,7 @@ ServerApp::_MessageLooper()
void
ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
{
LayerData ld;
// LayerData ld;
switch (code) {
case AS_UPDATE_COLORS:
@ -1916,6 +1921,15 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
}
void
ServerApp::RemoveWindow(ServerWindow* window)
{
BAutolock locker(fWindowListLock);
fWindowList.RemoveItem(window);
}
int32
ServerApp::CountBitmaps() const
{

View File

@ -43,14 +43,8 @@ public:
status_t InitCheck();
bool Run();
void Quit();
/*
TODO: These aren't even implemented...
void Lock(void);
void Unlock(void);
bool IsLocked(void);
*/
/*!
\brief Determines whether the application is the active one
\return true if active, false if not.
@ -61,7 +55,7 @@ public:
bool PingTarget(void);
void PostMessage(int32 code);
void SendMessageToClient( const BMessage* msg ) const;
void SendMessageToClient(const BMessage* msg) const;
void SetAppCursor(void);
@ -70,25 +64,24 @@ public:
const char *Signature() const { return fSignature.String(); }
void RemoveWindow(ServerWindow* window);
int32 CountBitmaps() const;
ServerBitmap *FindBitmap(int32 token) const;
int32 CountPictures() const;
ServerPicture *FindPicture(int32 token) const;
AreaPool *AppAreaPool() { return fSharedMem; }
SubWindowList fAppSubWindowList;
private:
void _DispatchMessage(int32 code, BPrivate::LinkReceiver &link);
void _MessageLooper();
static int32 _message_thread(void *data);
// TODO: Not used.
sem_id fLockSem;
// our BApplication's event port
port_id fClientReplyPort;
// port we receive messages from our BApplication
@ -106,10 +99,12 @@ private:
BPrivate::PortLink fLink;
BLocker fWindowListLock;
BList fWindowList;
// TODO:
// - Are really Bitmaps and Pictures stored per application and not globally ?
// - As we reference these stuff by token, what about putting them in hash tables ?
BList fWindowList;
BList fBitmapList;
BList fPictureList;

File diff suppressed because it is too large Load Diff

View File

@ -51,7 +51,7 @@ class ServerPicture;
coordinating and linking a window's WinBorder half with its messaging half, dispatching
mouse and key events from the server to its window, and other such things.
*/
class ServerWindow {
class ServerWindow : public BLocker {
public:
ServerWindow( const char *string,
ServerApp *winapp,
@ -68,10 +68,6 @@ public:
void Show(void);
void Hide(void);
status_t Lock(void);
void Unlock(void);
bool IsLocked(void) const;
// methods for sending various messages to client.
void Quit(void);
void Minimize(bool status);
@ -90,7 +86,7 @@ public:
// to who we belong. who do we own. our title.
inline ServerApp* App() const { return fServerApp; }
inline const WinBorder* GetWinBorder() const { return fWinBorder; }
inline const char* Title() const { return fName; }
inline const char* Title() const { return fTitle; }
// related thread/team_id(s).
inline team_id ClientTeam() const { return fClientTeam; }
@ -127,7 +123,9 @@ private:
BRegion &,
bool inverse,
BPoint where);
char fName[50];
private:
const char* fTitle;
ServerApp* fServerApp;
WinBorder* fWinBorder;
@ -144,8 +142,6 @@ private:
BMessage fClientViewsWithInvalidCoords;
BLocker fLocker;
int32 fHandlerToken;
Layer* fCurrentLayer;

View File

@ -89,7 +89,7 @@ SubWindowList::PrintToStream() const
for (int32 i=0; i<CountItems(); i++) {
wb = (WinBorder*)ItemAt(i);
printf("\t%s", wb->GetName());
printf("\t%s", wb->Name());
if (wb->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL)
printf("\t%s\n", "B_FLOATING_SUBSET_WINDOW_FEEL");

View File

@ -151,7 +151,7 @@ STRACE(("~Workspace(%ld) - say bye bye\n", fID));
*/
void Workspace::AddWinBorder(WinBorder *winBorder)
{
STRACE(("W(%ld)::AddWinBorder(%s)\n", fID, winBorder?winBorder->GetName():"NULL"));
STRACE(("W(%ld)::AddWinBorder(%s)\n", fID, winBorder?winBorder->Name():"NULL"));
if (winBorder->Level() == B_FLOATING_APP)
{
// floating windows are automaticaly added when needed
@ -180,7 +180,7 @@ STRACE(("W(%ld)::AddWinBorder(%s)\n", fID, winBorder?winBorder->GetName():"NULL"
*/
void Workspace::RemoveWinBorder(WinBorder *winBorder)
{
STRACE(("W(%ld)::RemoveWinBorder(%s)\n", fID, winBorder?winBorder->GetName():"NULL"));
STRACE(("W(%ld)::RemoveWinBorder(%s)\n", fID, winBorder?winBorder->Name():"NULL"));
ListData *item = HasItem(winBorder);
if (item)
{
@ -272,7 +272,7 @@ window will be shown in front.
*/
bool Workspace::MoveToFront(WinBorder *newFront, bool doNotDisturb)
{
STRACE(("\nWks(%ld)::MoveToFront ~%s~ \n", fID, newFront?newFront->GetName():"NULL"));
STRACE(("\nWks(%ld)::MoveToFront ~%s~ \n", fID, newFront?newFront->Name():"NULL"));
if (!newFront)
return false;
@ -313,7 +313,7 @@ B_NORMAL window in front of which they appear.
*/
bool Workspace::MoveToBack(WinBorder *newLast)
{
STRACE(("Wks(%ld)::MoveToBack(%s) \n", fID, newLast? newLast->GetName(): "NULL"));
STRACE(("Wks(%ld)::MoveToBack(%s) \n", fID, newLast? newLast->Name(): "NULL"));
if (newLast->IsHidden())
return false;
@ -478,7 +478,7 @@ chosen. Same goes for focus.
*/
bool Workspace::HideWinBorder(WinBorder *winBorder)
{
STRACE(("W(%ld)::HideWinBorder(%s) \n", fID, winBorder? winBorder->GetName(): "NULL"));
STRACE(("W(%ld)::HideWinBorder(%s) \n", fID, winBorder? winBorder->Name(): "NULL"));
bool returnValue = false;
int32 level = winBorder->Level();
bool changeFront = false;
@ -641,7 +641,7 @@ unless a modal windows steals both.
*/
bool Workspace::ShowWinBorder(WinBorder *winBorder, bool userBusy)
{
STRACE(("W(%ld)::ShowWinBorder(%s) \n", fID, winBorder? winBorder->GetName(): "NULL"));
STRACE(("W(%ld)::ShowWinBorder(%s) \n", fID, winBorder? winBorder->Name(): "NULL"));
bool returnValue = false;
int32 level = winBorder->Level();
if (level > B_SYSTEM_FIRST)
@ -1151,7 +1151,7 @@ void Workspace::PutDefaultSettings(BMessage *msg, const uint8 &index)
// Just in case...
msg->RemoveName(fieldname);
msg->AddMessage(fieldname,&container);
msg->AddMessage(fieldname, &container);
}
//----------------------------------------------------------------------------------
@ -1162,7 +1162,7 @@ void Workspace::PrintToStream() const
for (ListData *item = fTopItem; item != NULL; item = item->lowerItem)
{
WinBorder *wb = (WinBorder*)item->layerPtr;
printf("\tName: %s\t%s", wb->GetName(), wb->IsHidden()?"Hidden\t": "Visible\t");
printf("\tName: %s\t%s", wb->Name(), wb->IsHidden()?"Hidden\t": "Visible\t");
if(wb->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL)
printf("\t%s\n", "B_FLOATING_SUBSET_WINDOW_FEEL");
if(wb->Feel() == B_FLOATING_APP_WINDOW_FEEL)
@ -1183,8 +1183,8 @@ void Workspace::PrintToStream() const
printf("\t%s\n", "B_SYSTEM_FIRST");
}
printf("Focus Layer:\t%s\n", fFocusItem? fFocusItem->layerPtr->GetName(): "NULL");
printf("Front Layer:\t%s\n\n", fFrontItem? fFrontItem->layerPtr->GetName(): "NULL");
printf("Focus Layer:\t%s\n", fFocusItem? fFocusItem->layerPtr->Name(): "NULL");
printf("Front Layer:\t%s\n\n", fFrontItem? fFrontItem->layerPtr->Name(): "NULL");
}
//----------------------------------------------------------------------------------
@ -1194,9 +1194,9 @@ 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");
printf("WinBorder:\t%s\n", item->layerPtr? item->layerPtr->Name(): "NULL");
printf("UpperItem:\t%s\n", item->upperItem? item->upperItem->layerPtr->Name(): "NULL");
printf("LowerItem:\t%s\n", item->lowerItem? item->lowerItem->layerPtr->Name(): "NULL");
}
else
{