*** empty log message ***

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8000 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca
2004-06-16 06:40:26 +00:00
parent 10937f43ff
commit d754f1a3d6
6 changed files with 330 additions and 472 deletions
+172 -294
View File
@@ -14,7 +14,7 @@
#include "LayerData.h" #include "LayerData.h"
#include <stdio.h> #include <stdio.h>
//#define DEBUG_LAYER #define DEBUG_LAYER
#ifdef DEBUG_LAYER #ifdef DEBUG_LAYER
# define STRACE(x) printf x # define STRACE(x) printf x
#else #else
@@ -32,15 +32,6 @@ BRegion gRedrawReg;
BList gCopyRegList; BList gCopyRegList;
BList gCopyList; BList gCopyList;
enum
{
B_LAYER_NONE = 0x00001000UL,
B_LAYER_MOVE = 0x00002000UL,
B_LAYER_SIMPLE_MOVE = 0x00004000UL,
B_LAYER_RESIZE = 0x00008000UL,
B_LAYER_MASK_RESIZE = 0x00010000UL,
};
Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize, Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize,
uint32 flags, DisplayDriver *driver) uint32 flags, DisplayDriver *driver)
{ {
@@ -62,24 +53,25 @@ Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize,
fDriver = driver; fDriver = driver;
// Layer does not start out as a part of the tree // Layer does not start out as a part of the tree
fParent = NULL; fParent = NULL;
fUpperSibling = NULL; fUpperSibling = NULL;
fLowerSibling = NULL; fLowerSibling = NULL;
fTopChild = NULL; fTopChild = NULL;
fBottomChild = NULL; fBottomChild = NULL;
fCurrent = NULL; fCurrent = NULL;
fRootLayer = NULL; fRootLayer = NULL;
fFlags = flags; fFlags = flags;
fResizeMode = resize; fAdFlags = 0;
fHidden = false; fResizeMode = resize;
fHidden = false;
fIsUpdating = false; fIsUpdating = false;
fIsTopLayer = false; fIsTopLayer = false;
fLevel = 0; fLevel = 0;
fViewToken = token; fViewToken = token;
fServerWin = NULL; fServerWin = NULL;
clipToPicture = NULL; clipToPicture = NULL;
@@ -117,7 +109,7 @@ Layer::~Layer(void)
} }
} }
void Layer::AddChild(Layer *layer, RootLayer *rootLayer) void Layer::AddChild(Layer *layer, ServerWindow *serverWin)
{ {
STRACE(("Layer(%s)::AddChild(%s) START\n", GetName(), layer->GetName())); STRACE(("Layer(%s)::AddChild(%s) START\n", GetName(), layer->GetName()));
@@ -127,7 +119,7 @@ void Layer::AddChild(Layer *layer, RootLayer *rootLayer)
return; return;
} }
// attach layer to the tree structure // 1) attach layer to the tree structure
layer->fParent = this; layer->fParent = this;
if( fBottomChild ) if( fBottomChild )
{ {
@@ -140,66 +132,49 @@ void Layer::AddChild(Layer *layer, RootLayer *rootLayer)
} }
fBottomChild = layer; fBottomChild = layer;
layer->SetRootLayer(fRootLayer); // if no RootLayer, there is no need to set any parameters.
// they will be set when the root Layer for this tree will be added
// to the main tree structure.
if (fRootLayer == NULL)
return;
// higher level objects like RootLayers do not have ServerWindow objects attached // 2) set some fields for this new layer and its children.
// This is in case o a WinBorder object which already has a valid fServerWin member. Layer *c = layer; //c = short for: current
if(!(layer->fServerWin)) Layer *stop = layer;
layer->SetServerWindow(this->SearchForServerWindow()); while( true ){
// action block
layer->RebuildFullRegion();
//c = short for: current
Layer *c = layer->fTopChild;
Layer *stop = layer;
if( c != NULL )
{
while( true )
{ {
// action block // 2.1) set the RootLayer for this object.
{ c->SetRootLayer(c->fParent->fRootLayer);
c->SetRootLayer(fRootLayer); // 2.2) this Layer must know if it has a ServerWindow object attached.
c->SetServerWindow(c->SearchForServerWindow()); c->SetServerWindow(serverWin);//c->fParent->fServerWin);
c->RebuildFullRegion(); // 2.3) we are attached to the main tree so build our full region.
c->RebuildFullRegion();
}
// tree parsing algorithm
if( c->fTopChild ){ // go deep
c = c->fTopChild;
}
else{ // go right or up
if (c == stop) // out trip is over
break;
if( c->fLowerSibling ){ // go right
c = c->fLowerSibling;
} }
else{ // go up
while( !c->fParent->fLowerSibling && c->fParent != stop )
c = c->fParent;
// tree parsing algorithm if( c->fParent == stop ) // that enough!
break;
// go deep c = c->fParent->fLowerSibling;
if( c->fTopChild )
{
c = c->fTopChild;
}
else
{
// go right or up
if( c->fLowerSibling )
{
// go right
c = c->fLowerSibling;
}
else
{
// go up
while( !c->fParent->fLowerSibling && c->fParent != stop )
c = c->fParent;
// that enough! We've reached this view.
if( c->fParent == stop )
break;
c = c->fParent->fLowerSibling;
}
} }
} }
} }
if ( !(layer->IsHidden()) && layer->fRootLayer && !IsHidden()) STRACE(("Layer(%s)::AddChild(%s) END\n", GetName(), layer->GetName()));
FullInvalidate( layer->fFull );
STRACE(("Layer(%s)::AddChild(%s) END\n", GetName(), layer->GetName()));
} }
void Layer::RemoveChild(Layer *layer) void Layer::RemoveChild(Layer *layer)
@@ -218,87 +193,63 @@ void Layer::RemoveChild(Layer *layer)
return; return;
} }
// 1) remove this layer the main tree.
// Take care of fParent // Take care of fParent
layer->fParent = NULL; layer->fParent = NULL;
if( fTopChild == layer ) if( fTopChild == layer )
fTopChild = layer->fLowerSibling; fTopChild = layer->fLowerSibling;
if( fBottomChild == layer ) if( fBottomChild == layer )
fBottomChild = layer->fUpperSibling; fBottomChild = layer->fUpperSibling;
// Take care of siblings // Take care of siblings
if( layer->fUpperSibling != NULL ) if( layer->fUpperSibling != NULL )
layer->fUpperSibling->fLowerSibling = layer->fLowerSibling; layer->fUpperSibling->fLowerSibling = layer->fLowerSibling;
if( layer->fLowerSibling != NULL ) if( layer->fLowerSibling != NULL )
layer->fLowerSibling->fUpperSibling = layer->fUpperSibling; layer->fLowerSibling->fUpperSibling = layer->fUpperSibling;
layer->fUpperSibling = NULL;
layer->fLowerSibling = NULL;
layer->fUpperSibling = NULL; // 2) clear some fields for this layer and its children.
layer->fLowerSibling = NULL; Layer *c = layer; //c = short for: current
Layer *stop = layer;
//c = short for: current while( true ){
Layer *c = layer->fTopChild; // action block
Layer *stop = layer;
if( c != NULL )
{
while( true )
{ {
// action block // 2.1) set the RootLayer for this object.
{ c->SetRootLayer(NULL);
c->SetRootLayer(NULL); // 2.2) this Layer must know if it has a ServerWindow object attached.
c->SetServerWindow(NULL); c->SetServerWindow(NULL);
c->fFull.MakeEmpty(); // 2.3) we were removed from the main tree so clear our full region.
c->fFullVisible.MakeEmpty(); c->fFull.MakeEmpty();
c->fVisible.MakeEmpty(); // 2.4) clear fullVisible region.
c->fFullVisible.MakeEmpty();
// 2.5) we don't have a visible region anymore.
c->fVisible.MakeEmpty();
}
// tree parsing algorithm
if( c->fTopChild ){ // go deep
c = c->fTopChild;
}
else{ // go right or up
if (c == stop) // out trip is over
break;
if( c->fLowerSibling ){ // go right
c = c->fLowerSibling;
} }
else{ // go up
while( !c->fParent->fLowerSibling && c->fParent != stop )
c = c->fParent;
// tree parsing algorithm if( c->fParent == stop ) // that enough!
break;
if( c->fTopChild ) c = c->fParent->fLowerSibling;
{
// go deep
c = c->fTopChild;
}
else
{
// go right or up
if( c->fLowerSibling )
{
// go right
c = c->fLowerSibling;
}
else
{
// go up
while( !c->fParent->fLowerSibling && c->fParent != stop )
c = c->fParent;
// that's enough! We've reached this view.
if( c->fParent == stop )
break;
c = c->fParent->fLowerSibling;
}
} }
} }
} }
STRACE(("Layer(%s)::RemoveChild(%s) END\n", GetName(), layer->GetName()));
if ( !(layer->IsHidden()) && layer->fRootLayer)
{
PrintTree();
FullInvalidate( layer->fFullVisible );
}
layer->fRootLayer = NULL;
layer->fServerWin = NULL;
layer->fFull.MakeEmpty();
layer->fFullVisible.MakeEmpty();
layer->fVisible.MakeEmpty();
STRACE(("Layer(%s)::RemoveChild(%s) END\n", GetName(), layer->GetName()));
} }
void Layer::RemoveSelf() void Layer::RemoveSelf()
@@ -455,113 +406,69 @@ void Layer::Invalidate(const BRegion& region)
void Layer::Redraw(const BRegion& reg, Layer *startFrom) void Layer::Redraw(const BRegion& reg, Layer *startFrom)
{ {
STRACE(("Layer(%s)::Redraw();\n", GetName())); STRACE(("Layer(%s)::Redraw();\n", GetName()));
if (IsHidden())
// this layer has nothing visible on screen, so bail out.
return;
BRegion *pReg = const_cast<BRegion*>(&reg); BRegion *pReg = const_cast<BRegion*>(&reg);
if(fServerWin) if (pReg->CountRects() > 0)
{ RequestDraw(reg, startFrom);
if (pReg->CountRects() > 0)
RequestClientUpdate(reg, startFrom);
}
else
{
// call Draw() for all server layers
if (pReg->CountRects() > 0)
RequestDraw(reg, startFrom);
}
STRACE(("Layer::Redraw ENDED\n")); STRACE(("Layer::Redraw ENDED\n"));
} }
void Layer::RequestClientUpdate(const BRegion &reg, Layer *startFrom) void Layer::RequestDraw(const BRegion &reg, Layer *startFrom)
{ {
STRACE(("Layer(%s)::RequestClientUpdate()\n", GetName())); STRACE(("Layer(%s)::RequestDraw()\n", GetName()));
if (IsHidden()) int redraw = false;
{
// this layer has nothing visible on screen, so bail out. if (startFrom == NULL)
return; redraw = true;
}
// TODO: remove
if (fVisible.CountRects() > 0) if (fVisible.CountRects() > 0)
{ {
fUpdateReg = fVisible; fUpdateReg = fVisible;
fUpdateReg.IntersectWith(&reg); fUpdateReg.IntersectWith(&reg);
// NOTE: CLEAR to the background color! if (fUpdateReg.CountRects() > 0){
if (fServerWin){
// clear background, *only IF* our view color is different to B_TRANSPARENT_COLOR!
// TODO: DO That!
// TODO: UNcomment!!!
// TODO !!! UPDATE code !!!
/*
BMessage msg;
msg.what = _UPDATE_;
msg.AddInt32("_token", fViewToken);
msg.AddRect("_rect", ConvertFromTop(reg.Frame()) );
// draw itself. // for test purposes only!
if (fUpdateReg.CountRects() > 0) msg.AddRect("_rect2", reg.Frame());
{
fDriver->ConstrainClippingRegion(&fUpdateReg);
Draw(fUpdateReg.Frame());
fDriver->ConstrainClippingRegion(NULL);
}
fUpdateReg.MakeEmpty(); fServerWin->SendMessageToClient( &msg );
} */
return; }
else{
// NOTE: do not clear background for internal server layers!
fDriver->ConstrainClippingRegion(&fUpdateReg);
Draw(fUpdateReg.Frame());
fDriver->ConstrainClippingRegion(NULL);
fUpdateReg.MakeEmpty();
// TODO: use startFrom
// TODO: Do that! here? or after a message sent by the client just before calling BView::Draw(r)
// clear the area in the low color
// only the visible area is cleared, because DisplayDriver does the clipping to it.
// draw background, *only IF* our view color is different to B_TRANSPARENT_COLOR!
BMessage msg;
msg.what = _UPDATE_;
msg.AddInt32("_token", fViewToken);
msg.AddRect("_rect", ConvertFromTop(reg.Frame()) );
// for test purposes only!
msg.AddRect("_rect2", reg.Frame());
fServerWin->SendMessageToClient( &msg );
}
void Layer::RequestDraw(const BRegion &reg, Layer *startFrom, bool redraw)
{
STRACE(("Layer(%s)::RequestDraw()\n", GetName()));
if (fVisible.CountRects() > 0 && !IsHidden())
{
fUpdateReg = fVisible;
fUpdateReg.IntersectWith(&reg);
// NOTE: do not clear background for internal server layers!
// draw itself.
if (fUpdateReg.CountRects() > 0)
{
fDriver->ConstrainClippingRegion(&fUpdateReg);
Draw(fUpdateReg.Frame());
fDriver->ConstrainClippingRegion(NULL);
}
fUpdateReg.MakeEmpty();
}
// tell children to draw. YES, it's OK - if we're hidden don't tell children to draw
if (!IsHidden())
{
for (Layer *lay = VirtualBottomChild(); lay != NULL; lay = VirtualUpperSibling())
{
if (!redraw && startFrom && lay == startFrom)
redraw = true;
if ((startFrom && redraw) || !startFrom)
{
if ( !(lay->IsHidden()) )
lay->RequestDraw( reg, startFrom, redraw );
} }
} }
} }
for (Layer *lay = VirtualBottomChild(); lay != NULL; lay = VirtualUpperSibling())
{
if (lay == startFrom)
redraw = true;
if (redraw && !(lay->IsHidden()))
lay->RequestDraw(reg, NULL);
}
} }
void Layer::Draw(const BRect &r) void Layer::Draw(const BRect &r)
@@ -590,9 +497,9 @@ void Layer::Show(bool invalidate)
if(invalidate) if(invalidate)
{ {
if(fParent) if(fParent)
fParent->FullInvalidate(fFull); fParent->FullInvalidate( BRegion(fFull) );
else else
FullInvalidate( fFull ); FullInvalidate( BRegion(fFull) );
} }
} }
@@ -604,60 +511,13 @@ void Layer::Hide(bool invalidate)
fHidden = true; fHidden = true;
//c = short for: current
Layer *c = fTopChild;
Layer *stop = this;
if( c != NULL )
{
while(1)
{
// action block
{
c->fFullVisible.MakeEmpty();
c->fVisible.MakeEmpty();
}
// tree parsing algorithm
if( c->fTopChild )
{
// go deep
c = c->fTopChild;
}
else
{
// go right or up
if( c->fLowerSibling )
{
// go right
c = c->fLowerSibling;
}
else
{
// go up
while( !c->fParent->fLowerSibling && c->fParent != stop )
c = c->fParent;
// that's enough! We've reached this view.
if( c->fParent == stop )
break;
c = c->fParent->fLowerSibling;
}
}
}
}
if(invalidate) if(invalidate)
{ {
if(fParent) if(fParent)
fParent->FullInvalidate( fFullVisible ); fParent->FullInvalidate( BRegion(fFullVisible) );
else else
FullInvalidate( fFullVisible ); FullInvalidate( BRegion(fFullVisible) );
} }
fFullVisible.MakeEmpty();
fVisible.MakeEmpty();
} }
bool Layer::IsHidden(void) const bool Layer::IsHidden(void) const
@@ -694,6 +554,7 @@ void Layer::RebuildFullRegion( )
else else
fFull.Set( fFrame ); fFull.Set( fFrame );
// TODO: restrict to screen coordinates!!!
// TODO: Convert to screen coordinates! // TODO: Convert to screen coordinates!
LayerData *ld; LayerData *ld;
ld = fLayerData; ld = fLayerData;
@@ -712,15 +573,6 @@ void Layer::RebuildFullRegion( )
else else
fFull.IntersectWith( clipToPicture ); fFull.IntersectWith( clipToPicture );
} }
if(IsTopLayer() && fServerWin)
{
if (fServerWin->fWinBorder->fDecorator)
{
// decorator overlapping topLayer? put decorator in front.
fFull.Exclude( fServerWin->fWinBorder->fDecFull );
}
}
} }
void Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOffset) void Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOffset)
@@ -840,14 +692,39 @@ void Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint
if (!IsHidden()) if (!IsHidden())
{ {
fFullVisible.MakeEmpty();
fVisible = fFull; fVisible = fFull;
if (fParent) if (fParent && fVisible.CountRects() >0){
{ // not the usual case, but support fot this is needed.
fVisible.IntersectWith( &(fParent->fVisible) ); if (fParent->fAdFlags & B_LAYER_CHILDREN_DEPENDANT){
// because we're skipping one level, we need to do out
// parent business as well.
// exclude from parent's visible area. // our visible area is relative to our parent's parent.
if ( !IsHidden() && fVisible.CountRects() > 0) if (fParent->fParent)
fParent->fVisible.Exclude( &(fVisible) ); fVisible.IntersectWith(&(fParent->fParent->fVisible));
// exclude parent's visible area which could be composed by
// prior siblings' visible areas.
if (fVisible.CountRects() > 0)
fVisible.Exclude(&(fParent->fVisible));
// we have a final visible area. Include it to our parent's one,
// exclude from parent's parent.
if (fVisible.CountRects() > 0){
fParent->fFullVisible.Include(&fVisible);
if (fParent->fParent)
fParent->fParent->fVisible.Exclude(&fVisible);
}
}
// for 95+% of cases
else{
// the visible area is the one common with parent's one.
fVisible.IntersectWith(&(fParent->fVisible));
// exclude from parent's visible area. we're the owners now.
if (fVisible.CountRects() > 0)
fParent->fVisible.Exclude(&fVisible);
}
} }
fFullVisible = fVisible; fFullVisible = fVisible;
} }
@@ -1002,7 +879,8 @@ void Layer::StartRebuildRegions( const BRegion& reg, Layer *target, uint32 actio
if (oldVisible.CountRects() > 0) if (oldVisible.CountRects() > 0)
redrawReg.Exclude(&oldVisible); redrawReg.Exclude(&oldVisible);
gRedrawReg.Include(&redrawReg); if (redrawReg.CountRects() > 0)
gRedrawReg.Include(&redrawReg);
#ifdef DEBUG_LAYER_REBUILD #ifdef DEBUG_LAYER_REBUILD
printf("Layer(%s)::StartRebuildREgions() ended! Redraw Region:\n", GetName()); printf("Layer(%s)::StartRebuildREgions() ended! Redraw Region:\n", GetName());
+15 -3
View File
@@ -10,6 +10,17 @@
#include <Locker.h> #include <Locker.h>
#include "RGBColor.h" #include "RGBColor.h"
enum
{
B_LAYER_NONE = 0x00001000UL,
B_LAYER_MOVE = 0x00002000UL,
B_LAYER_SIMPLE_MOVE = 0x00004000UL,
B_LAYER_RESIZE = 0x00008000UL,
B_LAYER_MASK_RESIZE = 0x00010000UL,
B_LAYER_CHILDREN_DEPENDANT = 0x10000000UL,
};
class ServerWindow; class ServerWindow;
class RootLayer; class RootLayer;
class DisplayDriver; class DisplayDriver;
@@ -22,7 +33,7 @@ public:
uint32 flags, DisplayDriver *driver); uint32 flags, DisplayDriver *driver);
virtual ~Layer(void); virtual ~Layer(void);
void AddChild(Layer *child, RootLayer *rootLayer = NULL); void AddChild(Layer *child, ServerWindow *serverWin);
void RemoveChild(Layer *child); void RemoveChild(Layer *child);
void RemoveSelf(void); void RemoveSelf(void);
bool HasChild(Layer *layer); bool HasChild(Layer *layer);
@@ -78,6 +89,7 @@ public:
BRect ConvertFromTop(BRect rect); BRect ConvertFromTop(BRect rect);
DisplayDriver *GetDisplayDriver(void) const { return fDriver; } DisplayDriver *GetDisplayDriver(void) const { return fDriver; }
ServerWindow *Window(void) const { return fServerWin; }
void PruneTree(void); void PruneTree(void);
@@ -126,6 +138,7 @@ protected:
bool fHidden; bool fHidden;
bool fIsUpdating; bool fIsUpdating;
bool fIsTopLayer; bool fIsTopLayer;
uint16 fAdFlags;
DisplayDriver *fDriver; DisplayDriver *fDriver;
LayerData *fLayerData; LayerData *fLayerData;
@@ -134,8 +147,7 @@ protected:
RootLayer *fRootLayer; RootLayer *fRootLayer;
private: private:
void RequestClientUpdate(const BRegion &reg, Layer *startFrom); void RequestDraw(const BRegion &reg, Layer *startFrom);
void RequestDraw(const BRegion &reg, Layer *startFrom, bool redraw=false);
ServerWindow *SearchForServerWindow(void) const; ServerWindow *SearchForServerWindow(void) const;
}; };
+13 -3
View File
@@ -225,13 +225,14 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
winBorder->Window()->QuietlySetWorkspaces(0x00000001 << (ActiveWorkspaceIndex()-1)); winBorder->Window()->QuietlySetWorkspaces(0x00000001 << (ActiveWorkspaceIndex()-1));
// add winBorder to the known list of WinBorders so we can keep track of it. // add winBorder to the known list of WinBorders so we can keep track of it.
AddChild(winBorder, this); AddChild(winBorder, winBorder->Window());
// add winBorder to the desired workspaces // add winBorder to the desired workspaces
switch(winBorder->Window()->Feel()) switch(winBorder->Window()->Feel())
{ {
case B_MODAL_SUBSET_WINDOW_FEEL: case B_MODAL_SUBSET_WINDOW_FEEL:
{ {
printf("XXXXXXXX1: 21\n");
// this kind of window isn't added anywhere. It will be added // this kind of window isn't added anywhere. It will be added
// to main window's subset when winBorder::AddToSubsetOf(main) // to main window's subset when winBorder::AddToSubsetOf(main)
// will be called. // will be called.
@@ -239,6 +240,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
} }
case B_MODAL_APP_WINDOW_FEEL: case B_MODAL_APP_WINDOW_FEEL:
{ {
printf("XXXXXXXX1: 22\n");
// add to app's list of Floating/Modal windows (as opposed to the system's) // add to app's list of Floating/Modal windows (as opposed to the system's)
winBorder->Window()->App()->fAppFMWList.AddItem(winBorder); winBorder->Window()->App()->fAppFMWList.AddItem(winBorder);
@@ -267,6 +269,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
case B_MODAL_ALL_WINDOW_FEEL: case B_MODAL_ALL_WINDOW_FEEL:
{ {
printf("XXXXXXXX1: 23\n");
// add to system's list of Floating/Modal Windows (as opposed to the app's list) // add to system's list of Floating/Modal Windows (as opposed to the app's list)
fMainFMWList.AddItem(winBorder); fMainFMWList.AddItem(winBorder);
@@ -277,6 +280,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
case B_FLOATING_SUBSET_WINDOW_FEEL: case B_FLOATING_SUBSET_WINDOW_FEEL:
{ {
printf("XXXXXXXX1: 24\n");
// this kind of window isn't added anywhere. It *will* be added to WS's list // this kind of window isn't added anywhere. It *will* be added to WS's list
// when its main window will become the front one. // when its main window will become the front one.
// Also, it will be added to MainWinBorder's list when // Also, it will be added to MainWinBorder's list when
@@ -286,6 +290,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
case B_FLOATING_APP_WINDOW_FEEL: case B_FLOATING_APP_WINDOW_FEEL:
{ {
printf("XXXXXXXX1: 25\n");
// add to app's list of Floating/Modal windows (as opposed to the system's) // add to app's list of Floating/Modal windows (as opposed to the system's)
winBorder->Window()->App()->fAppFMWList.AddItem(winBorder); winBorder->Window()->App()->fAppFMWList.AddItem(winBorder);
@@ -304,6 +309,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
case B_FLOATING_ALL_WINDOW_FEEL: case B_FLOATING_ALL_WINDOW_FEEL:
{ {
printf("XXXXXXXX1: 26\n");
// add to system's list of Floating/Modal Windows (as opposed to the app's list) // add to system's list of Floating/Modal Windows (as opposed to the app's list)
fMainFMWList.AddItem(winBorder); fMainFMWList.AddItem(winBorder);
@@ -314,6 +320,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
case B_NORMAL_WINDOW_FEEL: case B_NORMAL_WINDOW_FEEL:
{ {
printf("XXXXXXXX1: 27\n");
// add this winBorder to the specified workspaces // add this winBorder to the specified workspaces
AddWinBorderToWorkspaces(winBorder, winBorder->Window()->Workspaces()); AddWinBorderToWorkspaces(winBorder, winBorder->Window()->Workspaces());
break; break;
@@ -321,14 +328,17 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
case B_SYSTEM_LAST: case B_SYSTEM_LAST:
case B_SYSTEM_FIRST: case B_SYSTEM_FIRST:
{ {
printf("XXXXXXXX1: 28\n");
// add this winBorder to all workspaces // add this winBorder to all workspaces
AddWinBorderToWorkspaces(winBorder, 0xffffffffUL); AddWinBorderToWorkspaces(winBorder, 0xffffffffUL);
break; break;
} }
default: default:{
printf("XXXXXXXX1: 29\n");
break; break;
}
} // end switch(winborder->Feel()) } // end switch(winborder->Feel())
printf("XXXXXXXX1: 4\n");
fMainLock.Unlock(); fMainLock.Unlock();
STRACE(("*RootLayer::AddWinBorder(%s) - Main lock released\n", winBorder->GetName())); STRACE(("*RootLayer::AddWinBorder(%s) - Main lock released\n", winBorder->GetName()));
+97 -79
View File
@@ -49,7 +49,7 @@
#include "CursorManager.h" #include "CursorManager.h"
#include "Workspace.h" #include "Workspace.h"
//#define DEBUG_SERVERWINDOW #define DEBUG_SERVERWINDOW
//#define DEBUG_SERVERWINDOW_MOUSE //#define DEBUG_SERVERWINDOW_MOUSE
//#define DEBUG_SERVERWINDOW_KEYBOARD //#define DEBUG_SERVERWINDOW_KEYBOARD
@@ -174,9 +174,6 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
fTopLayer->SetAsTopLayer(true); fTopLayer->SetAsTopLayer(true);
cl = fTopLayer; cl = fTopLayer;
fWinBorder = new WinBorder( fFrame, fTitle.String(),wlook, wfeel, wflags,
this, desktop->GetDisplayDriver());
STRACE(("ServerWindow %s:\n",fTitle.String())); STRACE(("ServerWindow %s:\n",fTitle.String()));
STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom)); STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom));
STRACE(("\tPort: %ld\n",fMessagePort)); STRACE(("\tPort: %ld\n",fMessagePort));
@@ -185,7 +182,12 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
void ServerWindow::Init(void) void ServerWindow::Init(void)
{ {
fWinBorder->AddChild(fTopLayer); fWinBorder = new WinBorder( fFrame, fTitle.String(), fLook, fFeel, fFlags,
this, desktop->GetDisplayDriver());
fWinBorder->RebuildFullRegion();
// connect decorator and top layer.
fWinBorder->AddChild(fTopLayer, NULL);
// NOTE: this MUST be before the monitor thread is spawned! // NOTE: this MUST be before the monitor thread is spawned!
desktop->AddWinBorder(fWinBorder); desktop->AddWinBorder(fWinBorder);
@@ -632,7 +634,7 @@ void ServerWindow::SetLayerFontState(Layer *layer)
layer->fLayerData->font.SetFlags(flags); layer->fLayerData->font.SetFlags(flags);
} }
STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer: %s\n", STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer: %s\n",
fTitle.String(), layer->_name->String())); fTitle.String(), layer->fName->String()));
} }
void ServerWindow::SetLayerState(Layer *layer) void ServerWindow::SetLayerState(Layer *layer)
@@ -687,7 +689,7 @@ void ServerWindow::SetLayerState(Layer *layer)
} }
} }
STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_STATE: Layer: %s\n",fTitle.String(), STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_STATE: Layer: %s\n",fTitle.String(),
layer->_name->String())); layer->fName->String()));
} }
Layer * ServerWindow::CreateLayerTree(Layer *localRoot) Layer * ServerWindow::CreateLayerTree(Layer *localRoot)
@@ -736,7 +738,7 @@ Layer * ServerWindow::CreateLayerTree(Layer *localRoot)
// add the new Layer to the tree structure. // add the new Layer to the tree structure.
if(localRoot) if(localRoot)
localRoot->AddChild(newLayer); localRoot->AddChild(newLayer, NULL);
// attach newLayer's children... // attach newLayer's children...
for(int i = 0; i < childCount; i++) for(int i = 0; i < childCount; i++)
@@ -748,7 +750,7 @@ Layer * ServerWindow::CreateLayerTree(Layer *localRoot)
debugger("ServerWindow(%s) - AS_LAYER_CREATE Expected!\n"); debugger("ServerWindow(%s) - AS_LAYER_CREATE Expected!\n");
} }
STRACE(("DONE: ServerWindow %s: Message AS_CREATE_LAYER: Parent: %s, Child: %s\n", fTitle.String(), STRACE(("DONE: ServerWindow %s: Message AS_CREATE_LAYER: Parent: %s, Child: %s\n", fTitle.String(),
newLayer->_name->String(), name)); localRoot? localRoot->fName->String(): "NULL", newLayer->fName->String()));
return newLayer; return newLayer;
} }
@@ -854,6 +856,7 @@ void ServerWindow::DispatchMessage(int32 code)
} }
case AS_SET_CURRENT_LAYER: case AS_SET_CURRENT_LAYER:
{ {
STRACE(("ServerWindow %s: Message AS_SET_CURRENT_LAYER: Layer name: %s\n", fTitle.String(), cl->fName->String()));
int32 token; int32 token;
fSession->ReadInt32(&token); fSession->ReadInt32(&token);
@@ -864,13 +867,21 @@ void ServerWindow::DispatchMessage(int32 code)
cl=current; cl=current;
else // hope this NEVER happens! :-) else // hope this NEVER happens! :-)
debugger("Server PANIC: window cannot find Layer with ID\n"); debugger("Server PANIC: window cannot find Layer with ID\n");
STRACE(("ServerWindow %s: Message AS_SET_CURRENT_LAYER: Layer name: %s\n", fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_CREATE: case AS_LAYER_CREATE:
{ {
CreateLayerTree(cl); STRACE(("ServerWindow %s: Message AS_LAYER_CREATE: Layer name: %s\n", fTitle.String(), cl->fName->String()));
Layer *newLayer;
newLayer = CreateLayerTree(NULL);
cl->AddChild(newLayer, this);
if (!(newLayer->IsHidden())){
// cl is the parent of newLayer, so this call is OK.
cl->FullInvalidate(newLayer->fFull.Frame());
}
break; break;
} }
case AS_LAYER_DELETE: case AS_LAYER_DELETE:
@@ -888,11 +899,10 @@ void ServerWindow::DispatchMessage(int32 code)
cl->RemoveSelf(); cl->RemoveSelf();
// TODO: invalidate the region occupied by this view. // TODO: invalidate the region occupied by this view.
// Should be done in Layer::RemoveChild() though
cl->PruneTree(); cl->PruneTree();
parent->PrintTree(); parent->PrintTree();
STRACE(("DONE: ServerWindow %s: Message AS_DELETE_LAYER: Parent: %s Layer: %s\n", fTitle.String(), parent->_name->String(), cl->_name->String())); STRACE(("DONE: ServerWindow %s: Message AS_DELETE_LAYER: Parent: %s Layer: %s\n", fTitle.String(), parent->fName->String(), cl->fName->String()));
delete cl; delete cl;
@@ -901,18 +911,21 @@ void ServerWindow::DispatchMessage(int32 code)
} }
case AS_LAYER_SET_STATE: case AS_LAYER_SET_STATE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_STATE: Layer name: %s\n", fTitle.String(), cl->fName->String()));
SetLayerState(cl); SetLayerState(cl);
cl->RebuildFullRegion(); cl->RebuildFullRegion();
break; break;
} }
case AS_LAYER_SET_FONT_STATE: case AS_LAYER_SET_FONT_STATE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer name: %s\n", fTitle.String(), cl->fName->String()));
SetLayerFontState(cl); SetLayerFontState(cl);
cl->RebuildFullRegion(); cl->RebuildFullRegion();
break; break;
} }
case AS_LAYER_GET_STATE: case AS_LAYER_GET_STATE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_STATE: Layer name: %s\n", fTitle.String(), cl->fName->String()));
LayerData *ld; LayerData *ld;
// these 4 are here because of a compiler warning. Maybe he's right... :-) // these 4 are here because of a compiler warning. Maybe he's right... :-)
@@ -965,12 +978,11 @@ void ServerWindow::DispatchMessage(int32 code)
fSession->WriteFloat(cl->fFrame.top); fSession->WriteFloat(cl->fFrame.top);
fSession->WriteRect(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop)); fSession->WriteRect(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop));
fSession->Sync(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_STATE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_MOVETO: case AS_LAYER_MOVETO:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_MOVETO: Layer name: %s\n", fTitle.String(), cl->fName->String()));
float x, y; float x, y;
fSession->ReadFloat(&x); fSession->ReadFloat(&x);
@@ -982,6 +994,7 @@ void ServerWindow::DispatchMessage(int32 code)
} }
case AS_LAYER_RESIZETO: case AS_LAYER_RESIZETO:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_RESIZETO: Layer name: %s\n", fTitle.String(), cl->fName->String()));
float newWidth, newHeight; float newWidth, newHeight;
fSession->ReadFloat(&newWidth); fSession->ReadFloat(&newWidth);
@@ -996,16 +1009,16 @@ void ServerWindow::DispatchMessage(int32 code)
} }
case AS_LAYER_GET_COORD: case AS_LAYER_GET_COORD:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->WriteFloat(cl->fFrame.left); fSession->WriteFloat(cl->fFrame.left);
fSession->WriteFloat(cl->fFrame.top); fSession->WriteFloat(cl->fFrame.top);
fSession->WriteRect(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop)); fSession->WriteRect(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop));
fSession->Sync(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_SET_ORIGIN: case AS_LAYER_SET_ORIGIN:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_ORIGIN: Layer: %s\n",fTitle.String(), cl->fName->String()));
float x, y; float x, y;
fSession->ReadFloat(&x); fSession->ReadFloat(&x);
@@ -1013,58 +1026,56 @@ void ServerWindow::DispatchMessage(int32 code)
cl->fLayerData->coordOrigin.Set(x, y); cl->fLayerData->coordOrigin.Set(x, y);
STRACE(("ServerWindow %s: Message AS_LAYER_SET_ORIGIN: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_GET_ORIGIN: case AS_LAYER_GET_ORIGIN:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->WritePoint(cl->fLayerData->coordOrigin); fSession->WritePoint(cl->fLayerData->coordOrigin);
fSession->Sync(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_RESIZE_MODE: case AS_LAYER_RESIZE_MODE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->ReadUInt32(&(cl->fResizeMode)); fSession->ReadUInt32(&(cl->fResizeMode));
STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_CURSOR: case AS_LAYER_CURSOR:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: Layer: %s\n",fTitle.String(), cl->fName->String()));
int32 token; int32 token;
fSession->ReadInt32(&token); fSession->ReadInt32(&token);
cursormanager->SetCursor(token); cursormanager->SetCursor(token);
STRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_SET_FLAGS: case AS_LAYER_SET_FLAGS:
{ {
fSession->ReadUInt32(&(cl->fFlags)); fSession->ReadUInt32(&(cl->fFlags));
STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: Layer: %s\n",fTitle.String(), cl->fName->String()));
break; break;
} }
case AS_LAYER_HIDE: case AS_LAYER_HIDE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_HIDE: Layer: %s\n",fTitle.String(), cl->fName->String()));
cl->Hide(); cl->Hide();
STRACE(("ServerWindow %s: Message AS_LAYER_HIDE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_SHOW: case AS_LAYER_SHOW:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SHOW: Layer: %s\n",fTitle.String(), cl->fName->String()));
cl->Show(); cl->Show();
STRACE(("ServerWindow %s: Message AS_LAYER_SHOW: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_SET_LINE_MODE: case AS_LAYER_SET_LINE_MODE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_LINE_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
int8 lineCap, lineJoin; int8 lineCap, lineJoin;
// TODO: DW: Shouldn't we lock before modifying certain memebers? // TODO: DW: Shouldn't we lock before modifying certain memebers?
@@ -1079,35 +1090,35 @@ void ServerWindow::DispatchMessage(int32 code)
cl->fLayerData->lineCap = (cap_mode)lineCap; cl->fLayerData->lineCap = (cap_mode)lineCap;
cl->fLayerData->lineJoin = (join_mode)lineJoin; cl->fLayerData->lineJoin = (join_mode)lineJoin;
STRACE(("ServerWindow %s: Message AS_LAYER_SET_LINE_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_GET_LINE_MODE: case AS_LAYER_GET_LINE_MODE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->WriteInt8((int8)(cl->fLayerData->lineCap)); fSession->WriteInt8((int8)(cl->fLayerData->lineCap));
fSession->WriteInt8((int8)(cl->fLayerData->lineJoin)); fSession->WriteInt8((int8)(cl->fLayerData->lineJoin));
fSession->WriteFloat(cl->fLayerData->miterLimit); fSession->WriteFloat(cl->fLayerData->miterLimit);
fSession->Sync(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_PUSH_STATE: case AS_LAYER_PUSH_STATE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: Layer: %s\n",fTitle.String(), cl->fName->String()));
LayerData *ld = new LayerData(); LayerData *ld = new LayerData();
ld->prevState = cl->fLayerData; ld->prevState = cl->fLayerData;
cl->fLayerData = ld; cl->fLayerData = ld;
cl->RebuildFullRegion(); cl->RebuildFullRegion();
STRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_POP_STATE: case AS_LAYER_POP_STATE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_POP_STATE: Layer: %s\n",fTitle.String(), cl->fName->String()));
if (!(cl->fLayerData->prevState)) if (!(cl->fLayerData->prevState))
{ {
STRACE(("WARNING: SW(%s): User called BView(%s)::PopState(), but there is NO state on stack!\n", fTitle.String(), cl->_name->String())); STRACE(("WARNING: SW(%s): User called BView(%s)::PopState(), but there is NO state on stack!\n", fTitle.String(), cl->fName->String()));
break; break;
} }
@@ -1117,19 +1128,20 @@ void ServerWindow::DispatchMessage(int32 code)
cl->RebuildFullRegion(); cl->RebuildFullRegion();
STRACE(("ServerWindow %s: Message AS_LAYER_POP_STATE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_SET_SCALE: case AS_LAYER_SET_SCALE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->ReadFloat(&(cl->fLayerData->scale)); fSession->ReadFloat(&(cl->fLayerData->scale));
STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_GET_SCALE: case AS_LAYER_GET_SCALE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_SCALE: Layer: %s\n",fTitle.String(), cl->fName->String()));
LayerData *ld = cl->fLayerData; LayerData *ld = cl->fLayerData;
float scale = ld->scale; float scale = ld->scale;
while((ld = ld->prevState)) while((ld = ld->prevState))
@@ -1138,11 +1150,11 @@ void ServerWindow::DispatchMessage(int32 code)
fSession->WriteFloat(scale); fSession->WriteFloat(scale);
fSession->Sync(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_SET_PEN_LOC: case AS_LAYER_SET_PEN_LOC:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->fName->String()));
float x, y; float x, y;
fSession->ReadFloat(&x); fSession->ReadFloat(&x);
@@ -1150,56 +1162,56 @@ void ServerWindow::DispatchMessage(int32 code)
cl->fLayerData->penlocation.Set(x, y); cl->fLayerData->penlocation.Set(x, y);
STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_GET_PEN_LOC: case AS_LAYER_GET_PEN_LOC:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->WritePoint(cl->fLayerData->penlocation); fSession->WritePoint(cl->fLayerData->penlocation);
fSession->Sync(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_SET_PEN_SIZE: case AS_LAYER_SET_PEN_SIZE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->ReadFloat(&(cl->fLayerData->pensize)); fSession->ReadFloat(&(cl->fLayerData->pensize));
STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_GET_PEN_SIZE: case AS_LAYER_GET_PEN_SIZE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->WriteFloat(cl->fLayerData->pensize); fSession->WriteFloat(cl->fLayerData->pensize);
fSession->Sync(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_SET_HIGH_COLOR: case AS_LAYER_SET_HIGH_COLOR:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_HIGH_COLOR: Layer: %s\n",fTitle.String(), cl->fName->String()));
rgb_color c; rgb_color c;
fSession->ReadData(&c, sizeof(rgb_color)); fSession->ReadData(&c, sizeof(rgb_color));
cl->fLayerData->highcolor.SetColor(c); cl->fLayerData->highcolor.SetColor(c);
STRACE(("ServerWindow %s: Message AS_LAYER_SET_HIGH_COLOR: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_SET_LOW_COLOR: case AS_LAYER_SET_LOW_COLOR:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_LOW_COLOR: Layer: %s\n",fTitle.String(), cl->fName->String()));
rgb_color c; rgb_color c;
fSession->ReadData(&c, sizeof(rgb_color)); fSession->ReadData(&c, sizeof(rgb_color));
cl->fLayerData->lowcolor.SetColor(c); cl->fLayerData->lowcolor.SetColor(c);
STRACE(("ServerWindow %s: Message AS_LAYER_SET_LOW_COLOR: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_SET_VIEW_COLOR: case AS_LAYER_SET_VIEW_COLOR:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_VIEW_COLOR: Layer: %s\n",fTitle.String(), cl->fName->String()));
rgb_color c; rgb_color c;
fSession->ReadData(&c, sizeof(rgb_color)); fSession->ReadData(&c, sizeof(rgb_color));
@@ -1208,11 +1220,11 @@ void ServerWindow::DispatchMessage(int32 code)
cl->Invalidate(cl->fVisible); cl->Invalidate(cl->fVisible);
STRACE(("ServerWindow %s: Message AS_LAYER_SET_VIEW_COLOR: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_GET_COLORS: case AS_LAYER_GET_COLORS:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n",fTitle.String(), cl->fName->String()));
rgb_color highColor, lowColor, viewColor; rgb_color highColor, lowColor, viewColor;
highColor = cl->fLayerData->highcolor.GetColor32(); highColor = cl->fLayerData->highcolor.GetColor32();
@@ -1224,11 +1236,11 @@ void ServerWindow::DispatchMessage(int32 code)
fSession->WriteData(&viewColor, sizeof(rgb_color)); fSession->WriteData(&viewColor, sizeof(rgb_color));
fSession->Sync(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_SET_BLEND_MODE: case AS_LAYER_SET_BLEND_MODE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
int8 srcAlpha, alphaFunc; int8 srcAlpha, alphaFunc;
fSession->ReadInt8(&srcAlpha); fSession->ReadInt8(&srcAlpha);
@@ -1237,46 +1249,47 @@ void ServerWindow::DispatchMessage(int32 code)
cl->fLayerData->alphaSrcMode = (source_alpha)srcAlpha; cl->fLayerData->alphaSrcMode = (source_alpha)srcAlpha;
cl->fLayerData->alphaFncMode = (alpha_function)alphaFunc; cl->fLayerData->alphaFncMode = (alpha_function)alphaFunc;
STRACE(("ServerWindow %s: Message AS_LAYER_SET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_GET_BLEND_MODE: case AS_LAYER_GET_BLEND_MODE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->WriteInt8((int8)(cl->fLayerData->alphaSrcMode)); fSession->WriteInt8((int8)(cl->fLayerData->alphaSrcMode));
fSession->WriteInt8((int8)(cl->fLayerData->alphaFncMode)); fSession->WriteInt8((int8)(cl->fLayerData->alphaFncMode));
fSession->Sync(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_SET_DRAW_MODE: case AS_LAYER_SET_DRAW_MODE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
int8 drawingMode; int8 drawingMode;
fSession->ReadInt8(&drawingMode); fSession->ReadInt8(&drawingMode);
cl->fLayerData->draw_mode = (drawing_mode)drawingMode; cl->fLayerData->draw_mode = (drawing_mode)drawingMode;
STRACE(("ServerWindow %s: Message AS_LAYER_SET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_GET_DRAW_MODE: case AS_LAYER_GET_DRAW_MODE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->WriteInt8((int8)(cl->fLayerData->draw_mode)); fSession->WriteInt8((int8)(cl->fLayerData->draw_mode));
fSession->Sync(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_PRINT_ALIASING: case AS_LAYER_PRINT_ALIASING:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->ReadBool(&(cl->fLayerData->fontAliasing)); fSession->ReadBool(&(cl->fLayerData->fontAliasing));
STRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_CLIP_TO_PICTURE: case AS_LAYER_CLIP_TO_PICTURE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",fTitle.String(), cl->fName->String()));
// TODO: watch out for the coordinate system // TODO: watch out for the coordinate system
int32 pictureToken; int32 pictureToken;
BPoint where; BPoint where;
@@ -1346,11 +1359,11 @@ void ServerWindow::DispatchMessage(int32 code)
if (redraw) if (redraw)
cl->Invalidate(reg); cl->Invalidate(reg);
STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_CLIP_TO_INVERSE_PICTURE: case AS_LAYER_CLIP_TO_INVERSE_PICTURE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",fTitle.String(), cl->fName->String()));
// TODO: watch out for the coordinate system // TODO: watch out for the coordinate system
int32 pictureToken; int32 pictureToken;
BPoint where; BPoint where;
@@ -1385,43 +1398,45 @@ void ServerWindow::DispatchMessage(int32 code)
cl->RebuildFullRegion(); cl->RebuildFullRegion();
//cl->RequestDraw(cl->clipToPicture->Frame()); //cl->RequestDraw(cl->clipToPicture->Frame());
} }
STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",fTitle.String(),
cl->_name->String()));
break; break;
} }
case AS_LAYER_GET_CLIP_REGION: case AS_LAYER_GET_CLIP_REGION:
{ {
// TODO: watch out for the coordinate system STRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->fName->String()));
BRegion reg; // if this Layer is hidden, it is clear that its visible region is void.
LayerData *ld; if (cl->IsHidden()){
int32 noOfRects; fSession->WriteInt32(0L);
fSession->Sync();
}
else{
// TODO: watch out for the coordinate system
BRegion reg;
LayerData *ld;
int32 noOfRects;
ld = cl->fLayerData; ld = cl->fLayerData;
reg = cl->ConvertFromParent(&(cl->fVisible)); reg = cl->ConvertFromParent(&(cl->fVisible));
if(ld->clipReg)
reg.IntersectWith(ld->clipReg);
while((ld = ld->prevState))
{
if(ld->clipReg) if(ld->clipReg)
reg.IntersectWith(ld->clipReg); reg.IntersectWith(ld->clipReg);
while((ld = ld->prevState))
{
if(ld->clipReg)
reg.IntersectWith(ld->clipReg);
}
noOfRects = reg.CountRects();
fSession->WriteInt32(noOfRects);
for(int i = 0; i < noOfRects; i++)
fSession->WriteRect(reg.RectAt(i));
} }
noOfRects = reg.CountRects();
fSession->WriteInt32(noOfRects);
for(int i = 0; i < noOfRects; i++)
fSession->WriteRect(reg.RectAt(i));
fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_SET_CLIP_REGION: case AS_LAYER_SET_CLIP_REGION:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->fName->String()));
// TODO: watch out for the coordinate system // TODO: watch out for the coordinate system
int32 noOfRects; int32 noOfRects;
BRect r; BRect r;
@@ -1440,26 +1455,31 @@ void ServerWindow::DispatchMessage(int32 code)
} }
cl->RebuildFullRegion(); cl->RebuildFullRegion();
// cl->RequestDraw(cl->clipToPicture->Frame()); if (!(cl->IsHidden()))
{
if (cl->fParent)
cl->fParent->FullInvalidate(BRegion(cl->fFull));
else
cl->FullInvalidate(BRegion(cl->fFull));
}
STRACE(("ServerWindow %s: Message AS_LAYER_SET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_INVAL_RECT: case AS_LAYER_INVAL_RECT:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->fName->String()));
// TODO: watch out for the coordinate system // TODO: watch out for the coordinate system
BRect invalRect; BRect invalRect;
fSession->ReadRect(&invalRect); fSession->ReadRect(&invalRect);
cl->Invalidate(invalRect); cl->Invalidate(invalRect);
//cl->RequestDraw(invalRect);
STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_INVAL_REGION: case AS_LAYER_INVAL_REGION:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->fName->String()));
// TODO: watch out for the coordinate system // TODO: watch out for the coordinate system
BRegion invalReg; BRegion invalReg;
int32 noOfRects; int32 noOfRects;
@@ -1474,9 +1494,7 @@ void ServerWindow::DispatchMessage(int32 code)
} }
cl->Invalidate(invalReg); cl->Invalidate(invalReg);
// cl->RequestDraw(invalReg.Frame());
STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
+8 -62
View File
@@ -91,7 +91,7 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
fKeyModifiers = 0; fKeyModifiers = 0;
fMainWinBorder = NULL; fMainWinBorder = NULL;
fDecorator = NULL; fDecorator = NULL;
fDecFull = NULL; fAdFlags = fAdFlags | B_LAYER_CHILDREN_DEPENDANT;
fIsMoving = false; fIsMoving = false;
fIsResizing = false; fIsResizing = false;
@@ -101,16 +101,9 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
fLastMousePosition.Set(-1,-1); fLastMousePosition.Set(-1,-1);
SetLevel(); SetLevel();
fNewTopLayerFrame = &(win->fTopLayer->fFrame);
if (feel!= B_NO_BORDER_WINDOW_LOOK) if (feel!= B_NO_BORDER_WINDOW_LOOK)
{
fDecorator = new_decorator(r, name, look, feel, flags, fDriver); fDecorator = new_decorator(r, name, look, feel, flags, fDriver);
fDecFull = new BRegion();
fDecorator->GetFootprint(fDecFull);
}
fFull.MakeEmpty();
STRACE(("WinBorder %s:\n",GetName())); STRACE(("WinBorder %s:\n",GetName()));
STRACE(("\tFrame: (%.1f,%.1f,%.1f,%.1f)\n",r.left,r.top,r.right,r.bottom)); STRACE(("\tFrame: (%.1f,%.1f,%.1f,%.1f)\n",r.left,r.top,r.right,r.bottom));
@@ -124,49 +117,18 @@ WinBorder::~WinBorder(void)
{ {
delete fDecorator; delete fDecorator;
fDecorator = NULL; fDecorator = NULL;
delete fDecFull;
fDecFull = NULL;
} }
} }
void WinBorder::RebuildFullRegion(void) void WinBorder::RebuildFullRegion(void)
{ {
STRACE(("WinBorder(%s):~RebuildFullRegion()\n",GetName())); STRACE(("WinBorder(%s):~RebuildFullRegion()\n",GetName()));
BRegion topLayerFull;
Layer *topLayer = fServerWin->fTopLayer;
topLayerFull.Set( ConvertToTop(*fNewTopLayerFrame) );
fNewTopLayerFrame = &(fServerWin->fTopLayer->fFrame);
// TODO: Convert to screen coordinates
LayerData *ld;
ld = topLayer->fLayerData;
do
{
// clip to user region
if(ld->clipReg)
topLayerFull.IntersectWith( ld->clipReg );
} while( (ld = ld->prevState) );
// clip to user picture region
if(topLayer->clipToPicture)
{
if(topLayer->clipToPictureInverse)
topLayerFull.Exclude( topLayer->clipToPicture );
else
topLayerFull.IntersectWith( topLayer->clipToPicture );
}
fFull.MakeEmpty(); fFull.MakeEmpty();
fFull = topLayerFull;
// Winborder holds Decorator's full regions. if any...
if (fDecorator) if (fDecorator)
{ fDecorator->GetFootprint(&fFull);
fDecFull->MakeEmpty();
fDecorator->GetFootprint(fDecFull);
fFull.Include(fDecFull);
}
} }
void WinBorder::MouseDown(PortMessage *msg) void WinBorder::MouseDown(PortMessage *msg)
@@ -379,25 +341,20 @@ void WinBorder::HighlightDecorator(const bool &active)
void WinBorder::Draw(const BRect &r) void WinBorder::Draw(const BRect &r)
{ {
STRACE(("WinBorder(%s)::Draw()\n", GetName())); STRACE(("WinBorder(%s)::Draw()\n", GetName()));
// if we have a visible region, it is decorator's one.
if(fDecorator) if(fDecorator)
{ {
// decorator is allowed to draw in its entire visible region, not just in the update one.
fUpdateReg = fVisible; fUpdateReg = fVisible;
fUpdateReg.IntersectWith(fDecFull);
// restrict Decorator drawing to the update region only. // restrict Decorator drawing to the update region only.
fDriver->ConstrainClippingRegion(&fUpdateReg); fDriver->ConstrainClippingRegion(&fUpdateReg);
/*
fUpdateReg.PrintToStream();
/* fUpdateReg.PrintToStream();
RGBColor c(128, 56, 98); RGBColor c(128, 56, 98);
//fDriver->FillRect(r, c); //fDriver->FillRect(r, c);
fDriver->FillRect(fUpdateReg.Frame(), c); fDriver->FillRect(fUpdateReg.Frame(), c);
snooze(1000000); snooze(1000000);
*/ */
// TODO: pass 'r' not as you do now!!! Let Decorator object handle update problems
fDecorator->Draw(fUpdateReg.Frame()); fDecorator->Draw(fUpdateReg.Frame());
// remove the additional clipping region. // remove the additional clipping region.
fDriver->ConstrainClippingRegion(NULL); fDriver->ConstrainClippingRegion(NULL);
} }
@@ -407,11 +364,8 @@ void WinBorder::MoveBy(float x, float y)
{ {
STRACE(("WinBorder(%s)::MoveBy()\n", GetName())); STRACE(("WinBorder(%s)::MoveBy()\n", GetName()));
if(fDecorator) if(fDecorator)
{
fDecorator->MoveBy(x,y); fDecorator->MoveBy(x,y);
fDecFull->OffsetBy(x,y); // TODO: Repair! :-))
}
Layer::MoveBy(x,y); Layer::MoveBy(x,y);
} }
@@ -420,16 +374,8 @@ void WinBorder::ResizeBy(float x, float y)
STRACE(("WinBorder(%s)::ResizeBy()\n", GetName())); STRACE(("WinBorder(%s)::ResizeBy()\n", GetName()));
if(fDecorator) if(fDecorator)
fDecorator->ResizeBy(x,y); fDecorator->ResizeBy(x,y);
// TODO: Repair! :-))
BRect *localRect = new BRect(fServerWin->fTopLayer->fFrame);
fNewTopLayerFrame = localRect;
// force topLayer's frame to resize
fNewTopLayerFrame->right += x;
fNewTopLayerFrame->bottom += y;
Layer::ResizeBy(x,y); Layer::ResizeBy(x,y);
delete localRect;
} }
bool WinBorder::HasPoint(BPoint& pt) const bool WinBorder::HasPoint(BPoint& pt) const
-6
View File
@@ -60,7 +60,6 @@ public:
void UpdateFont(void); void UpdateFont(void);
void UpdateScreen(void); void UpdateScreen(void);
ServerWindow *Window(void) const { return fServerWin; }
Decorator *GetDecorator(void) const { return fDecorator; } Decorator *GetDecorator(void) const { return fDecorator; }
WinBorder *MainWinBorder() const; WinBorder *MainWinBorder() const;
@@ -87,17 +86,12 @@ protected:
int32 fKeyModifiers; int32 fKeyModifiers;
BPoint fLastMousePosition; BPoint fLastMousePosition;
BRegion *fDecFull;
WinBorder *fMainWinBorder; WinBorder *fMainWinBorder;
bool fIsMoving; bool fIsMoving;
bool fIsResizing; bool fIsResizing;
bool fIsClosing; bool fIsClosing;
bool fIsMinimizing; bool fIsMinimizing;
bool fIsZooming; bool fIsZooming;
// having a hard time doing resizing. It's not nice, but this helps a bit
BRect *fNewTopLayerFrame;
}; };
#endif #endif