new code. use diff to see differences

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4577 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca 2003-09-08 21:18:39 +00:00
parent 80d0dc75a6
commit 92e26ba96d
10 changed files with 378 additions and 363 deletions

View File

@ -28,7 +28,6 @@
#include "ColorSet.h" #include "ColorSet.h"
#include "Decorator.h" #include "Decorator.h"
#include "DisplayDriver.h" #include "DisplayDriver.h"
#include <stdio.h> #include <stdio.h>
/*! /*!

View File

@ -30,6 +30,7 @@
#include "ServerConfig.h" #include "ServerConfig.h"
#include "ViewDriver.h" #include "ViewDriver.h"
#include "ServerWindow.h"
#if DISPLAYDRIVER == SCREENDRIVER #if DISPLAYDRIVER == SCREENDRIVER
#include "ScreenDriver.h" #include "ScreenDriver.h"
@ -39,12 +40,12 @@
#include "AccelerantDriver.h" #include "AccelerantDriver.h"
#endif #endif
#include "ServerWindow.h"
//#define DEBUG_DESKTOP //#define DEBUG_DESKTOP
#ifdef DEBUG_DESKTOP #ifdef DEBUG_DESKTOP
#include <stdio.h> # include <stdio.h>
# define STRACE(x) printf x
#else
# define STRACE(x) ;
#endif #endif
bool ReadOBOSWorkspaceData(void); bool ReadOBOSWorkspaceData(void);
@ -88,9 +89,7 @@ void unlock_workspaces(void) { desktop_private::workspacelock.Unlock(); }
*/ */
void InitDesktop(void) void InitDesktop(void)
{ {
#ifdef DEBUG_DESKTOP STRACE(("Desktop: InitWorkspace\n"));
printf("Desktop: InitWorkspace\n");
#endif
desktop_private::screenlist=new BList(0); desktop_private::screenlist=new BList(0);
DisplayDriver *tdriver; DisplayDriver *tdriver;
Screen *s=NULL; Screen *s=NULL;
@ -116,9 +115,7 @@ printf("Desktop: InitWorkspace\n");
tdriver->Shutdown(); tdriver->Shutdown();
delete tdriver; delete tdriver;
tdriver=NULL; tdriver=NULL;
#ifdef DEBUG_DESKTOP STRACE(("\t NULL display driver. OK. We crash now. :P\n"));
printf("\t NULL display driver. OK. We crash now. :P\n");
#endif
} }
#else // end if not TEST_MODE #else // end if not TEST_MODE
@ -143,9 +140,7 @@ printf("\t NULL display driver. OK. We crash now. :P\n");
tdriver->Shutdown(); tdriver->Shutdown();
delete tdriver; delete tdriver;
tdriver=NULL; tdriver=NULL;
#ifdef DEBUG_DESKTOP STRACE(("\t NULL display driver. OK. We crash now. :P\n"));
printf("\t NULL display driver. OK. We crash now. :P\n");
#endif
} }
#endif #endif
@ -156,8 +151,7 @@ printf("\t NULL display driver. OK. We crash now. :P\n");
desktop_private::activescreen=s; desktop_private::activescreen=s;
s->SetSpace(0,B_32_BIT_640x480,true); s->SetSpace(0,B_32_BIT_640x480,true);
} }
#ifdef DEBUG_DESKTOP #ifndef DEBUG_DESKTOP
else
printf("ERROR: NULL display driver\n"); printf("ERROR: NULL display driver\n");
#endif #endif
} }
@ -165,9 +159,7 @@ printf("ERROR: NULL display driver\n");
//! Shuts down the graphics subsystem //! Shuts down the graphics subsystem
void ShutdownDesktop(void) void ShutdownDesktop(void)
{ {
#ifdef DEBUG_DESKTOP STRACE(("Desktop: ShutdownDesktop\n"));
printf("Desktop: ShutdownDesktop\n");
#endif
Screen *s; Screen *s;
for(int32 i=0;i<desktop_private::screenlist->CountItems();i++) for(int32 i=0;i<desktop_private::screenlist->CountItems();i++)
@ -195,9 +187,7 @@ printf("Desktop: ShutdownDesktop\n");
*/ */
void AddWorkspace(int32 index) void AddWorkspace(int32 index)
{ {
#ifdef DEBUG_DESKTOP STRACE(("Desktop: AddWorkspace(%ld)\n",index+1));
printf("Desktop: AddWorkspace(%ld)\n",index+1);
#endif
lock_workspaces(); lock_workspaces();
lock_layers(); lock_layers();
@ -225,9 +215,7 @@ printf("Desktop: AddWorkspace(%ld)\n",index+1);
*/ */
void DeleteWorkspace(int32 index) void DeleteWorkspace(int32 index)
{ {
#ifdef DEBUG_DESKTOP STRACE(("Desktop: DeleteWorkspace(%ld)\n",index+1));
printf("Desktop: DeleteWorkspace(%ld)\n",index+1);
#endif
lock_workspaces(); lock_workspaces();
lock_layers(); lock_layers();
@ -273,9 +261,7 @@ int32 CountWorkspaces(void)
*/ */
void SetWorkspaceCount(int32 count) void SetWorkspaceCount(int32 count)
{ {
#ifdef DEBUG_DESKTOP STRACE(("Desktop: SetWorkspaceCount(%ld)\n",count));
printf("Desktop: SetWorkspaceCount(%ld)\n",count);
#endif
if(count<1 || count>32) if(count<1 || count>32)
return; return;
lock_workspaces(); lock_workspaces();
@ -328,9 +314,7 @@ Workspace *WorkspaceAt(int32 index)
*/ */
void SetWorkspace(int32 workspace) void SetWorkspace(int32 workspace)
{ {
#ifdef DEBUG_DESKTOP STRACE(("Desktop: SetWorkspace(%ld)\n",workspace+1));
printf("Desktop: SetWorkspace(%ld)\n",workspace+1);
#endif
lock_workspaces(); lock_workspaces();
if(workspace<0 || workspace>(CountWorkspaces()-1)) if(workspace<0 || workspace>(CountWorkspaces()-1))
{ {
@ -355,9 +339,7 @@ printf("Desktop: SetWorkspace(%ld)\n",workspace+1);
*/ */
void SetScreen(screen_id id) void SetScreen(screen_id id)
{ {
#ifdef DEBUG_DESKTOP STRACE(("Desktop: SetScreen(%ld)\n",id.id));
printf("Desktop: SetScreen(%ld)\n",id.id);
#endif
Screen *scr; Screen *scr;
for(int32 i=0;i<desktop_private::screenlist->CountItems();i++) for(int32 i=0;i<desktop_private::screenlist->CountItems();i++)
{ {
@ -425,10 +407,10 @@ DisplayDriver *GetGfxDriver(screen_id screen)
*/ */
status_t SetSpace(int32 index, int32 res, screen_id screen, bool stick) status_t SetSpace(int32 index, int32 res, screen_id screen, bool stick)
{ {
#ifdef DEBUG_DESKTOP
printf("Desktop: SetSpace(%ld,%ld,%s,%ld)\n",index+1,res, STRACE(("Desktop: SetSpace(%ld,%ld,%s,%ld)\n",index+1,res,
stick?"stick":"non-stick",screen.id); stick?"stick":"non-stick",screen.id));
#endif
desktop_private::workspacelock.Lock(); desktop_private::workspacelock.Lock();
status_t stat=desktop_private::activescreen->SetSpace(index,res,stick); status_t stat=desktop_private::activescreen->SetSpace(index,res,stick);
desktop_private::workspacelock.Unlock(); desktop_private::workspacelock.Unlock();
@ -443,10 +425,10 @@ printf("Desktop: SetSpace(%ld,%ld,%s,%ld)\n",index+1,res,
*/ */
void AddWindowToDesktop(ServerWindow *win, int32 workspace, screen_id screen) void AddWindowToDesktop(ServerWindow *win, int32 workspace, screen_id screen)
{ {
#ifdef DEBUG_DESKTOP
printf("Desktop: AddWindowToDesktop(%s,%ld,%ld)\n",win?win->GetTitle():"NULL", STRACE(("Desktop: AddWindowToDesktop(%s,%ld,%ld)\n",win?win->GetTitle():"NULL",
workspace+1,screen.id); workspace+1,screen.id));
#endif
// Workspace() will be non-NULL if it has already been added to the desktop // Workspace() will be non-NULL if it has already been added to the desktop
if(!win || win->GetWorkspace()) if(!win || win->GetWorkspace())
return; return;
@ -463,10 +445,10 @@ printf("Desktop: AddWindowToDesktop(%s,%ld,%ld)\n",win?win->GetTitle():"NULL",
} }
WinBorder* WindowContainsPoint( BPoint pt ){ WinBorder* WindowContainsPoint( BPoint pt ){
#ifdef DEBUG_DESKTOP
printf("Desktop: WindowContainsPoint(%s,%f,%f)\n",win?win->GetTitle():"NULL", STRACE(("Desktop: WindowContainsPoint(%s,%f,%f)\n",win?win->GetTitle():"NULL",
pt.x, pt.y); pt.x, pt.y));
#endif
WinBorder *wb; WinBorder *wb;
desktop_private::workspacelock.Lock(); desktop_private::workspacelock.Lock();
@ -485,9 +467,7 @@ printf("Desktop: WindowContainsPoint(%s,%f,%f)\n",win?win->GetTitle():"NULL",
*/ */
void RemoveWindowFromDesktop(ServerWindow *win) void RemoveWindowFromDesktop(ServerWindow *win)
{ {
#ifdef DEBUG_DESKTOP STRACE(("Desktop: RemoveWindowFromDesktop(%s)\n",win?win->GetTitle():"NULL"));
printf("Desktop: RemoveWindowFromDesktop(%s)\n",win?win->GetTitle():"NULL");
#endif
lock_workspaces(); lock_workspaces();
lock_layers(); lock_layers();
@ -519,9 +499,7 @@ ServerWindow *GetActiveWindow(void)
*/ */
void SetActiveWindow(ServerWindow *win) void SetActiveWindow(ServerWindow *win)
{ {
#ifdef DEBUG_DESKTOP STRACE(("Desktop: SetActiveWindow(%s)\n",win?win->GetTitle():"NULL"));
printf("Desktop: SetActiveWindow(%s)\n",win?win->GetTitle():"NULL");
#endif
lock_workspaces(); lock_workspaces();
Workspace *w=desktop_private::activescreen->GetActiveWorkspace(); Workspace *w=desktop_private::activescreen->GetActiveWorkspace();
if(win && win->GetWorkspace()!=w) if(win && win->GetWorkspace()!=w)

View File

@ -43,10 +43,17 @@
//#define DEBUG_SCREEN //#define DEBUG_SCREEN
#ifdef DEBUG_WORKSPACE #ifdef DEBUG_WORKSPACE
#include <stdio.h> # include <stdio.h>
# define STRACE_WS(x) printf x
#else
# define STRACE_WS(x) ;
#endif #endif
#ifdef DEBUG_SCREEN #ifdef DEBUG_SCREEN
#include <stdio.h> # include <stdio.h>
# define STRACE_SCREEN(x) printf x
#else
# define STRACE_SCREEN(x) ;
#endif #endif
// Defined and initialized in AppServer.cpp // Defined and initialized in AppServer.cpp
@ -68,9 +75,7 @@ Workspace::Workspace(const graphics_card_info &gcinfo, const frame_buffer_info &
_rootlayer=new RootLayer(BRect(0,0,fbinfo.display_width-1,fbinfo.display_height-1), _rootlayer=new RootLayer(BRect(0,0,fbinfo.display_width-1,fbinfo.display_height-1),
"Workspace Root",_screen->GetGfxDriver()); "Workspace Root",_screen->GetGfxDriver());
_rootlayer->SetColor(workspace_default_color); _rootlayer->SetColor(workspace_default_color);
#ifdef DEBUG_WORKSPACE STRACE_WS(("Workspace::Workspace(%s)\n",_rootlayer->GetName()));
printf("Workspace::Workspace(%s)\n",_rootlayer->GetName());
#endif
} }
/*! /*!
@ -86,9 +91,7 @@ Workspace::Workspace(as_workspace_data *data, Screen *screen)
*/ */
Workspace::~Workspace(void) Workspace::~Workspace(void)
{ {
#ifdef DEBUG_WORKSPACE STRACE_WS(("Workspace::~Workspace(%s)\n",_rootlayer->GetName()));
printf("Workspace::~Workspace(%s)\n",_rootlayer->GetName());
#endif
if(_rootlayer) if(_rootlayer)
{ {
_rootlayer->PruneTree(); _rootlayer->PruneTree();
@ -103,9 +106,8 @@ printf("Workspace::~Workspace(%s)\n",_rootlayer->GetName());
*/ */
void Workspace::SetBGColor(const RGBColor &c) void Workspace::SetBGColor(const RGBColor &c)
{ {
#ifdef DEBUG_WORKSPACE STRACE_WS(("Workspace::SetBGColor(): "));
printf("Workspace::SetBGColor(): "); c.PrintToStream(); c.PrintToStream();
#endif
_rootlayer->SetColor(c); _rootlayer->SetColor(c);
} }
@ -134,9 +136,7 @@ RootLayer *Workspace::GetRoot(void)
*/ */
void Workspace::SetData(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo) void Workspace::SetData(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo)
{ {
#ifdef DEBUG_WORKSPACE STRACE_WS(("Workspace::SetData(%s)\n",_rootlayer->GetName()));
printf("Workspace::SetData(%s)\n",_rootlayer->GetName());
#endif
if(_fbinfo.display_width!=fbinfo.display_width || if(_fbinfo.display_width!=fbinfo.display_width ||
_fbinfo.display_height!=fbinfo.display_height) _fbinfo.display_height!=fbinfo.display_height)
{ {
@ -167,9 +167,7 @@ void Workspace::GetData(graphics_card_info *gcinfo, frame_buffer_info *fbinfo)
*/ */
void Workspace::SetSpace(int32 res) void Workspace::SetSpace(int32 res)
{ {
#ifdef DEBUG_WORKSPACE STRACE_WS(("Workspace::SetSpace(%ld) unimplemented\n",res));
printf("Workspace::SetSpace(%ld) unimplemented\n",res);
#endif
// TODO: Implement // TODO: Implement
} }
@ -180,9 +178,7 @@ printf("Workspace::SetSpace(%ld) unimplemented\n",res);
*/ */
Screen::Screen(DisplayDriver *gfxmodule, uint8 workspaces) Screen::Screen(DisplayDriver *gfxmodule, uint8 workspaces)
{ {
#ifdef DEBUG_SCREEN STRACE_SCREEN(("Screen::Screen(%s,%u)\n",gfxmodule?"driver":"NULL",workspaces));
printf("Screen::Screen(%s,%u)\n",gfxmodule?"driver":"NULL",workspaces);
#endif
_workspacelist=NULL; _workspacelist=NULL;
_driver=gfxmodule; _driver=gfxmodule;
_resolution=0; _resolution=0;
@ -238,9 +234,7 @@ printf("Screen::Screen(%s,%u)\n",gfxmodule?"driver":"NULL",workspaces);
*/ */
Screen::~Screen(void) Screen::~Screen(void)
{ {
#ifdef DEBUG_SCREEN STRACE_SCREEN(("Screen::~Screen\n"));
printf("Screen::~Screen\n");
#endif
if ( _workspacelist ) if ( _workspacelist )
{ {
int i; int i;
@ -258,9 +252,7 @@ printf("Screen::~Screen\n");
*/ */
void Screen::AddWorkspace(int32 index) void Screen::AddWorkspace(int32 index)
{ {
#ifdef DEBUG_SCREEN STRACE_SCREEN(("Screen::AddWorkspace(%ld)\n",index+1));
printf("Screen::AddWorkspace(%ld)\n",index+1);
#endif
Workspace *workspace = new Workspace(_gcinfo,_fbinfo,this); Workspace *workspace = new Workspace(_gcinfo,_fbinfo,this);
if ( (index == -1) || !_workspacelist->AddItem(workspace,index) ) if ( (index == -1) || !_workspacelist->AddItem(workspace,index) )
_workspacelist->AddItem(workspace); _workspacelist->AddItem(workspace);
@ -275,9 +267,7 @@ printf("Screen::AddWorkspace(%ld)\n",index+1);
*/ */
void Screen::AddWorkspace(Workspace *workspace,int32 index) void Screen::AddWorkspace(Workspace *workspace,int32 index)
{ {
#ifdef DEBUG_SCREEN STRACE_SCREEN(("Screen::AddWorkspace(%s)\n",(workspace && workspace->GetRoot())?workspace->GetRoot()->GetName():"NULL"));
printf("Screen::AddWorkspace(%s)\n",(workspace && workspace->GetRoot())?workspace->GetRoot()->GetName():"NULL");
#endif
if ( (index==-1) || !_workspacelist->AddItem(workspace,index) ) if ( (index==-1) || !_workspacelist->AddItem(workspace,index) )
_workspacelist->AddItem(workspace); _workspacelist->AddItem(workspace);
} }
@ -288,9 +278,7 @@ printf("Screen::AddWorkspace(%s)\n",(workspace && workspace->GetRoot())?workspac
*/ */
void Screen::DeleteWorkspace(int32 index) void Screen::DeleteWorkspace(int32 index)
{ {
#ifdef DEBUG_SCREEN STRACE_SCREEN(("Screen::DeleteWorkspace(%ld)\n",index+1));
printf("Screen::DeleteWorkspace(%ld)\n",index+1);
#endif
Workspace *workspace; Workspace *workspace;
workspace = (Workspace *)_workspacelist->RemoveItem(index); workspace = (Workspace *)_workspacelist->RemoveItem(index);
if ( workspace ) if ( workspace )
@ -330,9 +318,7 @@ void Screen::SetWorkspaceCount(int32 count)
if ( _currentworkspace > count-1 ) if ( _currentworkspace > count-1 )
SetWorkspace(count-1); SetWorkspace(count-1);
#ifdef DEBUG_SCREEN STRACE_SCREEN(("Screen::SetWorkspaceCount(%ld)\n",count));
printf("Screen::SetWorkspaceCount(%ld)\n",count);
#endif
} }
/*! /*!
@ -350,9 +336,7 @@ int32 Screen::CurrentWorkspace(void)
*/ */
void Screen::SetWorkspace(int32 index) void Screen::SetWorkspace(int32 index)
{ {
#ifdef DEBUG_SCREEN STRACE_SCREEN(("Screen::SetWorkspace(%ld)\n",index+1));
printf("Screen::SetWorkspace(%ld)\n",index+1);
#endif
if ( (index >= 0) && (index <= _workspacecount-1) ) if ( (index >= 0) && (index <= _workspacecount-1) )
{ {
_currentworkspace = index; _currentworkspace = index;
@ -366,9 +350,7 @@ printf("Screen::SetWorkspace(%ld)\n",index+1);
*/ */
void Screen::Activate(bool active) void Screen::Activate(bool active)
{ {
#ifdef DEBUG_SCREEN STRACE_SCREEN(("Screen::Activate(%s)\n",active?"active":"inactive"));
printf("Screen::Activate(%s)\n",active?"active":"inactive");
#endif
_active=active; _active=active;
} }
@ -390,9 +372,7 @@ DisplayDriver *Screen::GetGfxDriver(void)
*/ */
status_t Screen::SetSpace(int32 index, int32 res,bool stick) status_t Screen::SetSpace(int32 index, int32 res,bool stick)
{ {
#ifdef DEBUG_SCREEN STRACE_SCREEN(("Screen::SetSpace(%ld,%ld,%s)\n",index,res,stick?"stick":"non-stick"));
printf("Screen::SetSpace(%ld,%ld,%s)\n",index,res,stick?"stick":"non-stick");
#endif
// the specified workspace isn't active, so this should be easy... // the specified workspace isn't active, so this should be easy...
Workspace *wkspc=(Workspace*)_workspacelist->ItemAt(index); Workspace *wkspc=(Workspace*)_workspacelist->ItemAt(index);
if(!wkspc) if(!wkspc)
@ -419,9 +399,7 @@ printf("Screen::SetSpace(%ld,%ld,%s)\n",index,res,stick?"stick":"non-stick");
*/ */
void Screen::AddWindow(ServerWindow *win, int32 workspace) void Screen::AddWindow(ServerWindow *win, int32 workspace)
{ {
#ifdef DEBUG_SCREEN STRACE_SCREEN(("Screen::AddWindow(%s,%ld)\n",win?win->GetTitle():"NULL", workspace+1));
printf("Screen::AddWindow(%s,%ld)\n",win?win->GetTitle():"NULL", workspace+1);
#endif
if(!win || !win->_winborder) if(!win || !win->_winborder)
return; return;
@ -439,9 +417,7 @@ printf("Screen::AddWindow(%s,%ld)\n",win?win->GetTitle():"NULL", workspace+1);
*/ */
void Screen::RemoveWindow(ServerWindow *win) void Screen::RemoveWindow(ServerWindow *win)
{ {
#ifdef DEBUG_SCREEN STRACE_SCREEN(("Screen::RemoveWindow(%s)\n",win?win->GetTitle():"NULL"));
printf("Screen::RemoveWindow(%s)\n",win?win->GetTitle():"NULL");
#endif
if(!win || !win->_winborder) if(!win || !win->_winborder)
return; return;
@ -458,7 +434,7 @@ WinBorder* Screen::GetWindowAt( BPoint pt ){
Layer *child; Layer *child;
for(child = rl->_bottomchild; child!=NULL; child = child->_uppersibling) for(child = rl->_bottomchild; child!=NULL; child = child->_uppersibling)
{ {
if(child->_hidecount>0) if(child->_hidden)
continue; continue;
wb = dynamic_cast<WinBorder*>( child ); wb = dynamic_cast<WinBorder*>( child );
if (wb) if (wb)

View File

@ -36,9 +36,6 @@
#include "RectUtils.h" #include "RectUtils.h"
#include "RootLayer.h" #include "RootLayer.h"
//! TokenHandler object used to provide IDs for all Layers and, thus, BViews
TokenHandler view_token_handler;
/*! /*!
\brief Constructor \brief Constructor
\param frame Size and placement of the Layer \param frame Size and placement of the Layer
@ -47,41 +44,39 @@ TokenHandler view_token_handler;
\param flags BView flags as defined in View.h \param flags BView flags as defined in View.h
\param win ServerWindow to which the Layer belongs \param win ServerWindow to which the Layer belongs
*/ */
Layer::Layer(BRect frame, const char *name, int32 resize, int32 flags,ServerWindow *win) Layer::Layer(BRect frame, const char *name, int32 token, int32 resize,
int32 flags, ServerWindow *win)
{ {
// frame is in _parent layer's coordinates // frame is in _parent layer's coordinates
if(frame.IsValid()) if(frame.IsValid())
_frame=frame; _frame = frame;
else else
_frame.Set(0,0,5,5); _frame.Set(0, 0, 5, 5);
_name=new BString(name);
_name = new BString(name);
// Layer does not start out as a part of the tree // Layer does not start out as a part of the tree
_parent=NULL; _parent = NULL;
_uppersibling=NULL; _uppersibling = NULL;
_lowersibling=NULL; _lowersibling = NULL;
_topchild=NULL; _topchild = NULL;
_bottomchild=NULL; _bottomchild = NULL;
_visible=new BRegion(Frame()); _visible = new BRegion( _frame );
_full=new BRegion(Frame()); _full = new BRegion( _frame );
_invalid=new BRegion(Frame()); _invalid = new BRegion( _frame );
_serverwin=win; _flags = flags;
_hidden = false;
_is_dirty = false;
_is_updating = false;
_regions_invalid= false;
_level = 0;
_view_token = token;
_layerdata = new LayerData;
// We have view tokens to be able to identify BViews _serverwin = win;
_view_token=view_token_handler.GetToken(); // what's this needed for?
_portlink = NULL;
_flags=flags;
_hidecount=0;
_is_dirty=false;
_is_updating=false;
_regions_invalid=false;
_level=0;
_layerdata=new LayerData;
} }
//! Destructor frees all allocated heap space //! Destructor frees all allocated heap space
@ -131,7 +126,7 @@ printf("Layer::AddChild lacks before support\n");
return; return;
} }
layer->_parent=this; layer->_parent=this;
if(layer->_visible && layer->_hidecount==0 && _visible) if(layer->_visible && layer->_hidden==false && _visible)
{ {
RootLayer *rl; RootLayer *rl;
rl = dynamic_cast<RootLayer*>(this); rl = dynamic_cast<RootLayer*>(this);
@ -142,9 +137,8 @@ printf("Layer::AddChild lacks before support\n");
else{ else{
// Technically, we could safely take the address of ConvertToParent(BRegion) // Technically, we could safely take the address of ConvertToParent(BRegion)
// but we don't just to avoid a compiler nag // but we don't just to avoid a compiler nag
BRegion *reg=new BRegion(layer->ConvertToParent(layer->_visible)); BRegion reg(layer->ConvertToParent(layer->_visible));
_visible->Exclude(reg); _visible->Exclude(&reg);
delete reg;
} }
} }
@ -186,11 +180,10 @@ void Layer::RemoveChild(Layer *layer, bool rebuild)
return; return;
} }
if(_hidecount==0 && layer->_visible && layer->_parent->_visible) if( !_hidden && layer->_visible && layer->_parent->_visible)
{ {
BRegion *reg=new BRegion(ConvertToParent(_visible)); BRegion reg(ConvertToParent(_visible));
layer->_parent->_visible->Include(reg); layer->_parent->_visible->Include(&reg);
delete reg;
} }
// Take care of _parent // Take care of _parent
@ -252,7 +245,7 @@ Layer *Layer::GetChildAt(BPoint pt, bool recursive)
if(child->_bottomchild!=NULL) if(child->_bottomchild!=NULL)
child->GetChildAt(pt,true); child->GetChildAt(pt,true);
if(child->_hidecount>0) if(child->_hidden)
continue; continue;
if(child->_frame.Contains(pt)) if(child->_frame.Contains(pt))
@ -263,7 +256,7 @@ Layer *Layer::GetChildAt(BPoint pt, bool recursive)
{ {
for(child=_bottomchild; child!=NULL; child=child->_uppersibling) for(child=_bottomchild; child!=NULL; child=child->_uppersibling)
{ {
if(child->_hidecount>0) if(child->_hidden)
continue; continue;
if(child->_frame.Contains(pt)) if(child->_frame.Contains(pt))
return child; return child;
@ -357,7 +350,7 @@ void Layer::Invalidate(BRegion& region)
BRect r; BRect r;
// See if the region intersects with our current area // See if the region intersects with our current area
if(region.Intersects(Bounds()) && _hidecount==0) if(region.Intersects(Bounds()) && !_hidden)
{ {
BRegion clippedreg(region); BRegion clippedreg(region);
clippedreg.IntersectWith(_visible); clippedreg.IntersectWith(_visible);
@ -374,7 +367,7 @@ void Layer::Invalidate(BRegion& region)
BRegion *reg; BRegion *reg;
for(Layer *lay=_topchild;lay!=NULL; lay=lay->_lowersibling) for(Layer *lay=_topchild;lay!=NULL; lay=lay->_lowersibling)
{ {
if(lay->_hidecount==0) if(lay->_hidden==false)
{ {
reg=new BRegion(lay->ConvertFromParent(&region)); reg=new BRegion(lay->ConvertFromParent(&region));
@ -442,7 +435,7 @@ printf("Layer: %s: RequestDraw(%.1f,%.1f,%.1f,%.1f) - unimplemented\n",
_name->String(),r.left,r.top,r.right,r.bottom); _name->String(),r.left,r.top,r.right,r.bottom);
// TODO: Implement and fix // TODO: Implement and fix
/* if(_visible==NULL || _hidecount>0) /* if(_visible==NULL || _hidden)
return; return;
if(_serverwin) if(_serverwin)
@ -541,18 +534,14 @@ void Layer::UpdateRegions(bool force)
//! Show the layer. Operates just like the BView call with the same name //! Show the layer. Operates just like the BView call with the same name
void Layer::Show(void) void Layer::Show(void)
{ {
if(_hidecount==0) if( !_hidden )
return;
_hidecount--;
if(_hidecount>0)
return; return;
_hidden = false;
if( _parent ){ if( _parent ){
BRegion *reg=new BRegion(ConvertToParent(_visible)); BRegion reg(ConvertToParent(_visible));
_parent->_visible->Exclude(reg); _parent->_visible->Exclude( &reg );
delete reg;
_parent->_is_dirty=true; _parent->_is_dirty=true;
} }
_is_dirty=true; _is_dirty=true;
@ -581,15 +570,16 @@ void Layer::Show(void)
//! Hide the layer. Operates just like the BView call with the same name //! Hide the layer. Operates just like the BView call with the same name
void Layer::Hide(void) void Layer::Hide(void)
{ {
if(_hidecount==0) if ( _hidden )
{ return;
BRegion *reg=new BRegion(ConvertToParent(_visible));
_parent->_visible->Include(reg); _hidden = true;
delete reg;
_parent->_is_dirty=true; BRegion reg(ConvertToParent(_visible));
_is_dirty=true; _parent->_visible->Include( &reg );
}
_hidecount++; _parent->_is_dirty=true;
_is_dirty=true;
Layer *child; Layer *child;
for(child=_topchild; child!=NULL; child=child->_lowersibling) for(child=_topchild; child!=NULL; child=child->_lowersibling)
@ -602,7 +592,7 @@ void Layer::Hide(void)
*/ */
bool Layer::IsHidden(void) bool Layer::IsHidden(void)
{ {
return (_hidecount==0)?false:true; return _hidden;
} }
/*! /*!
@ -714,7 +704,7 @@ void Layer::RebuildRegions(bool include_children)
childlay->_visible->MakeEmpty(); childlay->_visible->MakeEmpty();
childlay->_visible->Include(childlay->_full); childlay->_visible->Include(childlay->_full);
if(childlay->_visible && childlay->_hidecount==0) if(childlay->_visible && childlay->_hidden==false)
childlay->_visible->IntersectWith(_visible); childlay->_visible->IntersectWith(_visible);
} }
@ -734,7 +724,7 @@ void Layer::RebuildRegions(bool include_children)
if( clipregion.CountRects()>0 && if( clipregion.CountRects()>0 &&
TestRectIntersection(siblay->Frame(),clipregion.Frame()) && TestRectIntersection(siblay->Frame(),clipregion.Frame()) &&
siblay->_visible && siblay->_visible &&
siblay->_hidecount==0 ) siblay->_hidden==false )
{ {
siblay->_visible->Exclude(&clipregion); siblay->_visible->Exclude(&clipregion);
} }
@ -779,7 +769,7 @@ void Layer::PrintToStream(void)
printf("Bottom child: NULL\n"); printf("Bottom child: NULL\n");
printf("Frame: "); _frame.PrintToStream(); printf("Frame: "); _frame.PrintToStream();
printf("Token: %ld\nLevel: %ld\n",_view_token, _level); printf("Token: %ld\nLevel: %ld\n",_view_token, _level);
printf("Hide count: %u\n",_hidecount); printf("Hide count: %s\n",_hidden?"true":"false");
if(_invalid) if(_invalid)
{ {
printf("Invalid Areas: "); _invalid->PrintToStream(); printf("Invalid Areas: "); _invalid->PrintToStream();

View File

@ -36,6 +36,7 @@
#include <Locker.h> #include <Locker.h>
#include "LayerData.h" #include "LayerData.h"
#include "DesktopClasses.h" #include "DesktopClasses.h"
#include "TokenHandler.h"
class ServerWindow; class ServerWindow;
class PortLink; class PortLink;
@ -54,8 +55,8 @@ class Screen;
class Layer class Layer
{ {
public: public:
Layer(BRect frame, const char *name, int32 resize, Layer(BRect frame, const char *name, int32 token, int32 resize,
int32 flags,ServerWindow *win); int32 flags, ServerWindow *win);
virtual ~Layer(void); virtual ~Layer(void);
void AddChild(Layer *child, Layer *before=NULL, bool rebuild=true); void AddChild(Layer *child, Layer *before=NULL, bool rebuild=true);
@ -109,32 +110,28 @@ protected:
friend class RootLayer; friend class RootLayer;
friend class WinBorder; friend class WinBorder;
friend class Screen; friend class Screen;
friend class ServerWindow;
BRect _frame; BRect _frame;
Layer *_parent,
Layer *_parent, *_uppersibling,
*_uppersibling, *_lowersibling,
*_lowersibling, *_topchild,
*_topchild, *_bottomchild;
*_bottomchild; BRegion *_visible,
*_invalid,
BRegion *_visible, *_full;
*_invalid, ServerWindow *_serverwin;
*_full; BString *_name;
int32 _view_token;
ServerWindow *_serverwin; int32 _level;
int32 _flags;
BString *_name; bool _hidden;
int32 _view_token; bool _is_dirty;
int32 _level; bool _is_updating;
int32 _flags; bool _regions_invalid;
uint8 _hidecount; LayerData *_layerdata;
bool _is_dirty; PortLink *_portlink;
bool _is_updating;
bool _regions_invalid;
LayerData *_layerdata;
PortLink *_portlink;
}; };
#endif #endif

View File

@ -388,8 +388,8 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, LayerData *d)
{ {
int16 alphaSrcMode = GetInt16(); int16 alphaSrcMode = GetInt16();
int16 alphaFncMode = GetInt16(); int16 alphaFncMode = GetInt16();
fldata.alpha_mode=(source_alpha)alphaSrcMode; fldata.alphaSrcMode = (source_alpha)alphaSrcMode;
fldata.blending_mode=(alpha_function)alphaFncMode; fldata.alphaFncMode = (alpha_function)alphaFncMode;
break; break;
} }
case B_PIC_SET_FONT_FAMILY: case B_PIC_SET_FONT_FAMILY:

View File

@ -30,7 +30,7 @@
class DisplayDriver; class DisplayDriver;
class RGBColor; class RGBColor;
class Layer; //class Layer;
/*! /*!
\class RootLayer RootLayer.h \class RootLayer RootLayer.h

View File

@ -50,6 +50,13 @@
#include "LayerData.h" #include "LayerData.h"
#include "PNGDump.h" #include "PNGDump.h"
#ifdef DEBUG_DRIVER_MODULE
# include <stdio.h>
# define STRACE(x) printf x
#else
# define STRACE(x) ;
#endif
enum enum
{ {
SDWIN_CLEAR=100, SDWIN_CLEAR=100,
@ -458,9 +465,7 @@ void ScreenDriver::CopyBits(BRect src, BRect dest)
void ScreenDriver::DrawBitmap(ServerBitmap *bitmap, BRect src, BRect dest) void ScreenDriver::DrawBitmap(ServerBitmap *bitmap, BRect src, BRect dest)
{ {
#ifdef DEBUG_DRIVER_MODULE STRACE(("ScreenDriver:: DrawBitmap unimplemented()\n"));
printf("ScreenDriver:: DrawBitmap unimplemented()\n");
#endif
} }
void ScreenDriver::DrawChar(char c, BPoint pt, LayerData *d) void ScreenDriver::DrawChar(char c, BPoint pt, LayerData *d)
@ -473,9 +478,7 @@ void ScreenDriver::DrawChar(char c, BPoint pt, LayerData *d)
/* /*
void ScreenDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL) void ScreenDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL)
{ {
#ifdef DEBUG_DRIVER_MODULE STRACE(("ScreenDriver:: DrawString(\"%s\",%ld,BPoint(%f,%f))\n",string,length,pt.x,pt.y));
printf("ScreenDriver:: DrawString(\"%s\",%ld,BPoint(%f,%f))\n",string,length,pt.x,pt.y);
#endif
if(!d) if(!d)
return; return;
BRect r; BRect r;
@ -770,9 +773,8 @@ void ScreenDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, const Patt
void ScreenDriver::StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d) void ScreenDriver::StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d)
{ {
#ifdef DEBUG_DRIVER_MODULE STRACE(("ScreenDriver:: StrokeLineArray unimplemented\n"));
printf("ScreenDriver:: StrokeLineArray unimplemented\n");
#endif
} }
void ScreenDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat, bool is_closed) void ScreenDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, const Pattern &pat, bool is_closed)

View File

@ -29,6 +29,7 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <View.h> // for B_XXXXX_MOUSE_BUTTON defines #include <View.h> // for B_XXXXX_MOUSE_BUTTON defines
#include <GraphicsDefs.h>
#include <PortLink.h> #include <PortLink.h>
#include "AppServer.h" #include "AppServer.h"
#include "Layer.h" #include "Layer.h"
@ -47,11 +48,29 @@
//#define DEBUG_SERVERWINDOW_MOUSE //#define DEBUG_SERVERWINDOW_MOUSE
//#define DEBUG_SERVERWINDOW_KEYBOARD //#define DEBUG_SERVERWINDOW_KEYBOARD
#ifdef DEBUG_SERVERWINDOW #ifdef DEBUG_SERVERWINDOW
#include <stdio.h> # include <stdio.h>
# define STRACE(x) printf x
#else
# define STRACE(x) ;
#endif #endif
//! Handler to get BWindow tokens from #ifdef DEBUG_SERVERWINDOW_KEYBOARD
# include <stdio.h>
# define STRACE_KEY(x) printf x
#else
# define STRACE_KEY(x) ;
#endif
#ifdef DEBUG_SERVERWINDOW_MOUSE
# include <stdio.h>
# define STRACE_MOUSE(x) printf x
#else
# define STRACE_MOUSE(x) ;
#endif
//! TokenHandler object used to provide IDs for all windows in the system
TokenHandler win_token_handler; TokenHandler win_token_handler;
//! Active winborder - used for tracking windows during moves, resizes, and tab slides //! Active winborder - used for tracking windows during moves, resizes, and tab slides
@ -106,6 +125,7 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
_look=wlook; _look=wlook;
_feel=wfeel; _feel=wfeel;
_handlertoken=handlerID; _handlertoken=handlerID;
cl = NULL;
_winborder=new WinBorder(_frame,_title->String(),wlook,wfeel,wflags,this); _winborder=new WinBorder(_frame,_title->String(),wlook,wfeel,wflags,this);
@ -124,6 +144,8 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
ses->WriteData( &_receiver, sizeof(port_id) ); ses->WriteData( &_receiver, sizeof(port_id) );
ses->Sync(); ses->Sync();
top_layer = NULL;
_active=false; _active=false;
// Spawn our message monitoring _monitorthread // Spawn our message monitoring _monitorthread
@ -137,20 +159,16 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
_token=win_token_handler.GetToken(); _token=win_token_handler.GetToken();
AddWindowToDesktop(this,index,ActiveScreen()); AddWindowToDesktop(this,index,ActiveScreen());
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s:\n",_title->String() ));
printf("ServerWindow %s:\n",_title->String()); STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom));
printf("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom); STRACE(("\tPort: %ld\n",_receiver));
printf("\tPort: %ld\n",_receiver); STRACE(("\tWorkspace: %ld\n",index));
printf("\tWorkspace: %ld\n",index);
#endif
} }
//!Tears down all connections with the user application, kills the monitoring thread. //!Tears down all connections with the user application, kills the monitoring thread.
ServerWindow::~ServerWindow(void) ServerWindow::~ServerWindow(void)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s:~ServerWindow()\n",_title->String()));
printf("ServerWindow %s:~ServerWindow()\n",_title->String());
#endif
RemoveWindowFromDesktop(this); RemoveWindowFromDesktop(this);
if(_applink) if(_applink)
{ {
@ -160,7 +178,9 @@ ServerWindow::~ServerWindow(void)
delete _winlink; delete _winlink;
delete _winborder; delete _winborder;
cl = NULL;
if ( top_layer )
delete top_layer;
delete ses; delete ses;
ses = NULL; ses = NULL;
} }
@ -175,9 +195,7 @@ ServerWindow::~ServerWindow(void)
*/ */
void ServerWindow::RequestDraw(BRect rect) void ServerWindow::RequestDraw(BRect rect)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Request Draw\n",_title->String()));
printf("ServerWindow %s: Request Draw\n",_title->String());
#endif
_winlink->SetOpCode(AS_LAYER_DRAW); _winlink->SetOpCode(AS_LAYER_DRAW);
_winlink->Attach(&rect,sizeof(BRect)); _winlink->Attach(&rect,sizeof(BRect));
_winlink->Flush(); _winlink->Flush();
@ -192,18 +210,14 @@ void ServerWindow::RequestDraw(void)
//! Forces the window border to update its decorator //! Forces the window border to update its decorator
void ServerWindow::ReplaceDecorator(void) void ServerWindow::ReplaceDecorator(void)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Replace Decorator\n",_title->String()));
printf("ServerWindow %s: Replace Decorator\n",_title->String());
#endif
_winborder->UpdateDecorator(); _winborder->UpdateDecorator();
} }
//! Requests that the ServerWindow's BWindow quit //! Requests that the ServerWindow's BWindow quit
void ServerWindow::Quit(void) void ServerWindow::Quit(void)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Quit\n",_title->String()));
printf("ServerWindow %s: Quit\n",_title->String());
#endif
_winlink->SetOpCode(B_QUIT_REQUESTED); _winlink->SetOpCode(B_QUIT_REQUESTED);
_winlink->Flush(); _winlink->Flush();
} }
@ -229,9 +243,7 @@ ServerApp *ServerWindow::GetApp(void)
//! Shows the window's WinBorder //! Shows the window's WinBorder
void ServerWindow::Show(void) void ServerWindow::Show(void)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Show\n",_title->String()));
printf("ServerWindow %s: Show\n",_title->String());
#endif
if(_winborder) if(_winborder)
{ {
_winborder->Show(); _winborder->Show();
@ -243,9 +255,7 @@ void ServerWindow::Show(void)
//! Hides the window's WinBorder //! Hides the window's WinBorder
void ServerWindow::Hide(void) void ServerWindow::Hide(void)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Hide\n",_title->String()));
printf("ServerWindow %s: Hide\n",_title->String());
#endif
if(_winborder) if(_winborder)
_winborder->Hide(); _winborder->Hide();
} }
@ -268,9 +278,7 @@ bool ServerWindow::IsHidden(void)
*/ */
void ServerWindow::SetFocus(bool value) void ServerWindow::SetFocus(bool value)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Set Focus to %s\n",_title->String(),value?"true":"false"));
printf("ServerWindow %s: Set Focus to %s\n",_title->String(),value?"true":"false");
#endif
if(_active!=value) if(_active!=value)
{ {
_active=value; _active=value;
@ -295,9 +303,7 @@ bool ServerWindow::HasFocus(void)
*/ */
void ServerWindow::WorkspaceActivated(int32 workspace, bool active) void ServerWindow::WorkspaceActivated(int32 workspace, bool active)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: WorkspaceActivated(%ld,%s)\n",_title->String(),workspace,(active)?"active":"inactive"));
printf("ServerWindow %s: WorkspaceActivated(%ld,%s)\n",_title->String(),workspace,(active)?"active":"inactive");
#endif
_winlink->SetOpCode(AS_WORKSPACE_ACTIVATED); _winlink->SetOpCode(AS_WORKSPACE_ACTIVATED);
_winlink->Attach<int32>(workspace); _winlink->Attach<int32>(workspace);
_winlink->Attach<bool>(active); _winlink->Attach<bool>(active);
@ -311,9 +317,7 @@ void ServerWindow::WorkspaceActivated(int32 workspace, bool active)
*/ */
void ServerWindow::WorkspacesChanged(int32 oldone,int32 newone) void ServerWindow::WorkspacesChanged(int32 oldone,int32 newone)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: WorkspacesChanged(%ld,%ld)\n",_title->String(),oldone,newone));
printf("ServerWindow %s: WorkspacesChanged(%ld,%ld)\n",_title->String(),oldone,newone);
#endif
_winlink->SetOpCode(AS_WORKSPACES_CHANGED); _winlink->SetOpCode(AS_WORKSPACES_CHANGED);
_winlink->Attach<int32>(oldone); _winlink->Attach<int32>(oldone);
_winlink->Attach<int32>(newone); _winlink->Attach<int32>(newone);
@ -326,9 +330,7 @@ void ServerWindow::WorkspacesChanged(int32 oldone,int32 newone)
*/ */
void ServerWindow::WindowActivated(bool active) void ServerWindow::WindowActivated(bool active)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: WindowActivated(%s)\n",_title->String(),(active)?"active":"inactive"));
printf("ServerWindow %s: WindowActivated(%s)\n",_title->String(),(active)?"active":"inactive");
#endif
_winlink->SetOpCode(AS_WINDOW_ACTIVATED); _winlink->SetOpCode(AS_WINDOW_ACTIVATED);
_winlink->Attach<bool>(active); _winlink->Attach<bool>(active);
_winlink->Flush(); _winlink->Flush();
@ -341,9 +343,7 @@ void ServerWindow::WindowActivated(bool active)
*/ */
void ServerWindow::ScreenModeChanged(const BRect frame, const color_space cspace) void ServerWindow::ScreenModeChanged(const BRect frame, const color_space cspace)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: ScreenModeChanged\n",_title->String()));
printf("ServerWindow %s: ScreenModeChanged\n",_title->String());
#endif
_winlink->SetOpCode(AS_SCREENMODE_CHANGED); _winlink->SetOpCode(AS_SCREENMODE_CHANGED);
_winlink->Attach<BRect>(frame); _winlink->Attach<BRect>(frame);
_winlink->Attach(&cspace,sizeof(color_space)); _winlink->Attach(&cspace,sizeof(color_space));
@ -356,10 +356,8 @@ void ServerWindow::ScreenModeChanged(const BRect frame, const color_space cspace
*/ */
void ServerWindow::SetFrame(const BRect &rect) void ServerWindow::SetFrame(const BRect &rect)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Set Frame to (%.1f,%.1f,%.1f,%.1f)\n",_title->String(),
printf("ServerWindow %s: Set Frame to (%.1f,%.1f,%.1f,%.1f)\n",_title->String(), rect.left,rect.top,rect.right,rect.bottom));
rect.left,rect.top,rect.right,rect.bottom);
#endif
_frame=rect; _frame=rect;
} }
@ -378,18 +376,14 @@ BRect ServerWindow::Frame(void)
*/ */
status_t ServerWindow::Lock(void) status_t ServerWindow::Lock(void)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Lock\n",_title->String()));
printf("ServerWindow %s: Lock\n",_title->String());
#endif
return (_locker.Lock())?B_OK:B_ERROR; return (_locker.Lock())?B_OK:B_ERROR;
} }
//! Unlocks the window //! Unlocks the window
void ServerWindow::Unlock(void) void ServerWindow::Unlock(void)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Unlock\n",_title->String()));
printf("ServerWindow %s: Unlock\n",_title->String());
#endif
_locker.Unlock(); _locker.Unlock();
} }
@ -406,28 +400,64 @@ void ServerWindow::DispatchMessage( int32 code )
{ {
switch( code ) switch( code )
{ {
/********** BView Messages ***********/
case AS_SET_CURRENT_LAYER:
{
int32 token;
ses->ReadInt32( &token );
Layer *current = FindLayer( top_layer, token );
if (current)
cl = current;
else // hope this NEVER happens! :-)
printf("!Server PANIC: window %s: cannot find Layer with ID %ld\n", _title->String(), token);
STRACE(("ServerWindow %s: Message Set_Current_Layer: Layer ID: %ld\n", _title->String(), token));
break;
}
case AS_LAYER_CREATE: case AS_LAYER_CREATE:
{ {
// Received when a view is attached to a window. This will require // Received when a view is attached to a window. This will require
// us to attach a layer in the tree in the same manner and invalidate // us to attach a layer in the tree in the same manner and invalidate
// the area in which the new layer resides assuming that it is // the area in which the new layer resides assuming that it is
// visible. // visible.
Layer *oldCL = cl;
// Attached Data:
// 1) (int32) id of the parent view
// 2) (BRect) frame in parent's coordinates
// 3) (int32) resize flags
// 4) (int32) view flags
// 5) (uint16) view's hide level
// This is a synchronous call, so reply immediately with the ID of the layer int32 token;
// so the BView can identify itself BRect frame;
uint32 resizeMask;
// TODO: Implement uint32 flags;
#ifdef DEBUG_SERVERWINDOW int32 childCount;
printf("ServerWindow %s: Message Create_Layer unimplemented\n",_title->String()); char* name;
#endif
ses->ReadInt32( &token );
name = ses->ReadString();
ses->ReadRect( &frame );
ses->ReadInt32( (int32*)&resizeMask );
ses->ReadInt32( (int32*)&flags );
ses->ReadInt32( &childCount );
Layer *newLayer;
newLayer = new Layer(frame, name, token, resizeMask, flags, this);
// TODO: review Layer::AddChild
cl->AddChild( newLayer );
cl = newLayer;
int32 msgCode;
ses->ReadInt32( &msgCode ); // this is AS_LAYER_SET_STATE
DispatchMessage( msgCode );
for(int i = 0; i < childCount; i++){
ses->ReadInt32( &msgCode ); // this is AS_LAYER_CREATE
DispatchMessage( msgCode );
}
cl = oldCL;
STRACE(("ServerWindow %s: Message Create_Layer unimplemented\n",_title->String()));
break; break;
} }
case AS_LAYER_DELETE: case AS_LAYER_DELETE:
@ -441,21 +471,86 @@ void ServerWindow::DispatchMessage( int32 code )
// 1) (int32) id of the removed view // 1) (int32) id of the removed view
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Delete_Layer unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Delete_Layer unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_LAYER_SET_STATE:
{
rgb_color highColor,
lowColor,
viewColor;
pattern patt;
int32 clippRegRects;
ses->ReadPoint( &(cl->_layerdata->penlocation) );
ses->ReadFloat( &(cl->_layerdata->pensize) );
ses->ReadData( &highColor, sizeof(rgb_color) );
ses->ReadData( &lowColor, sizeof(rgb_color) );
ses->ReadData( &viewColor, sizeof(rgb_color) );
ses->ReadData( &patt, sizeof(pattern) );
ses->ReadInt8( (int8*)&(cl->_layerdata->draw_mode) );
ses->ReadPoint( &(cl->_layerdata->coordOrigin) );
ses->ReadInt8( (int8*)&(cl->_layerdata->lineJoin) );
ses->ReadInt8( (int8*)&(cl->_layerdata->lineCap) );
ses->ReadFloat( &(cl->_layerdata->miterLimit) );
ses->ReadInt8( (int8*)&(cl->_layerdata->alphaSrcMode) );
ses->ReadInt8( (int8*)&(cl->_layerdata->alphaFncMode) );
ses->ReadFloat( &(cl->_layerdata->scale) );
ses->ReadBool( &(cl->_layerdata->fontAliasing) );
ses->ReadInt32( &clippRegRects );
cl->_layerdata->patt.Set( (int8*)&patt );
cl->_layerdata->highcolor.SetColor( highColor );
cl->_layerdata->lowcolor.SetColor( lowColor );
cl->_layerdata->viewcolor.SetColor( viewColor );
if( clippRegRects != 0 ){
if( cl->_layerdata->clippReg == NULL)
cl->_layerdata->clippReg = new BRegion();
else
cl->_layerdata->clippReg->MakeEmpty();
BRect rect;
for( int32 i = 0; i < clippRegRects; i++){
ses->ReadRect( &rect );
cl->_layerdata->clippReg->Include( rect );
}
}
else{
if ( cl->_layerdata->clippReg ){
delete cl->_layerdata->clippReg;
cl->_layerdata->clippReg = NULL;
}
}
STRACE(("ServerWindow %s: Message Layer_Set_State\n",_title->String()));
break;
}
/********** END: BView Messages ***********/
/********** BWindow Messages ***********/
case AS_LAYER_CREATE_ROOT: case AS_LAYER_CREATE_ROOT:
{ {
// Received when a window creates its internal top view // Received when a window creates its internal top view
int32 token;
// TODO: Implement BRect frame;
#ifdef DEBUG_SERVERWINDOW uint32 resizeMode;
printf("ServerWindow %s: Message Create_Layer_Root unimplemented\n",_title->String()); uint32 flags;
#endif char* name = NULL;
ses->ReadInt32( &token );
ses->ReadRect( &frame );
ses->ReadInt32( (int32*)&resizeMode );
ses->ReadInt32( (int32*)&flags );
name = ses->ReadString();
top_layer = new Layer( frame, name, token, resizeMode,
flags, this );
STRACE(("ServerWindow %s: Message Create_Layer_Root\n",_title->String()));
break; break;
} }
case AS_LAYER_DELETE_ROOT: case AS_LAYER_DELETE_ROOT:
@ -463,183 +558,140 @@ void ServerWindow::DispatchMessage( int32 code )
// Received when a window deletes its internal top view // Received when a window deletes its internal top view
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Delete_Layer_Root unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Delete_Layer_Root unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_SHOW_WINDOW: case AS_SHOW_WINDOW:
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message AS_SHOW\n",_title->String()));
printf("ServerWindow %s: Message AS_SHOW\n",_title->String());
#endif
Show(); Show();
break; break;
} }
case AS_HIDE_WINDOW: case AS_HIDE_WINDOW:
{ {
STRACE(("ServerWindow %s: Message AS_HIDE\n",_title->String()));
Hide(); Hide();
break; break;
} }
case AS_SEND_BEHIND: case AS_SEND_BEHIND:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Send_Behind unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Send_Behind unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_ENABLE_UPDATES: case AS_ENABLE_UPDATES:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Enable_Updates unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Enable_Updates unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_DISABLE_UPDATES: case AS_DISABLE_UPDATES:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Disable_Updates unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Disable_Updates unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_NEEDS_UPDATE: case AS_NEEDS_UPDATE:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Needs_Update unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Needs_Update unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_WINDOW_TITLE: case AS_WINDOW_TITLE:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Set_Title unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Set_Title unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_ADD_TO_SUBSET: case AS_ADD_TO_SUBSET:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Add_To_Subset unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Add_To_Subset unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_REM_FROM_SUBSET: case AS_REM_FROM_SUBSET:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Remove_From_Subset unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Remove_From_Subset unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_SET_LOOK: case AS_SET_LOOK:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Set_Look unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Set_Look unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_SET_FLAGS: case AS_SET_FLAGS:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Set_Flags unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Set_Flags unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_SET_FEEL: case AS_SET_FEEL:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Set_Feel unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Set_Feel unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_SET_ALIGNMENT: case AS_SET_ALIGNMENT:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Set_Alignment unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Set_Alignment unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_GET_ALIGNMENT: case AS_GET_ALIGNMENT:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Get_Alignment unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Get_Alignment unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_GET_WORKSPACES: case AS_GET_WORKSPACES:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Get_Workspaces unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Get_Workspaces unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_SET_WORKSPACES: case AS_SET_WORKSPACES:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Set_Workspaces unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Set_Workspaces unimplemented\n",_title->String());
#endif
break; break;
} }
case AS_WINDOW_RESIZE: case AS_WINDOW_RESIZE:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Resize unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Resize unimplemented\n",_title->String());
#endif
break; break;
} }
case B_MINIMIZE: case B_MINIMIZE:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Minimize unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Minimize unimplemented\n",_title->String());
#endif
break; break;
} }
case B_WINDOW_ACTIVATED: case B_WINDOW_ACTIVATED:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Window_Activated unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Window_Activated unimplemented\n",_title->String());
#endif
break; break;
} }
case B_ZOOM: case B_ZOOM:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Zoom unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Zoom unimplemented\n",_title->String());
#endif
break; break;
} }
case B_WINDOW_MOVE_TO: case B_WINDOW_MOVE_TO:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Move_To unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Move_To unimplemented\n",_title->String());
#endif
break; break;
} }
case B_WINDOW_MOVE_BY: case B_WINDOW_MOVE_BY:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Message Move_By unimplemented\n",_title->String()));
printf("ServerWindow %s: Message Move_By unimplemented\n",_title->String());
#endif
break; break;
} }
default: default:
@ -1207,9 +1259,7 @@ int32 ServerWindow::MonitorWin(void *data)
if ( rv != B_BAD_PORT_ID ){ if ( rv != B_BAD_PORT_ID ){
switch( code ){ switch( code ){
case B_QUIT_REQUESTED:{ case B_QUIT_REQUESTED:{
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s received Quit request\n",win->Title()));
printf("ServerWindow %s received Quit request\n",win->Title());
#endif
// Our BWindow sent us this message when it quit. // Our BWindow sent us this message when it quit.
// We need to ask its ServerApp to delete our monitor // We need to ask its ServerApp to delete our monitor
win->_applink->SetOpCode(AS_DELETE_WINDOW); win->_applink->SetOpCode(AS_DELETE_WINDOW);
@ -1377,9 +1427,7 @@ void ServerWindow::HandleMouseEvent(PortMessage *msg)
*/ */
void ServerWindow::HandleKeyEvent(int32 code, int8 *buffer) void ServerWindow::HandleKeyEvent(int32 code, int8 *buffer)
{ {
#ifdef DEBUG_SERVERWINDOW_KEYBOARD STRACE_KEY(("ServerWindow::HandleKeyEvent unimplemented\n"));
printf("ServerWindow::HandleKeyEvent unimplemented\n");
#endif
/* ServerWindow *keywin=NULL; /* ServerWindow *keywin=NULL;
// Dispatch the key event to the active window // Dispatch the key event to the active window
@ -1413,20 +1461,41 @@ Workspace *ServerWindow::GetWorkspace(void)
*/ */
void ServerWindow::SetWorkspace(Workspace *wkspc) void ServerWindow::SetWorkspace(Workspace *wkspc)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ServerWindow %s: Set Workspace\n",_title->String()));
printf("ServerWindow %s: Set Workspace\n",_title->String());
#endif
_workspace=wkspc; _workspace=wkspc;
} }
Layer* ServerWindow::FindLayer(const Layer* start, int32 token) const
{
if( !start )
return NULL;
Layer *c = start->_topchild; //c = short for: current
if( c != NULL )
while( c != start ){
if( c->_view_token == token )
return c;
if( c->_topchild )
c = c->_topchild;
else
if( c->_lowersibling )
c = c->_lowersibling;
else
c = c->_parent;
}
return NULL;
}
//-----------------------------------------------------------------------
/*! /*!
\brief Handles window activation stuff. Called by Desktop functions \brief Handles window activation stuff. Called by Desktop functions
*/ */
void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin) void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin)
{ {
#ifdef DEBUG_SERVERWINDOW STRACE(("ActivateWindow: old=%s, new=%s\n",oldwin?oldwin->Title():"NULL",newwin?newwin->Title():"NULL"));
printf("ActivateWindow: old=%s, new=%s\n",oldwin?oldwin->Title():"NULL",newwin?newwin->Title():"NULL");
#endif
if(oldwin==newwin) if(oldwin==newwin)
return; return;

View File

@ -36,8 +36,6 @@
#include <Window.h> #include <Window.h>
#include <PortMessage.h> #include <PortMessage.h>
#include <Session.h>
class BString; class BString;
class BMessenger; class BMessenger;
class BPoint; class BPoint;
@ -46,6 +44,8 @@ class Decorator;
class PortLink; class PortLink;
class WinBorder; class WinBorder;
class Workspace; class Workspace;
class BSession;
class Layer;
/*! /*!
\class ServerWindow ServerWindow.h \class ServerWindow ServerWindow.h
@ -100,6 +100,8 @@ public:
//! Returns the window's title //! Returns the window's title
const char *Title(void) { return _title->String(); } const char *Title(void) { return _title->String(); }
Layer* FindLayer(const Layer* start, int32 token) const;
protected: protected:
friend class ServerApp; friend class ServerApp;
friend class WinBorder; friend class WinBorder;
@ -124,7 +126,9 @@ protected:
int32 _handlertoken; int32 _handlertoken;
// ADI: // ADI:
BSession *ses; BSession* ses;
Layer* top_layer;
Layer* cl; // short for currentLayer. We'll use it a lot, that's why it's short :-)
}; };
void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin); void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin);