* Got rid of the frightening Layer::fCurrent/RootLayer::fWinBorderIndex as well as

NextChild() and PreviousChild() - the current WinBorder list is now rebuilt on every
  change; this is not perfect, and only a temporary solution (but cleaner than the
  previous one).
* Introduced Layer::PreviousLayer()/NextLayer() methods that return the previous resp.
  the next sibling.
* Moved {show|hide}_winBorder() into {Show|Hide}WinBorder() and got rid of the former.
* Renamed Layer::fServerWin to fWindow.
* removed some unused stuff, minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15108 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-24 12:19:11 +00:00
parent 3ea52afce9
commit 5ed0556236
6 changed files with 188 additions and 237 deletions
+1
View File
@@ -165,6 +165,7 @@ Desktop::Desktop(uid_t userID)
Desktop::~Desktop() Desktop::~Desktop()
{ {
// root layer only knows the visible WinBorders, so we delete them all over here
for (int32 i = 0; WinBorder *border = (WinBorder *)fWinBorderList.ItemAt(i); i++) for (int32 i = 0; WinBorder *border = (WinBorder *)fWinBorderList.ItemAt(i); i++)
delete border; delete border;
+65 -60
View File
@@ -49,7 +49,7 @@ Layer::Layer(BRect frame, const char* name, int32 token,
fDriver(driver), fDriver(driver),
fRootLayer(NULL), fRootLayer(NULL),
fServerWin(NULL), fWindow(NULL),
fOwner(NULL), fOwner(NULL),
fDrawState(new DrawState), fDrawState(new DrawState),
@@ -60,8 +60,6 @@ Layer::Layer(BRect frame, const char* name, int32 token,
fFirstChild(NULL), fFirstChild(NULL),
fLastChild(NULL), fLastChild(NULL),
fCurrent(NULL),
fViewToken(token), fViewToken(token),
fFlags(flags), fFlags(flags),
fAdFlags(0), fAdFlags(0),
@@ -109,7 +107,6 @@ Layer::~Layer()
delete fDrawState; delete fDrawState;
Layer* child = fFirstChild; Layer* child = fFirstChild;
while (child != NULL) { while (child != NULL) {
Layer* nextChild = child->fNextSibling; Layer* nextChild = child->fNextSibling;
@@ -128,7 +125,7 @@ Layer::~Layer()
it spits an error to stdout and returns. it spits an error to stdout and returns.
*/ */
void void
Layer::AddChild(Layer* layer, ServerWindow* serverWin) Layer::AddChild(Layer* layer, ServerWindow* window)
{ {
STRACE(("Layer(%s)::AddChild(%s) START\n", Name(), layer->Name())); STRACE(("Layer(%s)::AddChild(%s) START\n", Name(), layer->Name()));
@@ -172,18 +169,18 @@ Layer::AddChild(Layer* layer, ServerWindow* serverWin)
c->SetRootLayer(c->fParent->fRootLayer); c->SetRootLayer(c->fParent->fRootLayer);
// 2.2) this Layer must know if it has a ServerWindow object attached. // 2.2) this Layer must know if it has a ServerWindow object attached.
c->fServerWin=serverWin; c->fWindow = window;
// tree parsing algorithm // tree parsing algorithm
if (c->fFirstChild) { if (c->fFirstChild) {
// go deep // go deep
c = c->fFirstChild; c = c->fFirstChild;
} else { } else {
// go right or up // go right or up
if (c == stop) // our trip is over if (c == stop) // our trip is over
break; break;
if (c->fNextSibling) { if (c->fNextSibling) {
// go right // go right
c = c->fNextSibling; c = c->fNextSibling;
@@ -191,10 +188,10 @@ Layer::AddChild(Layer* layer, ServerWindow* serverWin)
// go up // go up
while (!c->fParent->fNextSibling && c->fParent != stop) while (!c->fParent->fNextSibling && c->fParent != stop)
c = c->fParent; c = c->fParent;
if (c->fParent == stop) // that's enough! if (c->fParent == stop) // that's enough!
break; break;
c = c->fParent->fNextSibling; c = c->fParent->fNextSibling;
} }
} }
@@ -203,6 +200,7 @@ Layer::AddChild(Layer* layer, ServerWindow* serverWin)
STRACE(("Layer(%s)::AddChild(%s) END\n", Name(), layer->Name())); STRACE(("Layer(%s)::AddChild(%s) END\n", Name(), layer->Name()));
} }
/*! /*!
\brief Removes a child layer from the current one \brief Removes a child layer from the current one
\param layer the layer to remove \param layer the layer to remove
@@ -259,7 +257,7 @@ Layer::RemoveChild(Layer *layer)
// 2.1) set the RootLayer for this object. // 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. // 2.2) this Layer must know if it has a ServerWindow object attached.
c->fServerWin = NULL; c->fWindow = NULL;
} }
// tree parsing algorithm // tree parsing algorithm
@@ -289,6 +287,7 @@ Layer::RemoveChild(Layer *layer)
STRACE(("Layer(%s)::RemoveChild(%s) END\n", Name(), layer->Name())); STRACE(("Layer(%s)::RemoveChild(%s) END\n", Name(), layer->Name()));
} }
//! Removes the calling layer from the tree //! Removes the calling layer from the tree
void void
Layer::RemoveSelf() Layer::RemoveSelf()
@@ -301,19 +300,21 @@ Layer::RemoveSelf()
fParent->RemoveChild(this); fParent->RemoveChild(this);
} }
/*! /*!
\return true if the child is owned by this Layer, false if not \return true if the child is owned by this Layer, false if not
*/ */
bool bool
Layer::HasChild(Layer* layer) Layer::HasChild(Layer* layer)
{ {
for (Layer* child = FirstChild(); child; child = NextChild()) { for (Layer* child = FirstChild(); child; child = child->NextLayer()) {
if (child == layer) if (child == layer)
return true; return true;
} }
return false; return false;
} }
//! Returns the number of children //! Returns the number of children
uint32 uint32
Layer::CountChildren() const Layer::CountChildren() const
@@ -321,7 +322,7 @@ Layer::CountChildren() const
uint32 count = 0; uint32 count = 0;
Layer* child = FirstChild(); Layer* child = FirstChild();
while (child != NULL) { while (child != NULL) {
child = NextChild(); child = child->NextLayer();
count++; count++;
} }
return count; return count;
@@ -338,17 +339,17 @@ Layer::FindLayer(const int32 token)
// (recursive) search for a layer based on its view token // (recursive) search for a layer based on its view token
// iterate only over direct child layers first // iterate only over direct child layers first
for (Layer* child = FirstChild(); child; child = NextChild()) { for (Layer* child = FirstChild(); child; child = child->NextLayer()) {
if (child->fViewToken == token) if (child->fViewToken == token)
return child; return child;
} }
// try a recursive search // try a recursive search
for (Layer* child = FirstChild(); child; child = NextChild()) { for (Layer* child = FirstChild(); child; child = child->NextLayer()) {
if (Layer* layer = child->FindLayer(token)) if (Layer* layer = child->FindLayer(token))
return layer; return layer;
} }
return NULL; return NULL;
} }
@@ -364,7 +365,7 @@ Layer::LayerAt(BPoint where)
return this; return this;
if (fFullVisible.Contains(where)) { if (fFullVisible.Contains(where)) {
for (Layer* child = LastChild(); child; child = PreviousChild()) { for (Layer* child = LastChild(); child; child = child->PreviousLayer()) {
if (Layer* layer = child->LayerAt(where)) if (Layer* layer = child->LayerAt(where))
return layer; return layer;
} }
@@ -373,39 +374,35 @@ Layer::LayerAt(BPoint where)
return NULL; return NULL;
} }
// FirstChild
Layer* Layer*
Layer::FirstChild() const Layer::FirstChild() const
{ {
fCurrent = fFirstChild; return fFirstChild;
return fCurrent;
} }
// NextChild
Layer* Layer*
Layer::NextChild() const Layer::NextLayer() const
{ {
fCurrent = fCurrent->fNextSibling; return fNextSibling;
return fCurrent;
} }
// PreviousChild
Layer* Layer*
Layer::PreviousChild() const Layer::PreviousLayer() const
{ {
fCurrent = fCurrent->fPreviousSibling; return fPreviousSibling;
return fCurrent;
} }
// LastChild
Layer* Layer*
Layer::LastChild() const Layer::LastChild() const
{ {
fCurrent = fLastChild; return fLastChild;
return fCurrent;
} }
// SetName
void void
Layer::SetName(const char* name) Layer::SetName(const char* name)
{ {
@@ -648,7 +645,7 @@ Layer::ResizeBy(float x, float y)
// TODO: ResizedByHook(x,y,true) is called from inside _ResizeLayerFrameBy // TODO: ResizedByHook(x,y,true) is called from inside _ResizeLayerFrameBy
// Should call this AFTER region rebuilding and redrawing. // Should call this AFTER region rebuilding and redrawing.
// resize children using their resize_mask. // resize children using their resize_mask.
for (Layer *child = LastChild(); child != NULL; child = PreviousChild()) for (Layer *child = LastChild(); child != NULL; child = child->PreviousLayer())
child->_ResizeLayerFrameBy(x, y); child->_ResizeLayerFrameBy(x, y);
BRegion oldFullVisible(fFullVisible); BRegion oldFullVisible(fFullVisible);
@@ -709,7 +706,7 @@ Layer::ResizeBy(float x, float y)
// TODO: ResizedByHook(x,y,true) is called from inside _ResizeLayerFrameBy // TODO: ResizedByHook(x,y,true) is called from inside _ResizeLayerFrameBy
// Should call this AFTER region rebuilding and redrawing. // Should call this AFTER region rebuilding and redrawing.
// resize children using their resize_mask. // resize children using their resize_mask.
for (Layer *child = LastChild(); child != NULL; child = PreviousChild()) for (Layer *child = LastChild(); child != NULL; child = child->PreviousLayer())
child->_ResizeLayerFrameBy(x, y); child->_ResizeLayerFrameBy(x, y);
} }
@@ -1188,7 +1185,7 @@ Layer::_ResizeLayerFrameBy(float x, float y)
// call hook function // call hook function
ResizedByHook(dx, dy, true); // automatic ResizedByHook(dx, dy, true); // automatic
for (Layer* child = LastChild(); child; child = PreviousChild()) for (Layer* child = LastChild(); child; child = child->PreviousLayer())
child->_ResizeLayerFrameBy(dx, dy); child->_ResizeLayerFrameBy(dx, dy);
} }
} }
@@ -1201,7 +1198,7 @@ Layer::_RezizeLayerRedrawMore(BRegion &reg, float dx, float dy)
if (dx == 0 && dy == 0) if (dx == 0 && dy == 0)
return; return;
for (Layer* child = LastChild(); child; child = PreviousChild()) { for (Layer* child = LastChild(); child; child = child->PreviousLayer()) {
uint16 rm = child->fResizeMode & 0x0000FFFF; uint16 rm = child->fResizeMode & 0x0000FFFF;
if ((rm & 0x0F0F) == (uint16)B_FOLLOW_LEFT_RIGHT || (rm & 0xF0F0) == (uint16)B_FOLLOW_TOP_BOTTOM) { if ((rm & 0x0F0F) == (uint16)B_FOLLOW_LEFT_RIGHT || (rm & 0xF0F0) == (uint16)B_FOLLOW_TOP_BOTTOM) {
@@ -1250,7 +1247,7 @@ Layer::_ResizeLayerFullUpdateOnResize(BRegion &reg, float dx, float dy)
if (dx == 0 && dy == 0) if (dx == 0 && dy == 0)
return; return;
for (Layer* child = LastChild(); child; child = PreviousChild()) { for (Layer* child = LastChild(); child; child = child->PreviousLayer()) {
uint16 rm = child->fResizeMode & 0x0000FFFF; uint16 rm = child->fResizeMode & 0x0000FFFF;
if ((rm & 0x0F0F) == (uint16)B_FOLLOW_LEFT_RIGHT || (rm & 0xF0F0) == (uint16)B_FOLLOW_TOP_BOTTOM) { if ((rm & 0x0F0F) == (uint16)B_FOLLOW_LEFT_RIGHT || (rm & 0xF0F0) == (uint16)B_FOLLOW_TOP_BOTTOM) {
@@ -1331,7 +1328,7 @@ Layer::_RebuildVisibleRegions(const BRegion &invalid,
// allow this layer to hide some parts from its children // allow this layer to hide some parts from its children
_ReserveRegions(common); _ReserveRegions(common);
for (Layer *child = LastChild(); child; child = PreviousChild()) { for (Layer *child = LastChild(); child; child = child->PreviousLayer()) {
if (child == startFrom) if (child == startFrom)
fullRebuild = true; fullRebuild = true;
@@ -1372,7 +1369,7 @@ Layer::_RebuildVisibleRegions(const BRegion &invalid,
// allow this layer to hide some parts from its children // allow this layer to hide some parts from its children
_ReserveRegions(common); _ReserveRegions(common);
for (Layer *child = LastChild(); child; child = PreviousChild()) { for (Layer *child = LastChild(); child; child = child->PreviousLayer()) {
child->_RebuildVisibleRegions(invalid, common, child->LastChild()); child->_RebuildVisibleRegions(invalid, common, child->LastChild());
// to let children know much they can take from parent's visible region // to let children know much they can take from parent's visible region
@@ -1385,7 +1382,7 @@ Layer::_RebuildVisibleRegions(const BRegion &invalid,
_RebuildDrawingRegion(); _RebuildDrawingRegion();
} }
// _RebuildDrawingRegion
void void
Layer::_RebuildDrawingRegion() Layer::_RebuildDrawingRegion()
{ {
@@ -1398,12 +1395,14 @@ Layer::_RebuildDrawingRegion()
} }
} }
void void
Layer::_ReserveRegions(BRegion &reg) Layer::_ReserveRegions(BRegion &reg)
{ {
// Empty for Layer objects // Empty for Layer objects
} }
void void
Layer::_ClearVisibleRegions() Layer::_ClearVisibleRegions()
{ {
@@ -1411,20 +1410,24 @@ Layer::_ClearVisibleRegions()
fVisible.MakeEmpty(); fVisible.MakeEmpty();
fFullVisible.MakeEmpty(); fFullVisible.MakeEmpty();
for (Layer *child = LastChild(); child; child = PreviousChild()) for (Layer *child = LastChild(); child; child = child->PreviousLayer())
child->_ClearVisibleRegions(); child->_ClearVisibleRegions();
} }
// mark a region dirty so that the next region rebuild for us
// and our children will take this into account /*! Mark a region dirty so that the next region rebuild for us
and our children will take this into account
*/
void void
Layer::MarkForRebuild(const BRegion &dirty) Layer::MarkForRebuild(const BRegion &dirty)
{ {
fDirtyForRebuild.Include(&dirty); fDirtyForRebuild.Include(&dirty);
} }
// this will trigger visible region recalculation for us and
// our descendants. /*! This will trigger visible region recalculation for us and
our descendants.
*/
void void
Layer::TriggerRebuild() Layer::TriggerRebuild()
{ {
@@ -1443,18 +1446,20 @@ Layer::TriggerRebuild()
} }
} }
// find out the region for which we must rebuild the visible regions
//! find out the region for which we must rebuild the visible regions
void void
Layer::_GetAllRebuildDirty(BRegion *totalReg) Layer::_GetAllRebuildDirty(BRegion *totalReg)
{ {
totalReg->Include(&fDirtyForRebuild); totalReg->Include(&fDirtyForRebuild);
for (Layer *child = LastChild(); child; child = PreviousChild()) for (Layer *child = LastChild(); child; child = child->PreviousLayer())
child->_GetAllRebuildDirty(totalReg); child->_GetAllRebuildDirty(totalReg);
fDirtyForRebuild.MakeEmpty(); fDirtyForRebuild.MakeEmpty();
} }
void void
Layer::_AllRedraw(const BRegion &invalid) Layer::_AllRedraw(const BRegion &invalid)
{ {
@@ -1474,11 +1479,11 @@ Layer::_AllRedraw(const BRegion &invalid)
} }
} }
for (Layer *child = LastChild(); child != NULL; child = PreviousChild()) { for (Layer *child = LastChild(); child != NULL; child = child->PreviousLayer()) {
if (!(child->IsHidden())) { if (!child->IsHidden()) {
BRegion common(child->fFullVisible); BRegion common(child->fFullVisible);
common.IntersectWith(&invalid); common.IntersectWith(&invalid);
if (common.CountRects() > 0) if (common.CountRects() > 0)
child->_AllRedraw(invalid); child->_AllRedraw(invalid);
} }
@@ -1489,11 +1494,11 @@ Layer::_AllRedraw(const BRegion &invalid)
void void
Layer::_AddToViewsWithInvalidCoords() const Layer::_AddToViewsWithInvalidCoords() const
{ {
if (fServerWin) { if (fWindow) {
fServerWin->ClientViewsWithInvalidCoords().AddInt32("_token", fViewToken); fWindow->ClientViewsWithInvalidCoords().AddInt32("_token", fViewToken);
fServerWin->ClientViewsWithInvalidCoords().AddPoint("where", fFrame.LeftTop()); fWindow->ClientViewsWithInvalidCoords().AddPoint("where", fFrame.LeftTop());
fServerWin->ClientViewsWithInvalidCoords().AddFloat("width", fFrame.Width()); fWindow->ClientViewsWithInvalidCoords().AddFloat("width", fFrame.Width());
fServerWin->ClientViewsWithInvalidCoords().AddFloat("height", fFrame.Height()); fWindow->ClientViewsWithInvalidCoords().AddFloat("height", fFrame.Height());
} }
} }
@@ -1501,8 +1506,8 @@ Layer::_AddToViewsWithInvalidCoords() const
void void
Layer::_SendViewCoordUpdateMsg() const Layer::_SendViewCoordUpdateMsg() const
{ {
if (fServerWin && !fServerWin->ClientViewsWithInvalidCoords().IsEmpty()) { if (fWindow && !fWindow->ClientViewsWithInvalidCoords().IsEmpty()) {
fServerWin->SendMessageToClient(&fServerWin->ClientViewsWithInvalidCoords()); fWindow->SendMessageToClient(&fWindow->ClientViewsWithInvalidCoords());
fServerWin->ClientViewsWithInvalidCoords().MakeEmpty(); fWindow->ClientViewsWithInvalidCoords().MakeEmpty();
} }
} }
+11 -11
View File
@@ -10,6 +10,10 @@
#ifndef _LAYER_H_ #ifndef _LAYER_H_
#define _LAYER_H_ #define _LAYER_H_
#include "RGBColor.h"
#include "ServerWindow.h"
#include <GraphicsDefs.h> #include <GraphicsDefs.h>
#include <List.h> #include <List.h>
#include <Locker.h> #include <Locker.h>
@@ -18,8 +22,6 @@
#include <Rect.h> #include <Rect.h>
#include <Region.h> #include <Region.h>
#include "RGBColor.h"
#include "ServerWindow.h"
enum { enum {
B_LAYER_NONE = 1, B_LAYER_NONE = 1,
@@ -85,10 +87,10 @@ class Layer {
Layer* FindLayer(const int32 token); Layer* FindLayer(const int32 token);
Layer* LayerAt(BPoint where); Layer* LayerAt(BPoint where);
virtual Layer* FirstChild() const; Layer* FirstChild() const;
virtual Layer* NextChild() const; Layer* LastChild() const;
virtual Layer* PreviousChild() const; Layer* NextLayer() const;
virtual Layer* LastChild() const; Layer* PreviousLayer() const;
void SetAsTopLayer(bool option) void SetAsTopLayer(bool option)
{ fIsTopLayer = option; } { fIsTopLayer = option; }
@@ -170,9 +172,9 @@ class Layer {
// app_server objects getters // app_server objects getters
ServerWindow* Window() const ServerWindow* Window() const
{ return fServerWin; } { return fWindow; }
ServerApp* App() const ServerApp* App() const
{ return fServerWin? fServerWin->App(): NULL; } { return fWindow ? fWindow->App() : NULL; }
inline WinBorder* Owner() const inline WinBorder* Owner() const
{ return fOwner; } { return fOwner; }
RootLayer* GetRootLayer() const RootLayer* GetRootLayer() const
@@ -243,7 +245,7 @@ class Layer {
DrawingEngine* fDriver; DrawingEngine* fDriver;
RootLayer* fRootLayer; RootLayer* fRootLayer;
ServerWindow* fServerWin; ServerWindow* fWindow;
WinBorder* fOwner; WinBorder* fOwner;
DrawState* fDrawState; DrawState* fDrawState;
@@ -253,8 +255,6 @@ class Layer {
Layer* fNextSibling; Layer* fNextSibling;
Layer* fFirstChild; Layer* fFirstChild;
Layer* fLastChild; Layer* fLastChild;
mutable Layer* fCurrent;
int32 fViewToken; int32 fViewToken;
uint32 fFlags; uint32 fFlags;
+107 -150
View File
@@ -70,10 +70,7 @@ RootLayer::RootLayer(const char *name, int32 workspaceCount,
fWsCount(0), fWsCount(0),
fWorkspace(new Workspace*[kMaxWorkspaceCount]), fWorkspace(new Workspace*[kMaxWorkspaceCount]),
fWorkspacesLayer(NULL), fWorkspacesLayer(NULL),
fWMState(), fWMState()
fWinBorderIndex(0),
fScreenShotIndex(1)
{ {
//NOTE: be careful about this one. //NOTE: be careful about this one.
fRootLayer = this; fRootLayer = this;
@@ -105,12 +102,6 @@ RootLayer::RootLayer(const char *name, int32 workspaceCount,
// number to an index in the name, i.e. workspace_settings_1 for screen #1 // number to an index in the name, i.e. workspace_settings_1 for screen #1
// ReadWorkspaceData(WORKSPACE_DATA_LIST); // ReadWorkspaceData(WORKSPACE_DATA_LIST);
// TODO: read these 4 from a configuration file.
// fScreenWidth = 0;
// fScreenHeight = 0;
// fColorSpace = B_RGB32;
// fFrequency = 60.f;
// init the first, default workspace // init the first, default workspace
fWorkspace[fActiveWksIndex] = new Workspace(fActiveWksIndex, 0xFF00FF00, fWorkspace[fActiveWksIndex] = new Workspace(fActiveWksIndex, 0xFF00FF00,
kDefaultWorkspaceColor); kDefaultWorkspaceColor);
@@ -144,6 +135,10 @@ RootLayer::~RootLayer()
delete fWorkspace[i]; delete fWorkspace[i];
delete[] fWorkspace; delete[] fWorkspace;
fFirstChild = NULL;
// this prevents the Layer destructor from freeing our children again
// (the Desktop destructor already took care of that)
// RootLayer object just uses Screen objects, it is not allowed to delete them. // RootLayer object just uses Screen objects, it is not allowed to delete them.
#if DISPLAY_HAIKU_LOGO #if DISPLAY_HAIKU_LOGO
@@ -194,33 +189,6 @@ RootLayer::ResizeBy(float x, float y)
} }
Layer*
RootLayer::FirstChild() const
{
fWinBorderIndex = 0;
return static_cast<Layer*>(fWMState.WindowList.ItemAt(fWinBorderIndex++));
}
Layer*
RootLayer::NextChild() const
{
return static_cast<Layer*>(fWMState.WindowList.ItemAt(fWinBorderIndex++));
}
Layer*
RootLayer::PreviousChild() const
{
return static_cast<Layer*>(fWMState.WindowList.ItemAt(fWinBorderIndex--));
}
Layer*
RootLayer::LastChild() const
{
fWinBorderIndex = fWMState.WindowList.CountItems()-1;
return static_cast<Layer*>(fWMState.WindowList.ItemAt(fWinBorderIndex--));
}
void void
RootLayer::AddWinBorder(WinBorder* winBorder) RootLayer::AddWinBorder(WinBorder* winBorder)
{ {
@@ -584,43 +552,36 @@ void
RootLayer::SaveWorkspaceData(const char *path) RootLayer::SaveWorkspaceData(const char *path)
{ {
BMessage msg,dummy; BMessage msg,dummy;
BFile file(path,B_READ_WRITE | B_CREATE_FILE); BFile file(path, B_READ_WRITE | B_CREATE_FILE);
if(file.InitCheck()!=B_OK) if (file.InitCheck() != B_OK) {
{
printf("ERROR: Couldn't save workspace data in RootLayer\n"); printf("ERROR: Couldn't save workspace data in RootLayer\n");
return; return;
} }
char string[20];
int32 count=fWsCount;
if(msg.Unflatten(&file)==B_OK) char string[20];
{ int32 count = fWsCount;
if (msg.Unflatten(&file) == B_OK) {
// if we were successful in unflattening the file, it means we're // if we were successful in unflattening the file, it means we're
// going to need to save over the existing data // going to need to save over the existing data
for(int32 i=0; i<count; i++) for(int32 i = 0; i < count; i++) {
{
sprintf(string,"workspace %ld",i); sprintf(string,"workspace %ld",i);
if(msg.FindMessage(string,&dummy)==B_OK) if(msg.FindMessage(string,&dummy)==B_OK)
msg.RemoveName(string); msg.RemoveName(string);
} }
} }
for(int32 i=0; i<count; i++) for (int32 i = 0; i < count; i++) {
{
sprintf(string,"workspace %ld",i); sprintf(string,"workspace %ld",i);
Workspace *ws=(Workspace*)fWorkspace[i]; Workspace *ws = (Workspace*)fWorkspace[i];
if(!ws) if (!ws) {
{
dummy.MakeEmpty(); dummy.MakeEmpty();
ws->PutSettings(&dummy,i); ws->PutSettings(&dummy,i);
msg.AddMessage(string,&dummy); msg.AddMessage(string,&dummy);
} } else {
else
{
// We're not supposed to have this happen, but we'll suck it up, anyway. :P // We're not supposed to have this happen, but we'll suck it up, anyway. :P
Workspace::PutDefaultSettings(&msg,i); Workspace::PutDefaultSettings(&msg,i);
} }
@@ -631,25 +592,82 @@ RootLayer::SaveWorkspaceData(const char *path)
void void
RootLayer::HideWinBorder(WinBorder* winBorder) RootLayer::HideWinBorder(WinBorder* winBorder)
{ {
Lock(); BAutolock _(fAllRegionsLock);
hide_winBorder(winBorder);
Unlock(); bool invalidate = false;
bool invalid;
Workspace::State oldWMState;
ActiveWorkspace()->GetState(&oldWMState);
winBorder->Hide(false);
for (int32 i = 0; i < fWsCount; i++) {
invalid = false;
if (fWorkspace[i] && fWorkspace[i]->HasWinBorder(winBorder))
invalid = fWorkspace[i]->HideWinBorder(winBorder);
if (fActiveWksIndex == i) {
invalidate = invalid;
if (dynamic_cast<class WorkspacesLayer *>(winBorder->FirstChild()) != NULL)
SetWorkspacesLayer(NULL);
}
}
if (invalidate)
RevealNewWMState(oldWMState);
} }
void void
RootLayer::ShowWinBorder(WinBorder* winBorder) RootLayer::ShowWinBorder(WinBorder* winBorder)
{ {
Lock(); BAutolock _(fAllRegionsLock);
show_winBorder(winBorder);
Unlock(); bool invalidate = false;
bool invalid;
Workspace::State oldWMState;
ActiveWorkspace()->GetState(&oldWMState);
winBorder->Show(false);
for (int32 i = 0; i < fWsCount; i++) {
invalid = false;
if (fWorkspace[i]
&& (fWorkspace[i]->HasWinBorder(winBorder)
|| winBorder->Feel() == B_MODAL_SUBSET_WINDOW_FEEL
// subset modals are a bit like floating windows, they are being added
// and removed from workspace when there's at least a normal window
// that uses them.
|| winBorder->Level() == B_FLOATING_APP))
// floating windows are inserted/removed on-the-fly so this window,
// although needed may not be in workspace's list.
{
invalid = fWorkspace[i]->ShowWinBorder(winBorder);
// ToDo: this won't work with FFM
fWorkspace[i]->AttemptToSetFocus(winBorder);
}
if (fActiveWksIndex == i) {
invalidate = invalid;
if (dynamic_cast<class WorkspacesLayer *>(winBorder->FirstChild()) != NULL)
SetWorkspacesLayer(winBorder->FirstChild());
}
}
if (invalidate)
RevealNewWMState(oldWMState);
} }
void void
RootLayer::RevealNewWMState(Workspace::State &oldWMState) RootLayer::RevealNewWMState(Workspace::State &oldWMState)
{ {
// clean fWMState // clear fWMState
fWMState.Focus = NULL; fWMState.Focus = NULL;
fWMState.Front = NULL; fWMState.Front = NULL;
fWMState.Active = NULL; fWMState.Active = NULL;
@@ -657,9 +675,6 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState)
ActiveWorkspace()->GetState(&fWMState); ActiveWorkspace()->GetState(&fWMState);
// BOOKMARK!
// TODO: there can be more than one window active at a time! ex: a normal + floating_app, with
// floating window having focus.
// send window activation messages // send window activation messages
if (oldWMState.Active != fWMState.Active) { if (oldWMState.Active != fWMState.Active) {
if (oldWMState.Active) if (oldWMState.Active)
@@ -710,35 +725,50 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState)
continue; continue;
bool stillPresent = false; bool stillPresent = false;
for (int32 j = 0; j < newWindowCount; ++j) for (int32 j = 0; j < newWindowCount; ++j) {
if (layer == fWMState.WindowList.ItemAtFast(j)) { if (layer == fWMState.WindowList.ItemAtFast(j)) {
stillPresent = true; stillPresent = true;
break; break;
} }
}
if (!stillPresent) { if (!stillPresent) {
MarkForRebuild(layer->FullVisible()); MarkForRebuild(layer->FullVisible());
MarkForRedraw(layer->FullVisible()); MarkForRedraw(layer->FullVisible());
layer->_ClearVisibleRegions(); layer->_ClearVisibleRegions();
} } else
else {
oldStrippedList.AddItem(layer); oldStrippedList.AddItem(layer);
}
} }
fFirstChild = NULL;
fLastChild = NULL;
// for new windows, invalidate(rebuild & redraw) the maximum that it can occupy. // for new windows, invalidate(rebuild & redraw) the maximum that it can occupy.
for (int32 i = 0; i < newWindowCount; ++i) { for (int32 i = 0; i < newWindowCount; ++i) {
Layer *layer = static_cast<Layer*>(fWMState.WindowList.ItemAtFast(i)); Layer *layer = static_cast<Layer*>(fWMState.WindowList.ItemAtFast(i));
if (!layer) if (!layer)
continue; continue;
// insert layer into RootLayer list
if (i == 0)
fFirstChild = layer;
if (fLastChild != NULL)
fLastChild->fNextSibling = layer;
layer->fPreviousSibling = fLastChild;
layer->fNextSibling = NULL;
fLastChild = layer;
bool isNewWindow = true; bool isNewWindow = true;
for (int32 j = 0; j < oldWindowCount; ++j) for (int32 j = 0; j < oldWindowCount; ++j) {
if (layer == oldWMState.WindowList.ItemAtFast(j)) { if (layer == oldWMState.WindowList.ItemAtFast(j)) {
isNewWindow = false; isNewWindow = false;
break; break;
} }
}
if (isNewWindow) { if (isNewWindow) {
BRegion invalid; BRegion invalid;
@@ -747,10 +777,8 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState)
MarkForRebuild(invalid); MarkForRebuild(invalid);
MarkForRedraw(invalid); MarkForRedraw(invalid);
} } else
else {
newStrippedList.AddItem(layer); newStrippedList.AddItem(layer);
}
} }
// if a window came in front ot others, invalidate its previously hidden area. // if a window came in front ot others, invalidate its previously hidden area.
@@ -786,8 +814,7 @@ GetDrawingEngine()->ConstrainClippingRegion(NULL);
// trigger region rebuilding and redraw // trigger region rebuilding and redraw
TriggerRebuild(); TriggerRebuild();
TriggerRedraw(); TriggerRedraw();
} } else if (redraw) {
else if (redraw) {
MarkForRedraw(dirtyRegion); MarkForRedraw(dirtyRegion);
TriggerRedraw(); TriggerRedraw();
} }
@@ -814,8 +841,7 @@ RootLayer::SetActive(WinBorder* newActive, bool activate)
returnValue = ActiveWorkspace()->AttemptToMoveToBack(newActive); returnValue = ActiveWorkspace()->AttemptToMoveToBack(newActive);
RevealNewWMState(oldWMState); RevealNewWMState(oldWMState);
} } else {
else {
fWorkspace[i]->AttemptToActivate(newActive); fWorkspace[i]->AttemptToActivate(newActive);
// NOTE: for multiple monitor support, if a workspaces is mapped to // NOTE: for multiple monitor support, if a workspaces is mapped to
// a Screen, we must invalidate/redraw to see the change. // a Screen, we must invalidate/redraw to see the change.
@@ -846,7 +872,7 @@ RootLayer::_ChildAt(BPoint where)
if (VisibleRegion().Contains(where)) if (VisibleRegion().Contains(where))
return NULL; return NULL;
for (Layer* child = LastChild(); child; child = PreviousChild()) { for (Layer* child = LastChild(); child; child = child->PreviousLayer()) {
if (child->FullVisible().Contains(where)) if (child->FullVisible().Contains(where))
return child; return child;
} }
@@ -926,76 +952,6 @@ RootLayer::DragMessage(void) const
// PRIVATE methods // PRIVATE methods
void
RootLayer::show_winBorder(WinBorder *winBorder)
{
bool invalidate = false;
bool invalid;
Workspace::State oldWMState;
ActiveWorkspace()->GetState(&oldWMState);
winBorder->Show(false);
for (int32 i = 0; i < fWsCount; i++) {
invalid = false;
if (fWorkspace[i]
&& (fWorkspace[i]->HasWinBorder(winBorder)
|| winBorder->Feel() == B_MODAL_SUBSET_WINDOW_FEEL
// subset modals are a bit like floating windows, they are being added
// and removed from workspace when there's at least a normal window
// that uses them.
|| winBorder->Level() == B_FLOATING_APP))
// floating windows are inserted/removed on-the-fly so this window,
// although needed may not be in workspace's list.
{
invalid = fWorkspace[i]->ShowWinBorder(winBorder);
// ToDo: this won't work with FFM
fWorkspace[i]->AttemptToSetFocus(winBorder);
}
if (fActiveWksIndex == i) {
invalidate = invalid;
if (dynamic_cast<class WorkspacesLayer *>(winBorder->FirstChild()) != NULL)
SetWorkspacesLayer(winBorder->FirstChild());
}
}
if (invalidate)
RevealNewWMState(oldWMState);
}
void
RootLayer::hide_winBorder(WinBorder *winBorder)
{
bool invalidate = false;
bool invalid;
Workspace::State oldWMState;
ActiveWorkspace()->GetState(&oldWMState);
winBorder->Hide(false);
for (int32 i = 0; i < fWsCount; i++) {
invalid = false;
if (fWorkspace[i] && fWorkspace[i]->HasWinBorder(winBorder))
invalid = fWorkspace[i]->HideWinBorder(winBorder);
if (fActiveWksIndex == i) {
invalidate = invalid;
if (dynamic_cast<class WorkspacesLayer *>(winBorder->FirstChild()) != NULL)
SetWorkspacesLayer(NULL);
}
}
if (invalidate)
RevealNewWMState(oldWMState);
}
void void
RootLayer::change_winBorder_feel(WinBorder *winBorder, int32 newFeel) RootLayer::change_winBorder_feel(WinBorder *winBorder, int32 newFeel)
@@ -1038,6 +994,7 @@ RootLayer::change_winBorder_feel(WinBorder *winBorder, int32 newFeel)
} }
} }
void void
RootLayer::Draw(const BRect &r) RootLayer::Draw(const BRect &r)
{ {
-12
View File
@@ -63,12 +63,6 @@ public:
virtual void ScrollBy(float x, float y) virtual void ScrollBy(float x, float y)
{ /* not allowed */ } { /* not allowed */ }
// For the active workspaces
virtual Layer* FirstChild() const;
virtual Layer* NextChild() const;
virtual Layer* PreviousChild() const;
virtual Layer* LastChild() const;
void HideWinBorder(WinBorder* winBorder); void HideWinBorder(WinBorder* winBorder);
void ShowWinBorder(WinBorder* winBorder); void ShowWinBorder(WinBorder* winBorder);
void SetWinBorderWorskpaces(WinBorder *winBorder, void SetWinBorderWorskpaces(WinBorder *winBorder,
@@ -127,9 +121,6 @@ friend class Desktop;
void AddSubsetWinBorder(WinBorder *winBorder, WinBorder *toWinBorder); void AddSubsetWinBorder(WinBorder *winBorder, WinBorder *toWinBorder);
void RemoveSubsetWinBorder(WinBorder *winBorder, WinBorder *fromWinBorder); void RemoveSubsetWinBorder(WinBorder *winBorder, WinBorder *fromWinBorder);
void show_winBorder(WinBorder* winBorder);
void hide_winBorder(WinBorder* winBorder);
void change_winBorder_feel(WinBorder *winBorder, int32 newFeel); void change_winBorder_feel(WinBorder *winBorder, int32 newFeel);
void MouseEventHandler(BMessage *msg); void MouseEventHandler(BMessage *msg);
@@ -155,9 +146,6 @@ friend class Desktop;
// with RootLayer, but after Axel's refractoring this should go in // with RootLayer, but after Axel's refractoring this should go in
// WorkspaceLayer, I think. // WorkspaceLayer, I think.
Workspace::State fWMState; Workspace::State fWMState;
mutable int32 fWinBorderIndex;
int32 fScreenShotIndex;
#if ON_SCREEN_DEBUGGING_INFO #if ON_SCREEN_DEBUGGING_INFO
friend class DebugInfoManager; friend class DebugInfoManager;
+4 -4
View File
@@ -104,10 +104,10 @@ WinBorder::WinBorder(const BRect &frame,
cnt(0) // for debugging cnt(0) // for debugging
{ {
// unlike BViews, windows start off as hidden // unlike BViews, windows start off as hidden
fHidden = true; fHidden = true;
fServerWin = window; fWindow = window;
fAdFlags = fAdFlags | B_LAYER_CHILDREN_DEPENDANT; fAdFlags = fAdFlags | B_LAYER_CHILDREN_DEPENDANT;
fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE; fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE;
QuietlySetFeel(feel); QuietlySetFeel(feel);