* 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:
parent
3ea52afce9
commit
5ed0556236
@ -165,6 +165,7 @@ Desktop::Desktop(uid_t userID)
|
||||
|
||||
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++)
|
||||
delete border;
|
||||
|
||||
|
@ -49,7 +49,7 @@ Layer::Layer(BRect frame, const char* name, int32 token,
|
||||
|
||||
fDriver(driver),
|
||||
fRootLayer(NULL),
|
||||
fServerWin(NULL),
|
||||
fWindow(NULL),
|
||||
fOwner(NULL),
|
||||
|
||||
fDrawState(new DrawState),
|
||||
@ -60,8 +60,6 @@ Layer::Layer(BRect frame, const char* name, int32 token,
|
||||
fFirstChild(NULL),
|
||||
fLastChild(NULL),
|
||||
|
||||
fCurrent(NULL),
|
||||
|
||||
fViewToken(token),
|
||||
fFlags(flags),
|
||||
fAdFlags(0),
|
||||
@ -109,7 +107,6 @@ Layer::~Layer()
|
||||
delete fDrawState;
|
||||
|
||||
Layer* child = fFirstChild;
|
||||
|
||||
while (child != NULL) {
|
||||
Layer* nextChild = child->fNextSibling;
|
||||
|
||||
@ -128,7 +125,7 @@ Layer::~Layer()
|
||||
it spits an error to stdout and returns.
|
||||
*/
|
||||
void
|
||||
Layer::AddChild(Layer* layer, ServerWindow* serverWin)
|
||||
Layer::AddChild(Layer* layer, ServerWindow* window)
|
||||
{
|
||||
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);
|
||||
|
||||
// 2.2) this Layer must know if it has a ServerWindow object attached.
|
||||
c->fServerWin=serverWin;
|
||||
|
||||
c->fWindow = window;
|
||||
|
||||
// tree parsing algorithm
|
||||
if (c->fFirstChild) {
|
||||
// go deep
|
||||
c = c->fFirstChild;
|
||||
} else {
|
||||
// go right or up
|
||||
|
||||
|
||||
if (c == stop) // our trip is over
|
||||
break;
|
||||
|
||||
|
||||
if (c->fNextSibling) {
|
||||
// go right
|
||||
c = c->fNextSibling;
|
||||
@ -191,10 +188,10 @@ Layer::AddChild(Layer* layer, ServerWindow* serverWin)
|
||||
// go up
|
||||
while (!c->fParent->fNextSibling && c->fParent != stop)
|
||||
c = c->fParent;
|
||||
|
||||
|
||||
if (c->fParent == stop) // that's enough!
|
||||
break;
|
||||
|
||||
|
||||
c = c->fParent->fNextSibling;
|
||||
}
|
||||
}
|
||||
@ -203,6 +200,7 @@ Layer::AddChild(Layer* layer, ServerWindow* serverWin)
|
||||
STRACE(("Layer(%s)::AddChild(%s) END\n", Name(), layer->Name()));
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Removes a child layer from the current one
|
||||
\param layer the layer to remove
|
||||
@ -259,7 +257,7 @@ Layer::RemoveChild(Layer *layer)
|
||||
// 2.1) set the RootLayer for this object.
|
||||
c->SetRootLayer(NULL);
|
||||
// 2.2) this Layer must know if it has a ServerWindow object attached.
|
||||
c->fServerWin = NULL;
|
||||
c->fWindow = NULL;
|
||||
}
|
||||
|
||||
// tree parsing algorithm
|
||||
@ -289,6 +287,7 @@ Layer::RemoveChild(Layer *layer)
|
||||
STRACE(("Layer(%s)::RemoveChild(%s) END\n", Name(), layer->Name()));
|
||||
}
|
||||
|
||||
|
||||
//! Removes the calling layer from the tree
|
||||
void
|
||||
Layer::RemoveSelf()
|
||||
@ -301,19 +300,21 @@ Layer::RemoveSelf()
|
||||
fParent->RemoveChild(this);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\return true if the child is owned by this Layer, false if not
|
||||
*/
|
||||
bool
|
||||
Layer::HasChild(Layer* layer)
|
||||
{
|
||||
for (Layer* child = FirstChild(); child; child = NextChild()) {
|
||||
for (Layer* child = FirstChild(); child; child = child->NextLayer()) {
|
||||
if (child == layer)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//! Returns the number of children
|
||||
uint32
|
||||
Layer::CountChildren() const
|
||||
@ -321,7 +322,7 @@ Layer::CountChildren() const
|
||||
uint32 count = 0;
|
||||
Layer* child = FirstChild();
|
||||
while (child != NULL) {
|
||||
child = NextChild();
|
||||
child = child->NextLayer();
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
@ -338,17 +339,17 @@ Layer::FindLayer(const int32 token)
|
||||
// (recursive) search for a layer based on its view token
|
||||
|
||||
// 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)
|
||||
return child;
|
||||
}
|
||||
|
||||
|
||||
// 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))
|
||||
return layer;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -364,7 +365,7 @@ Layer::LayerAt(BPoint where)
|
||||
return this;
|
||||
|
||||
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))
|
||||
return layer;
|
||||
}
|
||||
@ -373,39 +374,35 @@ Layer::LayerAt(BPoint where)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// FirstChild
|
||||
|
||||
Layer*
|
||||
Layer::FirstChild() const
|
||||
{
|
||||
fCurrent = fFirstChild;
|
||||
return fCurrent;
|
||||
return fFirstChild;
|
||||
}
|
||||
|
||||
// NextChild
|
||||
|
||||
Layer*
|
||||
Layer::NextChild() const
|
||||
Layer::NextLayer() const
|
||||
{
|
||||
fCurrent = fCurrent->fNextSibling;
|
||||
return fCurrent;
|
||||
return fNextSibling;
|
||||
}
|
||||
|
||||
// PreviousChild
|
||||
|
||||
Layer*
|
||||
Layer::PreviousChild() const
|
||||
Layer::PreviousLayer() const
|
||||
{
|
||||
fCurrent = fCurrent->fPreviousSibling;
|
||||
return fCurrent;
|
||||
return fPreviousSibling;
|
||||
}
|
||||
|
||||
// LastChild
|
||||
|
||||
Layer*
|
||||
Layer::LastChild() const
|
||||
{
|
||||
fCurrent = fLastChild;
|
||||
return fCurrent;
|
||||
return fLastChild;
|
||||
}
|
||||
|
||||
// SetName
|
||||
|
||||
void
|
||||
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
|
||||
// Should call this AFTER region rebuilding and redrawing.
|
||||
// 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);
|
||||
|
||||
BRegion oldFullVisible(fFullVisible);
|
||||
@ -709,7 +706,7 @@ Layer::ResizeBy(float x, float y)
|
||||
// TODO: ResizedByHook(x,y,true) is called from inside _ResizeLayerFrameBy
|
||||
// Should call this AFTER region rebuilding and redrawing.
|
||||
// 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);
|
||||
}
|
||||
|
||||
@ -1188,7 +1185,7 @@ Layer::_ResizeLayerFrameBy(float x, float y)
|
||||
// call hook function
|
||||
ResizedByHook(dx, dy, true); // automatic
|
||||
|
||||
for (Layer* child = LastChild(); child; child = PreviousChild())
|
||||
for (Layer* child = LastChild(); child; child = child->PreviousLayer())
|
||||
child->_ResizeLayerFrameBy(dx, dy);
|
||||
}
|
||||
}
|
||||
@ -1201,7 +1198,7 @@ Layer::_RezizeLayerRedrawMore(BRegion ®, float dx, float dy)
|
||||
if (dx == 0 && dy == 0)
|
||||
return;
|
||||
|
||||
for (Layer* child = LastChild(); child; child = PreviousChild()) {
|
||||
for (Layer* child = LastChild(); child; child = child->PreviousLayer()) {
|
||||
uint16 rm = child->fResizeMode & 0x0000FFFF;
|
||||
|
||||
if ((rm & 0x0F0F) == (uint16)B_FOLLOW_LEFT_RIGHT || (rm & 0xF0F0) == (uint16)B_FOLLOW_TOP_BOTTOM) {
|
||||
@ -1250,7 +1247,7 @@ Layer::_ResizeLayerFullUpdateOnResize(BRegion ®, float dx, float dy)
|
||||
if (dx == 0 && dy == 0)
|
||||
return;
|
||||
|
||||
for (Layer* child = LastChild(); child; child = PreviousChild()) {
|
||||
for (Layer* child = LastChild(); child; child = child->PreviousLayer()) {
|
||||
uint16 rm = child->fResizeMode & 0x0000FFFF;
|
||||
|
||||
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
|
||||
_ReserveRegions(common);
|
||||
|
||||
for (Layer *child = LastChild(); child; child = PreviousChild()) {
|
||||
for (Layer *child = LastChild(); child; child = child->PreviousLayer()) {
|
||||
if (child == startFrom)
|
||||
fullRebuild = true;
|
||||
|
||||
@ -1372,7 +1369,7 @@ Layer::_RebuildVisibleRegions(const BRegion &invalid,
|
||||
// allow this layer to hide some parts from its children
|
||||
_ReserveRegions(common);
|
||||
|
||||
for (Layer *child = LastChild(); child; child = PreviousChild()) {
|
||||
for (Layer *child = LastChild(); child; child = child->PreviousLayer()) {
|
||||
child->_RebuildVisibleRegions(invalid, common, child->LastChild());
|
||||
|
||||
// to let children know much they can take from parent's visible region
|
||||
@ -1385,7 +1382,7 @@ Layer::_RebuildVisibleRegions(const BRegion &invalid,
|
||||
_RebuildDrawingRegion();
|
||||
}
|
||||
|
||||
// _RebuildDrawingRegion
|
||||
|
||||
void
|
||||
Layer::_RebuildDrawingRegion()
|
||||
{
|
||||
@ -1398,12 +1395,14 @@ Layer::_RebuildDrawingRegion()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Layer::_ReserveRegions(BRegion ®)
|
||||
{
|
||||
// Empty for Layer objects
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Layer::_ClearVisibleRegions()
|
||||
{
|
||||
@ -1411,20 +1410,24 @@ Layer::_ClearVisibleRegions()
|
||||
|
||||
fVisible.MakeEmpty();
|
||||
fFullVisible.MakeEmpty();
|
||||
for (Layer *child = LastChild(); child; child = PreviousChild())
|
||||
for (Layer *child = LastChild(); child; child = child->PreviousLayer())
|
||||
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
|
||||
Layer::MarkForRebuild(const BRegion &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
|
||||
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
|
||||
Layer::_GetAllRebuildDirty(BRegion *totalReg)
|
||||
{
|
||||
totalReg->Include(&fDirtyForRebuild);
|
||||
|
||||
for (Layer *child = LastChild(); child; child = PreviousChild())
|
||||
for (Layer *child = LastChild(); child; child = child->PreviousLayer())
|
||||
child->_GetAllRebuildDirty(totalReg);
|
||||
|
||||
fDirtyForRebuild.MakeEmpty();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Layer::_AllRedraw(const BRegion &invalid)
|
||||
{
|
||||
@ -1474,11 +1479,11 @@ Layer::_AllRedraw(const BRegion &invalid)
|
||||
}
|
||||
}
|
||||
|
||||
for (Layer *child = LastChild(); child != NULL; child = PreviousChild()) {
|
||||
if (!(child->IsHidden())) {
|
||||
for (Layer *child = LastChild(); child != NULL; child = child->PreviousLayer()) {
|
||||
if (!child->IsHidden()) {
|
||||
BRegion common(child->fFullVisible);
|
||||
common.IntersectWith(&invalid);
|
||||
|
||||
|
||||
if (common.CountRects() > 0)
|
||||
child->_AllRedraw(invalid);
|
||||
}
|
||||
@ -1489,11 +1494,11 @@ Layer::_AllRedraw(const BRegion &invalid)
|
||||
void
|
||||
Layer::_AddToViewsWithInvalidCoords() const
|
||||
{
|
||||
if (fServerWin) {
|
||||
fServerWin->ClientViewsWithInvalidCoords().AddInt32("_token", fViewToken);
|
||||
fServerWin->ClientViewsWithInvalidCoords().AddPoint("where", fFrame.LeftTop());
|
||||
fServerWin->ClientViewsWithInvalidCoords().AddFloat("width", fFrame.Width());
|
||||
fServerWin->ClientViewsWithInvalidCoords().AddFloat("height", fFrame.Height());
|
||||
if (fWindow) {
|
||||
fWindow->ClientViewsWithInvalidCoords().AddInt32("_token", fViewToken);
|
||||
fWindow->ClientViewsWithInvalidCoords().AddPoint("where", fFrame.LeftTop());
|
||||
fWindow->ClientViewsWithInvalidCoords().AddFloat("width", fFrame.Width());
|
||||
fWindow->ClientViewsWithInvalidCoords().AddFloat("height", fFrame.Height());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1501,8 +1506,8 @@ Layer::_AddToViewsWithInvalidCoords() const
|
||||
void
|
||||
Layer::_SendViewCoordUpdateMsg() const
|
||||
{
|
||||
if (fServerWin && !fServerWin->ClientViewsWithInvalidCoords().IsEmpty()) {
|
||||
fServerWin->SendMessageToClient(&fServerWin->ClientViewsWithInvalidCoords());
|
||||
fServerWin->ClientViewsWithInvalidCoords().MakeEmpty();
|
||||
if (fWindow && !fWindow->ClientViewsWithInvalidCoords().IsEmpty()) {
|
||||
fWindow->SendMessageToClient(&fWindow->ClientViewsWithInvalidCoords());
|
||||
fWindow->ClientViewsWithInvalidCoords().MakeEmpty();
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,10 @@
|
||||
#ifndef _LAYER_H_
|
||||
#define _LAYER_H_
|
||||
|
||||
|
||||
#include "RGBColor.h"
|
||||
#include "ServerWindow.h"
|
||||
|
||||
#include <GraphicsDefs.h>
|
||||
#include <List.h>
|
||||
#include <Locker.h>
|
||||
@ -18,8 +22,6 @@
|
||||
#include <Rect.h>
|
||||
#include <Region.h>
|
||||
|
||||
#include "RGBColor.h"
|
||||
#include "ServerWindow.h"
|
||||
|
||||
enum {
|
||||
B_LAYER_NONE = 1,
|
||||
@ -85,10 +87,10 @@ class Layer {
|
||||
Layer* FindLayer(const int32 token);
|
||||
Layer* LayerAt(BPoint where);
|
||||
|
||||
virtual Layer* FirstChild() const;
|
||||
virtual Layer* NextChild() const;
|
||||
virtual Layer* PreviousChild() const;
|
||||
virtual Layer* LastChild() const;
|
||||
Layer* FirstChild() const;
|
||||
Layer* LastChild() const;
|
||||
Layer* NextLayer() const;
|
||||
Layer* PreviousLayer() const;
|
||||
|
||||
void SetAsTopLayer(bool option)
|
||||
{ fIsTopLayer = option; }
|
||||
@ -170,9 +172,9 @@ class Layer {
|
||||
|
||||
// app_server objects getters
|
||||
ServerWindow* Window() const
|
||||
{ return fServerWin; }
|
||||
{ return fWindow; }
|
||||
ServerApp* App() const
|
||||
{ return fServerWin? fServerWin->App(): NULL; }
|
||||
{ return fWindow ? fWindow->App() : NULL; }
|
||||
inline WinBorder* Owner() const
|
||||
{ return fOwner; }
|
||||
RootLayer* GetRootLayer() const
|
||||
@ -243,7 +245,7 @@ class Layer {
|
||||
|
||||
DrawingEngine* fDriver;
|
||||
RootLayer* fRootLayer;
|
||||
ServerWindow* fServerWin;
|
||||
ServerWindow* fWindow;
|
||||
WinBorder* fOwner;
|
||||
|
||||
DrawState* fDrawState;
|
||||
@ -253,8 +255,6 @@ class Layer {
|
||||
Layer* fNextSibling;
|
||||
Layer* fFirstChild;
|
||||
Layer* fLastChild;
|
||||
|
||||
mutable Layer* fCurrent;
|
||||
|
||||
int32 fViewToken;
|
||||
uint32 fFlags;
|
||||
|
@ -70,10 +70,7 @@ RootLayer::RootLayer(const char *name, int32 workspaceCount,
|
||||
fWsCount(0),
|
||||
fWorkspace(new Workspace*[kMaxWorkspaceCount]),
|
||||
fWorkspacesLayer(NULL),
|
||||
fWMState(),
|
||||
fWinBorderIndex(0),
|
||||
|
||||
fScreenShotIndex(1)
|
||||
fWMState()
|
||||
{
|
||||
//NOTE: be careful about this one.
|
||||
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
|
||||
// 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
|
||||
fWorkspace[fActiveWksIndex] = new Workspace(fActiveWksIndex, 0xFF00FF00,
|
||||
kDefaultWorkspaceColor);
|
||||
@ -144,6 +135,10 @@ RootLayer::~RootLayer()
|
||||
delete fWorkspace[i];
|
||||
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.
|
||||
|
||||
#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
|
||||
RootLayer::AddWinBorder(WinBorder* winBorder)
|
||||
{
|
||||
@ -584,43 +552,36 @@ void
|
||||
RootLayer::SaveWorkspaceData(const char *path)
|
||||
{
|
||||
BMessage msg,dummy;
|
||||
BFile file(path,B_READ_WRITE | B_CREATE_FILE);
|
||||
|
||||
if(file.InitCheck()!=B_OK)
|
||||
{
|
||||
BFile file(path, B_READ_WRITE | B_CREATE_FILE);
|
||||
|
||||
if (file.InitCheck() != B_OK) {
|
||||
printf("ERROR: Couldn't save workspace data in RootLayer\n");
|
||||
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
|
||||
// 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);
|
||||
if(msg.FindMessage(string,&dummy)==B_OK)
|
||||
msg.RemoveName(string);
|
||||
}
|
||||
}
|
||||
|
||||
for(int32 i=0; i<count; i++)
|
||||
{
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
sprintf(string,"workspace %ld",i);
|
||||
|
||||
Workspace *ws=(Workspace*)fWorkspace[i];
|
||||
|
||||
if(!ws)
|
||||
{
|
||||
Workspace *ws = (Workspace*)fWorkspace[i];
|
||||
|
||||
if (!ws) {
|
||||
dummy.MakeEmpty();
|
||||
ws->PutSettings(&dummy,i);
|
||||
msg.AddMessage(string,&dummy);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// We're not supposed to have this happen, but we'll suck it up, anyway. :P
|
||||
Workspace::PutDefaultSettings(&msg,i);
|
||||
}
|
||||
@ -631,25 +592,82 @@ RootLayer::SaveWorkspaceData(const char *path)
|
||||
void
|
||||
RootLayer::HideWinBorder(WinBorder* winBorder)
|
||||
{
|
||||
Lock();
|
||||
hide_winBorder(winBorder);
|
||||
Unlock();
|
||||
BAutolock _(fAllRegionsLock);
|
||||
|
||||
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
|
||||
RootLayer::ShowWinBorder(WinBorder* winBorder)
|
||||
{
|
||||
Lock();
|
||||
show_winBorder(winBorder);
|
||||
Unlock();
|
||||
BAutolock _(fAllRegionsLock);
|
||||
|
||||
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::RevealNewWMState(Workspace::State &oldWMState)
|
||||
{
|
||||
// clean fWMState
|
||||
// clear fWMState
|
||||
fWMState.Focus = NULL;
|
||||
fWMState.Front = NULL;
|
||||
fWMState.Active = NULL;
|
||||
@ -657,9 +675,6 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState)
|
||||
|
||||
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
|
||||
if (oldWMState.Active != fWMState.Active) {
|
||||
if (oldWMState.Active)
|
||||
@ -710,35 +725,50 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState)
|
||||
continue;
|
||||
|
||||
bool stillPresent = false;
|
||||
for (int32 j = 0; j < newWindowCount; ++j)
|
||||
for (int32 j = 0; j < newWindowCount; ++j) {
|
||||
if (layer == fWMState.WindowList.ItemAtFast(j)) {
|
||||
stillPresent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!stillPresent) {
|
||||
MarkForRebuild(layer->FullVisible());
|
||||
MarkForRedraw(layer->FullVisible());
|
||||
|
||||
layer->_ClearVisibleRegions();
|
||||
}
|
||||
else {
|
||||
} else
|
||||
oldStrippedList.AddItem(layer);
|
||||
}
|
||||
}
|
||||
|
||||
fFirstChild = NULL;
|
||||
fLastChild = NULL;
|
||||
|
||||
// for new windows, invalidate(rebuild & redraw) the maximum that it can occupy.
|
||||
for (int32 i = 0; i < newWindowCount; ++i) {
|
||||
Layer *layer = static_cast<Layer*>(fWMState.WindowList.ItemAtFast(i));
|
||||
if (!layer)
|
||||
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;
|
||||
for (int32 j = 0; j < oldWindowCount; ++j)
|
||||
for (int32 j = 0; j < oldWindowCount; ++j) {
|
||||
if (layer == oldWMState.WindowList.ItemAtFast(j)) {
|
||||
isNewWindow = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isNewWindow) {
|
||||
BRegion invalid;
|
||||
|
||||
@ -747,10 +777,8 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState)
|
||||
|
||||
MarkForRebuild(invalid);
|
||||
MarkForRedraw(invalid);
|
||||
}
|
||||
else {
|
||||
} else
|
||||
newStrippedList.AddItem(layer);
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
TriggerRebuild();
|
||||
TriggerRedraw();
|
||||
}
|
||||
else if (redraw) {
|
||||
} else if (redraw) {
|
||||
MarkForRedraw(dirtyRegion);
|
||||
TriggerRedraw();
|
||||
}
|
||||
@ -814,8 +841,7 @@ RootLayer::SetActive(WinBorder* newActive, bool activate)
|
||||
returnValue = ActiveWorkspace()->AttemptToMoveToBack(newActive);
|
||||
|
||||
RevealNewWMState(oldWMState);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fWorkspace[i]->AttemptToActivate(newActive);
|
||||
// NOTE: for multiple monitor support, if a workspaces is mapped to
|
||||
// a Screen, we must invalidate/redraw to see the change.
|
||||
@ -846,7 +872,7 @@ RootLayer::_ChildAt(BPoint where)
|
||||
if (VisibleRegion().Contains(where))
|
||||
return NULL;
|
||||
|
||||
for (Layer* child = LastChild(); child; child = PreviousChild()) {
|
||||
for (Layer* child = LastChild(); child; child = child->PreviousLayer()) {
|
||||
if (child->FullVisible().Contains(where))
|
||||
return child;
|
||||
}
|
||||
@ -926,76 +952,6 @@ RootLayer::DragMessage(void) const
|
||||
|
||||
// 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
|
||||
RootLayer::change_winBorder_feel(WinBorder *winBorder, int32 newFeel)
|
||||
@ -1038,6 +994,7 @@ RootLayer::change_winBorder_feel(WinBorder *winBorder, int32 newFeel)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RootLayer::Draw(const BRect &r)
|
||||
{
|
||||
|
@ -63,12 +63,6 @@ public:
|
||||
virtual void ScrollBy(float x, float y)
|
||||
{ /* 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 ShowWinBorder(WinBorder* winBorder);
|
||||
void SetWinBorderWorskpaces(WinBorder *winBorder,
|
||||
@ -127,9 +121,6 @@ friend class Desktop;
|
||||
void AddSubsetWinBorder(WinBorder *winBorder, WinBorder *toWinBorder);
|
||||
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 MouseEventHandler(BMessage *msg);
|
||||
@ -155,9 +146,6 @@ friend class Desktop;
|
||||
// with RootLayer, but after Axel's refractoring this should go in
|
||||
// WorkspaceLayer, I think.
|
||||
Workspace::State fWMState;
|
||||
mutable int32 fWinBorderIndex;
|
||||
|
||||
int32 fScreenShotIndex;
|
||||
|
||||
#if ON_SCREEN_DEBUGGING_INFO
|
||||
friend class DebugInfoManager;
|
||||
|
@ -104,10 +104,10 @@ WinBorder::WinBorder(const BRect &frame,
|
||||
cnt(0) // for debugging
|
||||
{
|
||||
// unlike BViews, windows start off as hidden
|
||||
fHidden = true;
|
||||
fServerWin = window;
|
||||
fAdFlags = fAdFlags | B_LAYER_CHILDREN_DEPENDANT;
|
||||
fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE;
|
||||
fHidden = true;
|
||||
fWindow = window;
|
||||
fAdFlags = fAdFlags | B_LAYER_CHILDREN_DEPENDANT;
|
||||
fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE;
|
||||
|
||||
QuietlySetFeel(feel);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user