Added skeleton Desktop functions and skeleton Layer class

Tweaked files dependent files to include Desktop.h


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2547 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-01-24 15:19:27 +00:00
parent 0934499c5d
commit 34a81c2f00
7 changed files with 1037 additions and 27 deletions

View File

@ -24,6 +24,8 @@
// Description: Handles the system's cursor infrastructure // Description: Handles the system's cursor infrastructure
// //
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "DisplayDriver.h"
#include "Desktop.h"
#include "CursorManager.h" #include "CursorManager.h"
#include "ServerCursor.h" #include "ServerCursor.h"
#include <Errors.h> #include <Errors.h>
@ -147,9 +149,9 @@ void CursorManager::RemoveAppCursors(const char *signature)
void CursorManager::ShowCursor(void) void CursorManager::ShowCursor(void)
{ {
acquire_sem(_lock); acquire_sem(_lock);
// TODO: enable this when Desktop.h is added to server
// DisplayDriver *driver=GetGfxDriver(); DisplayDriver *driver=GetGfxDriver();
// driver->ShowCursor(); driver->ShowCursor();
release_sem(_lock); release_sem(_lock);
} }
@ -157,9 +159,9 @@ void CursorManager::ShowCursor(void)
void CursorManager::HideCursor(void) void CursorManager::HideCursor(void)
{ {
acquire_sem(_lock); acquire_sem(_lock);
// TODO: enable this when Desktop.h is added to server
// DisplayDriver *driver=GetGfxDriver(); DisplayDriver *driver=GetGfxDriver();
// driver->HideCursor(); driver->HideCursor();
release_sem(_lock); release_sem(_lock);
} }
@ -167,9 +169,9 @@ void CursorManager::HideCursor(void)
void CursorManager::ObscureCursor(void) void CursorManager::ObscureCursor(void)
{ {
acquire_sem(_lock); acquire_sem(_lock);
// TODO: enable this when Desktop.h is added to server
// DisplayDriver *driver=GetGfxDriver(); DisplayDriver *driver=GetGfxDriver();
// driver->ObscureCursor(); driver->ObscureCursor();
release_sem(_lock); release_sem(_lock);
} }
@ -183,9 +185,8 @@ void CursorManager::SetCursor(int32 token)
ServerCursor *c=_FindCursor(token); ServerCursor *c=_FindCursor(token);
if(c) if(c)
{ {
// TODO: enable this when Desktop.h is added to server DisplayDriver *driver=GetGfxDriver();
// DisplayDriver *driver=GetGfxDriver(); driver->SetCursor(c);
// driver->SetCursor(c);
_current_which=B_CURSOR_OTHER; _current_which=B_CURSOR_OTHER;
} }
release_sem(_lock); release_sem(_lock);
@ -195,8 +196,7 @@ void CursorManager::SetCursor(cursor_which which)
{ {
acquire_sem(_lock); acquire_sem(_lock);
// TODO: enable this when Desktop.h is added to server DisplayDriver *driver=GetGfxDriver();
/* DisplayDriver *driver=GetGfxDriver();
switch(which) switch(which)
{ {
case B_CURSOR_DEFAULT: case B_CURSOR_DEFAULT:
@ -256,7 +256,7 @@ void CursorManager::SetCursor(cursor_which which)
default: default:
break; break;
} }
*/
release_sem(_lock); release_sem(_lock);
} }

View File

@ -0,0 +1,129 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Desktop.cpp
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: Functions used to work with workspaces and general desktop stuff
//
//------------------------------------------------------------------------------
#include "DisplayDriver.h"
#include "Desktop.h"
//#include "ServerWindow.h"
namespace desktop_private {
int8 *dragmessage;
int32 dragmessagesize;
sem_id draglock;
}
void InitDesktop(void)
{
}
void ShutdownDesktop(void)
{
}
void AddWorkspace(int32 index=-1)
{
}
void DeleteWorkspace(int32 index)
{
}
int32 CountWorkspaces(void)
{
return 0;
}
void SetWorkspaceCount(int32 count)
{
}
int32 CurrentWorkspace(screen_id screen=B_MAIN_SCREEN_ID)
{
return 0;
}
void SetWorkspace(int32 workspace, screen_id screen=B_MAIN_SCREEN_ID)
{
}
void SetScreen(screen_id id)
{
}
int32 CountScreens(void)
{
return 0;
}
screen_id ActiveScreen(void)
{
return B_MAIN_SCREEN_ID;
}
DisplayDriver *GetGfxDriver(screen_id screen=B_MAIN_SCREEN_ID)
{
return NULL;
}
status_t SetSpace(int32 index, int32 res, bool stick=true, screen_id screen=B_MAIN_SCREEN_ID)
{
return B_ERROR;
}
void AddWindowToDesktop(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)
{
}
void RemoveWindowFromDesktop(ServerWindow *win)
{
}
ServerWindow *GetActiveWindow(void)
{
return NULL;
}
void SetActiveWindow(ServerWindow *win)
{
}
Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)
{
return NULL;
}
void set_drag_message(int32 size, int8 *flattened)
{
}
int8 *get_drag_message(int32 *size)
{
return NULL;
}
void empty_drag_message(void)
{
}

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Desktop.h
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: Functions used to work with workspaces and general desktop stuff
//
//------------------------------------------------------------------------------
#ifndef DESKTOP_H_
#define DESKTOP_H_
#include <Window.h>
#include <GraphicsDefs.h>
class ServerWindow;
class DisplayDriver;
class Layer;
void InitDesktop(void);
void ShutdownDesktop(void);
void AddWorkspace(int32 index=-1);
void DeleteWorkspace(int32 index);
int32 CountWorkspaces(void);
void SetWorkspaceCount(int32 count);
int32 CurrentWorkspace(screen_id screen=B_MAIN_SCREEN_ID);
void SetWorkspace(int32 workspace, screen_id screen=B_MAIN_SCREEN_ID);
void SetScreen(screen_id id);
int32 CountScreens(void);
screen_id ActiveScreen(void);
DisplayDriver *GetGfxDriver(screen_id screen=B_MAIN_SCREEN_ID);
status_t SetSpace(int32 index, int32 res, bool stick=true, screen_id screen=B_MAIN_SCREEN_ID);
void AddWindowToDesktop(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID);
void RemoveWindowFromDesktop(ServerWindow *win);
ServerWindow *GetActiveWindow(void);
void SetActiveWindow(ServerWindow *win);
Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID);
void set_drag_message(int32 size, int8 *flattened);
int8* get_drag_message(int32 *size);
void empty_drag_message(void);
#endif

View File

@ -25,6 +25,7 @@ Server app_server :
# Manager Classes # Manager Classes
AppServer.cpp AppServer.cpp
CursorManager.cpp CursorManager.cpp
Desktop.cpp
ServerApp.cpp ServerApp.cpp
# Font Classes # Font Classes
@ -36,6 +37,7 @@ Server app_server :
AccelerantDriver.cpp AccelerantDriver.cpp
Decorator.cpp Decorator.cpp
DisplayDriver.cpp DisplayDriver.cpp
Layer.cpp
ServerBitmap.cpp ServerBitmap.cpp
ServerCursor.cpp ServerCursor.cpp
; ;

View File

@ -0,0 +1,705 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Layer.cpp
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: Class used for rendering to the frame buffer. One layer per
// view on screen and also for window decorators
//
//------------------------------------------------------------------------------
#include "Layer.h"
#include "RectUtils.h"
//#include "ServerWindow.h"
#include "PortLink.h"
#include <string.h>
#include <stdio.h>
Layer::Layer(BRect frame, const char *name, int32 resize, int32 flags,ServerWindow *win)
{
/* // frame is in _parent layer's coordinates
if(frame.IsValid())
_frame=frame;
else
_frame.Set(0,0,1,1);
_name=new BString(name);
// Layer does not start out as a part of the tree
_parent=NULL;
_uppersibling=NULL;
_lowersibling=NULL;
_topchild=NULL;
_bottomchild=NULL;
_visible=new BRegion(Bounds());
_full=new BRegion(Bounds());
_invalid=NULL;
_serverwin=win;
// TODO: Can't remember why we have these... Find out why
_view_token=0;
_flags=flags;
_hidecount=0;
_is_dirty=false;
_is_updating=false;
_level=0;
_layerdata=new LayerData;
*/
}
Layer::~Layer(void)
{
/* if(_visible)
{
delete _visible;
_visible=NULL;
}
if(_full)
{
delete _full;
_full=NULL;
}
if(_invalid)
{
delete _invalid;
_invalid=NULL;
}
if(_name)
{
delete _name;
_name=NULL;
}
if(_layerdata)
{
delete _layerdata;
_layerdata=NULL;
}
*/
}
// Tested for adding children with 1 and 2 child cases, but not more
void Layer::AddChild(Layer *layer, Layer *before=NULL, bool rebuild)
{
/* // Adds a layer to the top of the layer's children
if(layer->_parent!=NULL)
{
printf("ERROR: AddChild(): View already has a _parent\n");
return;
}
layer->_parent=this;
if(layer->_visible && layer->_hidecount==0 && _visible)
{
// Technically, we could safely take the address of ConvertToParent(BRegion)
// but we don't just to avoid a compiler nag
BRegion *reg=new BRegion(layer->ConvertToParent(layer->_visible));
_visible->Exclude(reg);
delete reg;
}
// we need to change this to a loop for each _lowersibling of the layer
if(_topchild!=NULL)
{
// we're adding to the back side of the stack??
layer->_lowersibling=_topchild;
// added layer will be at the bottom of the stack
_topchild->_uppersibling=layer;
for(Layer *lay=layer->_lowersibling; lay!=NULL; lay=lay->_lowersibling)
{
if(layer->_frame.Intersects(lay->_frame))
{
if(lay->_visible && lay->_hidecount==0)
{
// reg is what is _visible in the layer's _parent's coordinate system
BRegion *reg=new BRegion(ConvertToParent(layer->_visible));
// reg2 is the layer's _visible region in the sibling's coordinate system
BRegion *reg2=new BRegion(lay->ConvertFromParent(reg));
delete reg;
// layer->_lowersibling->_visible->Exclude(reg2);
// lowersiblings occupy screen space _above_ a layer, so the layer itself
// must remove from its _visible region
layer->_visible->Exclude(reg2);
delete reg2;
}
}
}
}
else
_bottomchild=layer;
_topchild=layer;
layer->_level=_level+1;
*/
}
// Tested for cases with 1 and 2 children, but no more than that
void Layer::RemoveChild(Layer *layer, bool rebuild)
{
/* // Remove a layer from the tree
if(layer->_parent==NULL)
{
printf("ERROR: RemoveChild(): View doesn't have a _parent\n");
return;
}
if(layer->_parent!=this)
{
printf("ERROR: RemoveChild(): View is not a child of this layer\n");
return;
}
if(_hidecount==0 && layer->_visible && layer->_parent->_visible)
{
BRegion *reg=new BRegion(ConvertToParent(_visible));
layer->_parent->_visible->Include(reg);
delete reg;
}
// Take care of _parent
layer->_parent=NULL;
if(_topchild==layer)
_topchild=layer->_lowersibling;
if(_bottomchild==layer)
_bottomchild=layer->_uppersibling;
// Take care of siblings
if(layer->_uppersibling!=NULL)
layer->_uppersibling->_lowersibling=layer->_lowersibling;
if(layer->_lowersibling!=NULL)
layer->_lowersibling->_uppersibling=layer->_uppersibling;
layer->_uppersibling=NULL;
layer->_lowersibling=NULL;
RebuildRegions();
*/
}
void Layer::RemoveSelf(bool rebuild)
{
/* // A Layer removes itself from the tree (duh)
if(_parent==NULL)
{
printf("ERROR: RemoveSelf(): View doesn't have a _parent\n");
return;
}
_parent->RemoveChild(this);
*/
}
Layer *Layer::GetChildAt(BPoint pt, bool recursive=false)
{
/* // Find out which child gets hit if we click at a certain spot. Returns NULL
// if there are no _visible children or if the click does not hit a child layer
// If recursive==true, then it will continue to call until it reaches a layer
// which has no children, i.e. a layer that is at the top of its 'branch' in
// the layer tree
Layer *child;
if(recursive)
{
for(child=_bottomchild; child!=NULL; child=child->_uppersibling)
{
if(child->_bottomchild!=NULL)
child->GetChildAt(pt,true);
if(child->_hidecount>0)
continue;
if(child->_frame.Contains(pt))
return child;
}
}
else
{
for(child=_bottomchild; child!=NULL; child=child->_uppersibling)
{
if(child->_hidecount>0)
continue;
// if(child->_visible && child->_visible->Contains(ConvertFromTop(pt)))
// printf("child hit by mouse. News at 11\n");
if(child->_frame.Contains(pt))
return child;
}
}
*/ return NULL;
}
BRect Layer::Bounds(void)
{
return _frame.OffsetToCopy(0,0);
}
BRect Layer::Frame(void)
{
return _frame;
}
void Layer::PruneTree(void)
{
/* // recursively deletes all children (and grandchildren, etc) of the passed layer
// This is mostly used for server shutdown or deleting a workspace
Layer *lay,*nextlay;
lay=_topchild;
_topchild=NULL;
while(lay!=NULL)
{
if(lay->_topchild!=NULL)
{
// lay->_topchild->PruneTree();
lay->PruneTree();
}
nextlay=lay->_lowersibling;
lay->_lowersibling=NULL;
delete lay;
lay=nextlay;
}
// Man, this thing is short. Elegant, ain't it? :P
*/
}
Layer *Layer::FindLayer(int32 token)
{
/* // recursive search for a layer based on its view token
Layer *lay, *trylay;
// Search child layers first
for(lay=_topchild; lay!=NULL; lay=lay->_lowersibling)
{
if(lay->_view_token==token)
return lay;
}
// Hmmm... not in this layer's children. Try lower descendants
for(lay=_topchild; lay!=NULL; lay=lay->_lowersibling)
{
trylay=lay->FindLayer(token);
if(trylay)
return trylay;
}
// Well, we got this far in the function, so apparently there is no match to be found
*/ return NULL;
}
// Tested
void Layer::Invalidate(BRegion region)
{
/* int32 i;
BRect r;
// See if the region intersects with our current area
if(region.Intersects(Bounds()) && _hidecount==0)
{
BRegion clippedreg(region);
clippedreg.IntersectWith(_visible);
if(clippedreg.CountRects()>0)
{
_is_dirty=true;
if(_invalid)
_invalid->Include(&clippedreg);
else
_invalid=new BRegion(clippedreg);
}
}
BRegion *reg;
for(Layer *lay=_topchild;lay!=NULL; lay=lay->_lowersibling)
{
if(lay->_hidecount==0)
{
reg=new BRegion(lay->ConvertFromParent(&region));
for(i=0;i<reg->CountRects();i++)
{
r=reg->RectAt(i);
if(_frame.Intersects(r))
lay->Invalidate(r);
}
delete reg;
}
}
*/
}
// Tested
void Layer::Invalidate(BRect rect)
{
/* // Make our own section dirty and pass it on to any children, if necessary....
// YES, WE ARE SHARING DIRT! Mudpies anyone? :D
// if(Frame().Intersects(rect) || Frame().Contains(rect))
if(TestRectIntersection(Frame(),rect))
{
// Clip the rectangle to the _visible region of the layer
// if(_visible->Intersects(rect))
if(TestRegionIntersection(_visible,rect))
{
// BRegion reg(rect);
// reg.IntersectWith(_visible);
BRegion reg(*_visible);
IntersectRegionWith(&reg,rect);
if(reg.CountRects()>0)
{
_is_dirty=true;
if(_invalid)
_invalid->Include(&reg);
else
_invalid=new BRegion(reg);
}
else
{
}
}
else
{
}
}
for(Layer *lay=_topchild;lay!=NULL; lay=lay->_lowersibling)
lay->Invalidate(lay->ConvertFromParent(rect));
*/
}
void Layer::RequestDraw(const BRect &r)
{
// TODO: Implement and fix
/* if(_visible==NULL || _hidecount>0)
return;
if(_serverwin)
{
if(_invalid==NULL)
_invalid=new BRegion(*_visible);
_serverwin->RequestDraw(_invalid->Frame());
delete _invalid;
_invalid=NULL;
}
_is_dirty=false;
for(Layer *lay=_topchild; lay!=NULL; lay=lay->_lowersibling)
{
if(lay->IsDirty())
lay->RequestDraw();
}
*/
}
bool Layer::IsDirty(void) const
{
// return _is_dirty;
return (!_invalid)?true:false;
}
void Layer::Show(void)
{
/* if(_hidecount==0)
return;
_hidecount--;
if(_hidecount==0)
{
BRegion *reg=new BRegion(ConvertToParent(_visible));
_parent->_visible->Exclude(reg);
delete reg;
_is_dirty=true;
}
Layer *child;
for(child=_topchild; child!=NULL; child=child->_lowersibling)
child->Show();
*/
}
void Layer::Hide(void)
{
/* if(_hidecount==0)
{
BRegion *reg=new BRegion(ConvertToParent(_visible));
_parent->_visible->Include(reg);
delete reg;
_parent->_is_dirty=true;
_is_dirty=true;
}
_hidecount++;
Layer *child;
for(child=_topchild; child!=NULL; child=child->_lowersibling)
child->Hide();
*/
}
// Tested
uint32 Layer::CountChildren(void)
{
/* uint32 i=0;
Layer *lay=_topchild;
while(lay!=NULL)
{
lay=lay->_lowersibling;
i++;
}
return i;
*/ return 0;
}
void Layer::MoveBy(float x, float y)
{
/* BRect oldframe(_frame);
_frame.OffsetBy(x,y);
if(_parent)
{
if(_parent->_invalid==NULL)
_parent->_invalid=new BRegion(oldframe);
else
_parent->_invalid->Include(oldframe);
}
// for(Layer *lay=_topchild; lay!=NULL; lay=lay->_lowersibling)
// lay->MoveBy(x,y);
// Invalidate(Frame());
*/
}
void Layer::ResizeBy(float x, float y)
{
/* BRect oldframe=_frame;
_frame.right+=x;
_frame.bottom+=y;
if(_parent)
_parent->RebuildRegions();
else
RebuildRegions();
// for(Layer *lay=_topchild; lay!=NULL; lay=lay->_lowersibling)
// lay->ResizeBy(x,y);
if(x<0 || y<0)
_parent->Invalidate(oldframe);
// Invalidate(Frame());
*/
}
void Layer::RebuildRegions(bool include_children=true)
{
/* BRegion *reg,*reg2;
if(_full)
_full->Include(Bounds());
else
_full=new BRegion(Bounds());
if(_visible)
_visible->Include(Bounds());
else
_visible=new BRegion(Bounds());
// Remove child footprints from _visible region
for(Layer *childlay=_topchild; childlay!=NULL; childlay=childlay->_lowersibling)
{
if(childlay->_visible && childlay->_hidecount==0)
{
// reg is what is _visible in the layer's _parent's coordinate system
reg=new BRegion(ConvertToParent(_visible));
// reg2 is the layer's _visible region in the sibling's coordinate system
reg2=new BRegion(childlay->ConvertFromParent(reg));
delete reg;
// lowersiblings occupy screen space _above_ a layer, so the layer itself
// must remove from its _visible region
_visible->Exclude(reg2);
delete reg2;
}
}
// Remove _lowersibling footprints, which are on top of the layer on screen
for(Layer *siblay=_lowersibling; siblay!=NULL; siblay=siblay->_lowersibling)
{
if(_frame.Intersects(siblay->_frame))
{
if(siblay->_visible && siblay->_hidecount==0)
{
// reg is what is _visible in the layer's _parent's coordinate system
reg=new BRegion(ConvertToParent(_visible));
// reg2 is the layer's _visible region in the sibling's coordinate system
reg2=new BRegion(siblay->ConvertFromParent(reg));
delete reg;
// lowersiblings occupy screen space _above_ a layer, so the layer itself
// must remove from its _visible region
_visible->Exclude(reg2);
delete reg2;
}
}
}
if(include_children)
{
for(Layer *lay=_topchild; lay!=NULL; lay=lay->_lowersibling)
{
if(lay->_topchild)
lay->RebuildRegions(true);
}
}
*/
}
void Layer::PrintToStream(void)
{
printf("-----------\nLayer %s\n",_name->String());
if(_parent)
printf("Parent: %s (%p)\n",_parent->_name->String(), _parent);
else
printf("Parent: NULL\n");
if(_uppersibling)
printf("Upper sibling: %s (%p)\n",_uppersibling->_name->String(), _uppersibling);
else
printf("Upper sibling: NULL\n");
if(_lowersibling)
printf("Lower sibling: %s (%p)\n",_lowersibling->_name->String(), _lowersibling);
else
printf("Lower sibling: NULL\n");
if(_topchild)
printf("Top child: %s (%p)\n",_topchild->_name->String(), _topchild);
else
printf("Top child: NULL\n");
if(_bottomchild)
printf("Bottom child: %s (%p)\n",_bottomchild->_name->String(), _bottomchild);
else
printf("Bottom child: NULL\n");
printf("Frame: "); _frame.PrintToStream();
printf("Token: %ld\nLevel: %ld\n",_view_token, _level);
printf("Hide count: %u\n",_hidecount);
if(_invalid)
{
printf("Invalid Areas: "); _invalid->PrintToStream();
}
else
printf("Invalid Areas: NULL\n");
if(_visible)
{
printf("Visible Areas: "); _visible->PrintToStream();
}
else
printf("Visible Areas: NULL\n");
printf("Is updating = %s\n",(_is_updating)?"yes":"no");
}
void Layer::PrintNode(void)
{
printf("-----------\nLayer %s\n",_name->String());
if(_parent)
printf("Parent: %s (%p)\n",_parent->_name->String(), _parent);
else
printf("Parent: NULL\n");
if(_uppersibling)
printf("Upper sibling: %s (%p)\n",_uppersibling->_name->String(), _uppersibling);
else
printf("Upper sibling: NULL\n");
if(_lowersibling)
printf("Lower sibling: %s (%p)\n",_lowersibling->_name->String(), _lowersibling);
else
printf("Lower sibling: NULL\n");
if(_topchild)
printf("Top child: %s (%p)\n",_topchild->_name->String(), _topchild);
else
printf("Top child: NULL\n");
if(_bottomchild)
printf("Bottom child: %s (%p)\n",_bottomchild->_name->String(), _bottomchild);
else
printf("Bottom child: NULL\n");
if(_visible)
{
printf("Visible Areas: "); _visible->PrintToStream();
}
else
printf("Visible Areas: NULL\n");
}
// Tested
BRect Layer::ConvertToParent(BRect rect)
{
return (rect.OffsetByCopy(_frame.LeftTop()));
}
// Tested
BRegion Layer::ConvertToParent(BRegion *reg)
{
BRegion newreg;
for(int32 i=0; i<reg->CountRects();i++)
newreg.Include(ConvertToParent(reg->RectAt(i)));
return BRegion(newreg);
}
// Tested
BRect Layer::ConvertFromParent(BRect rect)
{
return (rect.OffsetByCopy(_frame.left*-1,_frame.top*-1));
}
// Tested
BRegion Layer::ConvertFromParent(BRegion *reg)
{
BRegion newreg;
for(int32 i=0; i<reg->CountRects();i++)
newreg.Include(ConvertFromParent(reg->RectAt(i)));
return BRegion(newreg);
}
// Tested
BRegion Layer::ConvertToTop(BRegion *reg)
{
BRegion newreg;
for(int32 i=0; i<reg->CountRects();i++)
newreg.Include(ConvertToTop(reg->RectAt(i)));
return BRegion(newreg);
}
// Tested
BRect Layer::ConvertToTop(BRect rect)
{
if (_parent!=NULL)
return(_parent->ConvertToTop(rect.OffsetByCopy(_frame.LeftTop())) );
else
return(rect);
}
// Tested
BRegion Layer::ConvertFromTop(BRegion *reg)
{
BRegion newreg;
for(int32 i=0; i<reg->CountRects();i++)
newreg.Include(ConvertFromTop(reg->RectAt(i)));
return BRegion(newreg);
}
// Tested
BRect Layer::ConvertFromTop(BRect rect)
{
if (_parent!=NULL)
return(_parent->ConvertFromTop(rect.OffsetByCopy(_frame.LeftTop().x*-1,
_frame.LeftTop().y*-1)) );
else
return(rect);
}

View File

@ -0,0 +1,116 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Layer.h
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: Class used for rendering to the frame buffer. One layer per
// view on screen and also for window decorators
//
//------------------------------------------------------------------------------
#ifndef _LAYER_H_
#define _LAYER_H_
#include <GraphicsDefs.h>
#include <Rect.h>
#include <Region.h>
#include <List.h>
#include <String.h>
#include <OS.h>
#include "LayerData.h"
class ServerWindow;
class PortLink;
class Layer
{
public:
Layer(BRect frame, const char *name, int32 resize,
int32 flags,ServerWindow *win);
virtual ~Layer(void);
void AddChild(Layer *child, Layer *before=NULL, bool rebuild=true);
void RemoveChild(Layer *child, bool rebuild=true);
void RemoveSelf(bool rebuild=true);
uint32 CountChildren(void);
void MakeTopChild(void);
void MakeBottomChild(void);
Layer *FindLayer(int32 token);
Layer *GetChildAt(BPoint pt, bool recursive=false);
PortLink *GetLink(void);
void Invalidate(BRect rect);
void Invalidate(BRegion region);
void RebuildRegions(bool include_children=true);
void RequestDraw(const BRect &r);
bool IsDirty(void) const;
void Show(void);
void Hide(void);
BRect Bounds(void);
BRect Frame(void);
virtual void MoveBy(float x, float y);
void ResizeBy(float x, float y);
BRect ConvertToParent(BRect rect);
BRegion ConvertToParent(BRegion *reg);
BRect ConvertFromParent(BRect rect);
BRegion ConvertFromParent(BRegion *reg);
BRegion ConvertToTop(BRegion *reg);
BRect ConvertToTop(BRect rect);
BRegion ConvertFromTop(BRegion *reg);
BRect ConvertFromTop(BRect rect);
void PrintToStream(void);
void PrintNode(void);
void PruneTree(void);
protected:
BRect _frame;
Layer *_parent,
*_uppersibling,
*_lowersibling,
*_topchild,
*_bottomchild;
BRegion *_visible,
*_invalid,
*_full;
ServerWindow *_serverwin;
BString *_name;
int32 _view_token;
int32 _level;
int32 _flags;
uint8 _hidecount;
bool _is_dirty;
bool _is_updating;
LayerData *_layerdata;
PortLink *_portlink;
};
extern BLocker *layerlock;
extern BList *layerlist;
extern Layer *rootlayer;
#endif

View File

@ -27,12 +27,12 @@
#include <AppDefs.h> #include <AppDefs.h>
#include <List.h> #include <List.h>
#include <String.h> #include <String.h>
#include <PortLink.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <PortLink.h>
#include "CursorManager.h" #include "CursorManager.h"
//#include "Desktop.h" #include "Desktop.h"
#include "DisplayDriver.h" #include "DisplayDriver.h"
#include "FontServer.h" #include "FontServer.h"
#include "ServerApp.h" #include "ServerApp.h"
@ -80,8 +80,7 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, char *signature)
_appcursor=(defaultc)?new ServerCursor(defaultc):NULL; _appcursor=(defaultc)?new ServerCursor(defaultc):NULL;
_lock=create_sem(1,"ServerApp sem"); _lock=create_sem(1,"ServerApp sem");
// TODO: uncomment this and include Desktop.h when the desktop classes are done _driver=GetGfxDriver();
// _driver=get_gfxdriver();
} }
//! Does all necessary teardown for application //! Does all necessary teardown for application
@ -357,8 +356,6 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
} }
case GFX_SET_SCREEN_MODE: case GFX_SET_SCREEN_MODE:
{ {
// TODO: Enable when we have Desktop.h
/*
// Attached data // Attached data
// 1) int32 workspace # // 1) int32 workspace #
// 2) uint32 screen mode // 2) uint32 screen mode
@ -366,20 +363,18 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
int32 workspace=*((int32*)index); index+=sizeof(int32); int32 workspace=*((int32*)index); index+=sizeof(int32);
uint32 mode=*((uint32*)index); index+=sizeof(uint32); uint32 mode=*((uint32*)index); index+=sizeof(uint32);
SetScreenSpace(workspace,mode,*((bool*)index)); SetSpace(workspace,mode,*((bool*)index));
*/
break; break;
} }
case GFX_ACTIVATE_WORKSPACE: case GFX_ACTIVATE_WORKSPACE:
{ {
// TODO: Enable when we have Desktop.h
/*
// Attached data // Attached data
// 1) int32 workspace index // 1) int32 workspace index
// Error-checking is done in ActivateWorkspace, so this is a safe call // Error-checking is done in ActivateWorkspace, so this is a safe call
ActivateWorkspace(*((int32*)index)); SetWorkspace(*((int32*)index));
*/ break; break;
} }
// Theoretically, we could just call the driver directly, but we will // Theoretically, we could just call the driver directly, but we will