Janitorial work and minor ServerWindow tweaks

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7907 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2004-06-11 14:47:36 +00:00
parent 768ec791c9
commit 70e337a0b4
4 changed files with 702 additions and 809 deletions
+49 -40
View File
@@ -53,12 +53,13 @@
//#define DISPLAYDRIVER_TEST_HACK //#define DISPLAYDRIVER_TEST_HACK
//---------------------------------------------------------------------------
RootLayer::RootLayer(const char *name, int32 workspaceCount, RootLayer::RootLayer(const char *name, int32 workspaceCount,
Desktop *desktop, DisplayDriver *driver) Desktop *desktop, DisplayDriver *driver)
: Layer(BRect(0,0,0,0), name, 0, B_FOLLOW_ALL, B_WILL_DRAW, driver) : Layer(BRect(0,0,0,0), name, 0, B_FOLLOW_ALL, B_WILL_DRAW, driver)
{ {
fDesktop = desktop; fDesktop = desktop;
//NOTE: be careful about this one. //NOTE: be careful about this one.
fRootLayer = this; fRootLayer = this;
fActiveWorkspace = NULL; fActiveWorkspace = NULL;
@@ -75,12 +76,12 @@ RootLayer::RootLayer(const char *name, int32 workspaceCount,
SetWorkspaceCount(workspaceCount); SetWorkspaceCount(workspaceCount);
} }
//---------------------------------------------------------------------------
RootLayer::~RootLayer() RootLayer::~RootLayer()
{ {
// RootLayer object just uses Screen objects, it is not allowed to delete them. // RootLayer object just uses Screen objects, it is not allowed to delete them.
} }
//---------------------------------------------------------------------------
void RootLayer::Draw(const BRect &r) void RootLayer::Draw(const BRect &r)
{ {
// REMOVEME: This method is here because of DisplayDriver testing ONLY. // REMOVEME: This method is here because of DisplayDriver testing ONLY.
@@ -154,39 +155,40 @@ void RootLayer::Draw(const BRect &r)
_driver->FillRoundRect(BRect(800,1000,1200,1090),30,40,_layerdata,pattern2); _driver->FillRoundRect(BRect(800,1000,1200,1090),30,40,_layerdata,pattern2);
_driver->FillPolygon(polygon,6,polygonRect,_layerdata,pattern); _driver->FillPolygon(polygon,6,polygonRect,_layerdata,pattern);
// _driver->FillTriangle(triangle,triangleRect,_layerdata,pattern); // _driver->FillTriangle(triangle,triangleRect,_layerdata,pattern);
#endif
#endif // end DISPLAYDRIVER_TEST_HACK
} }
//---------------------------------------------------------------------------
void RootLayer::MoveBy(float x, float y) void RootLayer::MoveBy(float x, float y)
{ {
} }
//---------------------------------------------------------------------------
void RootLayer::ResizeBy(float x, float y) void RootLayer::ResizeBy(float x, float y)
{ {
// TODO: implement // TODO: implement
} }
//---------------------------------------------------------------------------
Layer* RootLayer::VirtualTopChild() const Layer* RootLayer::VirtualTopChild() const
{ {
return fActiveWorkspace->GoToTopItem(); return fActiveWorkspace->GoToTopItem();
} }
//---------------------------------------------------------------------------
Layer* RootLayer::VirtualLowerSibling() const Layer* RootLayer::VirtualLowerSibling() const
{ {
return fActiveWorkspace->GoToLowerItem(); return fActiveWorkspace->GoToLowerItem();
} }
//---------------------------------------------------------------------------
Layer* RootLayer::VirtualUpperSibling() const Layer* RootLayer::VirtualUpperSibling() const
{ {
return fActiveWorkspace->GoToUpperItem(); return fActiveWorkspace->GoToUpperItem();
} }
//---------------------------------------------------------------------------
Layer* RootLayer::VirtualBottomChild() const Layer* RootLayer::VirtualBottomChild() const
{ {
return fActiveWorkspace->GoToBottomItem(); return fActiveWorkspace->GoToBottomItem();
} }
//---------------------------------------------------------------------------
void RootLayer::AddWinBorderToWorkspaces(WinBorder* winBorder, uint32 wks) void RootLayer::AddWinBorderToWorkspaces(WinBorder* winBorder, uint32 wks)
{ {
if (!(fMainLock.IsLocked())) if (!(fMainLock.IsLocked()))
@@ -204,7 +206,7 @@ void RootLayer::AddWinBorderToWorkspaces(WinBorder* winBorder, uint32 wks)
WorkspaceAt(i+1)->AddLayerPtr(winBorder); WorkspaceAt(i+1)->AddLayerPtr(winBorder);
} }
} }
//---------------------------------------------------------------------------
void RootLayer::AddWinBorder(WinBorder* winBorder) void RootLayer::AddWinBorder(WinBorder* winBorder)
{ {
// The main job of this function, besides adding winBorder as a child, is to determine // The main job of this function, besides adding winBorder as a child, is to determine
@@ -235,7 +237,6 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
// will be called. // will be called.
break; break;
} }
case B_MODAL_APP_WINDOW_FEEL: case B_MODAL_APP_WINDOW_FEEL:
{ {
// add to app's list of Floating/Modal windows (as opposed to the system's) // add to app's list of Floating/Modal windows (as opposed to the system's)
@@ -317,7 +318,6 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
AddWinBorderToWorkspaces(winBorder, winBorder->Window()->Workspaces()); AddWinBorderToWorkspaces(winBorder, winBorder->Window()->Workspaces());
break; break;
} }
case B_SYSTEM_LAST: case B_SYSTEM_LAST:
case B_SYSTEM_FIRST: case B_SYSTEM_FIRST:
{ {
@@ -338,14 +338,12 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
STRACE(("#RootLayer::AddWinBorder(%s)\n", winBorder->GetName())); STRACE(("#RootLayer::AddWinBorder(%s)\n", winBorder->GetName()));
} }
//---------------------------------------------------------------------------
void RootLayer::RemoveWinBorder(WinBorder* winBorder) void RootLayer::RemoveWinBorder(WinBorder* winBorder)
{ {
// This method does 3 things: // This method does 3 things:
// 1) Removes MODAL/SUBSET windows from system/app/window subset list. // 1) Removes MODAL/SUBSET windows from system/app/window subset list.
// 2) Removes this window from any workspace it appears in. // 2) Removes this window from any workspace it appears in.
// 3) Removes this window from RootLayer's list of chilren. // 3) Removes this window from RootLayer's list of children.
desktop->fGeneralLock.Lock(); desktop->fGeneralLock.Lock();
fMainLock.Lock(); fMainLock.Lock();
@@ -355,11 +353,13 @@ void RootLayer::RemoveWinBorder(WinBorder* winBorder)
{ {
desktop->RemoveSubsetWindow(winBorder); desktop->RemoveSubsetWindow(winBorder);
} }
else if (feel == B_MODAL_APP_WINDOW_FEEL || feel == B_FLOATING_APP_WINDOW_FEEL) else
if (feel == B_MODAL_APP_WINDOW_FEEL || feel == B_FLOATING_APP_WINDOW_FEEL)
{ {
RemoveAppWindow(winBorder); RemoveAppWindow(winBorder);
} }
else if(feel == B_MODAL_ALL_WINDOW_FEEL || feel == B_FLOATING_ALL_WINDOW_FEEL else
if(feel == B_MODAL_ALL_WINDOW_FEEL || feel == B_FLOATING_ALL_WINDOW_FEEL
|| feel == B_SYSTEM_FIRST || feel == B_SYSTEM_LAST) || feel == B_SYSTEM_FIRST || feel == B_SYSTEM_LAST)
{ {
if(feel == B_MODAL_ALL_WINDOW_FEEL || feel == B_FLOATING_ALL_WINDOW_FEEL) if(feel == B_MODAL_ALL_WINDOW_FEEL || feel == B_FLOATING_ALL_WINDOW_FEEL)
@@ -374,16 +374,18 @@ void RootLayer::RemoveWinBorder(WinBorder* winBorder)
uint32 workspaces = winBorder->Window()->Workspaces(); uint32 workspaces = winBorder->Window()->Workspaces();
int32 count = WorkspaceCount(); int32 count = WorkspaceCount();
for( int32 i=0; i < 32 && i < count; i++) for( int32 i=0; i < 32 && i < count; i++)
{
if( workspaces & (0x00000001UL << i)) if( workspaces & (0x00000001UL << i))
WorkspaceAt(i+1)->RemoveLayerPtr(winBorder); WorkspaceAt(i+1)->RemoveLayerPtr(winBorder);
} }
}
RemoveChild(winBorder); RemoveChild(winBorder);
fMainLock.Unlock(); fMainLock.Unlock();
desktop->fGeneralLock.Unlock(); desktop->fGeneralLock.Unlock();
} }
//---------------------------------------------------------------------------
void RootLayer::ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces) void RootLayer::ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces)
{ {
// only normal windows are affected by this change // only normal windows are affected by this change
@@ -397,17 +399,19 @@ void RootLayer::ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces)
{ {
// do nothing. // do nothing.
} }
else if(oldWorkspaces & (0x00000001 << i)) else
if(oldWorkspaces & (0x00000001 << i))
{ {
WorkspaceAt(i+1)->RemoveLayerPtr(winBorder); WorkspaceAt(i+1)->RemoveLayerPtr(winBorder);
} }
else if (newWorkspaces & (0x00000001 << i)) else
if (newWorkspaces & (0x00000001 << i))
{ {
WorkspaceAt(i+1)->AddLayerPtr(winBorder); WorkspaceAt(i+1)->AddLayerPtr(winBorder);
} }
} }
} }
//---------------------------------------------------------------------------
bool RootLayer::SetFrontWinBorder(WinBorder* winBorder) bool RootLayer::SetFrontWinBorder(WinBorder* winBorder)
{ {
if(!winBorder) if(!winBorder)
@@ -436,11 +440,13 @@ bool RootLayer::SetFrontWinBorder(WinBorder* winBorder)
{ {
int32 i; int32 i;
for( i = 0; i < 32 && i < count; i++) for( i = 0; i < 32 && i < count; i++)
{
if( workspaces & (0x00000001UL << i)) if( workspaces & (0x00000001UL << i))
{ {
newWorkspace = i+1; newWorkspace = i+1;
break; break;
} }
}
if (i == count || i == 32) if (i == count || i == 32)
newWorkspace = ActiveWorkspaceIndex(); newWorkspace = ActiveWorkspaceIndex();
@@ -451,7 +457,8 @@ bool RootLayer::SetFrontWinBorder(WinBorder* winBorder)
WorkspaceAt(newWorkspace)->SetFrontLayer(winBorder); WorkspaceAt(newWorkspace)->SetFrontLayer(winBorder);
SetActiveWorkspaceByIndex(newWorkspace); SetActiveWorkspaceByIndex(newWorkspace);
} }
else{ else
{
ActiveWorkspace()->SetFrontLayer(winBorder); ActiveWorkspace()->SetFrontLayer(winBorder);
} }
@@ -460,7 +467,7 @@ bool RootLayer::SetFrontWinBorder(WinBorder* winBorder)
STRACE(("#RootLayer::SetFrontWinBorder(%s)\n", winBorder? winBorder->GetName():"NULL")); STRACE(("#RootLayer::SetFrontWinBorder(%s)\n", winBorder? winBorder->GetName():"NULL"));
return true; return true;
} }
//---------------------------------------------------------------------------
void RootLayer::SetScreens(Screen *screen[], int32 rows, int32 columns) void RootLayer::SetScreens(Screen *screen[], int32 rows, int32 columns)
{ {
// NOTE: All screens *must* have the same resolution // NOTE: All screens *must* have the same resolution
@@ -469,11 +476,13 @@ void RootLayer::SetScreens(Screen *screen[], int32 rows, int32 columns)
for (int32 i=0; i < rows; i++) for (int32 i=0; i < rows; i++)
{ {
if (i==0) if (i==0)
{
for(int32 j=0; j < columns; j++) for(int32 j=0; j < columns; j++)
{ {
fScreenPtrList.AddItem(screen[i*rows + j]); fScreenPtrList.AddItem(screen[i*rows + j]);
newFrame.right += screen[i*rows + j]->Resolution().x; newFrame.right += screen[i*rows + j]->Resolution().x;
} }
}
newFrame.bottom += screen[i*rows]->Resolution().y; newFrame.bottom += screen[i*rows]->Resolution().y;
} }
@@ -486,14 +495,15 @@ void RootLayer::SetScreens(Screen *screen[], int32 rows, int32 columns)
fScreenXResolution = (int32)(screen[0]->Resolution().x); fScreenXResolution = (int32)(screen[0]->Resolution().x);
fScreenYResolution = (int32)(screen[0]->Resolution().y); fScreenYResolution = (int32)(screen[0]->Resolution().y);
// NOTE: a RebuildFullRegion() followed by FullInvalidate() are required after calling this method! // NOTE: a RebuildFullRegion() followed by FullInvalidate() are required after calling
// this method!
} }
//---------------------------------------------------------------------------
Screen **RootLayer::Screens() Screen **RootLayer::Screens()
{ {
return (Screen**)fScreenPtrList.Items(); return (Screen**)fScreenPtrList.Items();
} }
//---------------------------------------------------------------------------
bool RootLayer::SetScreenResolution(int32 width, int32 height, uint32 colorspace) bool RootLayer::SetScreenResolution(int32 width, int32 height, uint32 colorspace)
{ {
if (fScreenXResolution == width && fScreenYResolution == height && if (fScreenXResolution == width && fScreenYResolution == height &&
@@ -529,7 +539,7 @@ bool RootLayer::SetScreenResolution(int32 width, int32 height, uint32 colorspace
return false; return false;
} }
//---------------------------------------------------------------------------
void RootLayer::SetWorkspaceCount(const int32 count) void RootLayer::SetWorkspaceCount(const int32 count)
{ {
STRACE(("*RootLayer::SetWorkspaceCount(%ld)\n", count)); STRACE(("*RootLayer::SetWorkspaceCount(%ld)\n", count));
@@ -586,12 +596,12 @@ void RootLayer::SetWorkspaceCount(const int32 count)
STRACE(("#RootLayer::SetWorkspaceCount(%ld)\n", count)); STRACE(("#RootLayer::SetWorkspaceCount(%ld)\n", count));
} }
//---------------------------------------------------------------------------
int32 RootLayer::WorkspaceCount() const int32 RootLayer::WorkspaceCount() const
{ {
return fWSPtrList.CountItems(); return fWSPtrList.CountItems();
} }
//---------------------------------------------------------------------------
Workspace* RootLayer::WorkspaceAt(const int32 index) const Workspace* RootLayer::WorkspaceAt(const int32 index) const
{ {
Workspace *ws = NULL; Workspace *ws = NULL;
@@ -599,7 +609,7 @@ Workspace* RootLayer::WorkspaceAt(const int32 index) const
return ws; return ws;
} }
//---------------------------------------------------------------------------
void RootLayer::SetActiveWorkspaceByIndex(const int32 index) void RootLayer::SetActiveWorkspaceByIndex(const int32 index)
{ {
Workspace *ws = NULL; Workspace *ws = NULL;
@@ -607,7 +617,7 @@ void RootLayer::SetActiveWorkspaceByIndex(const int32 index)
if (ws) if (ws)
SetActiveWorkspace(ws); SetActiveWorkspace(ws);
} }
//---------------------------------------------------------------------------
void RootLayer::SetActiveWorkspace(Workspace *ws) void RootLayer::SetActiveWorkspace(Workspace *ws)
{ {
if (fActiveWorkspace == ws || !ws) if (fActiveWorkspace == ws || !ws)
@@ -618,19 +628,19 @@ void RootLayer::SetActiveWorkspace(Workspace *ws)
// RebuildRegions(Frame()); // RebuildRegions(Frame());
// Invalidate(Frame()); // Invalidate(Frame());
} }
//---------------------------------------------------------------------------
int32 RootLayer::ActiveWorkspaceIndex() const{ int32 RootLayer::ActiveWorkspaceIndex() const{
if (fActiveWorkspace) if (fActiveWorkspace)
return fActiveWorkspace->ID(); return fActiveWorkspace->ID();
else else
return -1; return -1;
} }
//---------------------------------------------------------------------------
Workspace* RootLayer::ActiveWorkspace() const Workspace* RootLayer::ActiveWorkspace() const
{ {
return fActiveWorkspace; return fActiveWorkspace;
} }
//---------------------------------------------------------------------------
void RootLayer::SetBGColor(const RGBColor &col) void RootLayer::SetBGColor(const RGBColor &col)
{ {
ActiveWorkspace()->SetBGColor(col); ActiveWorkspace()->SetBGColor(col);
@@ -639,12 +649,12 @@ void RootLayer::SetBGColor(const RGBColor &col)
// Invalidate(Frame()); // Invalidate(Frame());
} }
//---------------------------------------------------------------------------
RGBColor RootLayer::BGColor(void) const RGBColor RootLayer::BGColor(void) const
{ {
return _layerdata->viewcolor; return _layerdata->viewcolor;
} }
//---------------------------------------------------------------------------
void RootLayer::RemoveAppWindow(WinBorder *wb) void RootLayer::RemoveAppWindow(WinBorder *wb)
{ {
wb->Window()->App()->fAppFMWList.RemoveItem(wb); wb->Window()->App()->fAppFMWList.RemoveItem(wb);
@@ -653,7 +663,7 @@ void RootLayer::RemoveAppWindow(WinBorder *wb)
for(int32 i=0; i < count; i++) for(int32 i=0; i < count; i++)
WorkspaceAt(i+1)->RemoveLayerPtr(wb); WorkspaceAt(i+1)->RemoveLayerPtr(wb);
} }
//---------------------------------------------------------------------------
void RootLayer::PrintToStream() void RootLayer::PrintToStream()
{ {
printf("\nRootLayer '%s' internals:\n", GetName()); printf("\nRootLayer '%s' internals:\n", GetName());
@@ -671,5 +681,4 @@ void RootLayer::PrintToStream()
printf("~~~~~~~~\n"); printf("~~~~~~~~\n");
} }
printf("Active Workspace: %ld\n", fActiveWorkspace? fActiveWorkspace->ID(): -1); printf("Active Workspace: %ld\n", fActiveWorkspace? fActiveWorkspace->ID(): -1);
} }
+15 -14
View File
@@ -52,18 +52,19 @@ class DisplayDriver;
class RootLayer : public Layer class RootLayer : public Layer
{ {
public: public:
RootLayer(const char *name, RootLayer(const char *name, int32 workspaceCount, Desktop *desktop,
int32 workspaceCount, Desktop *desktop, DisplayDriver *driver); DisplayDriver *driver);
virtual ~RootLayer(); virtual ~RootLayer(void);
virtual void Draw(const BRect &r); virtual void Draw(const BRect &r);
virtual void MoveBy(float x, float y); virtual void MoveBy(float x, float y);
virtual void ResizeBy(float x, float y); virtual void ResizeBy(float x, float y);
virtual Layer* VirtualTopChild() const; // // For the active workspaces
virtual Layer* VirtualLowerSibling() const; // ... for the active workspace virtual Layer *VirtualTopChild(void) const;
virtual Layer* VirtualUpperSibling() const; // virtual Layer *VirtualLowerSibling(void) const;
virtual Layer* VirtualBottomChild() const; // virtual Layer *VirtualUpperSibling(void) const;
virtual Layer *VirtualBottomChild(void) const;
void AddWinBorder(WinBorder *winBorder); void AddWinBorder(WinBorder *winBorder);
void RemoveWinBorder(WinBorder *winBorder); void RemoveWinBorder(WinBorder *winBorder);
@@ -71,10 +72,10 @@ public:
bool SetFrontWinBorder(WinBorder *winBorder); bool SetFrontWinBorder(WinBorder *winBorder);
void SetScreens(Screen *screen[], int32 rows, int32 columns); void SetScreens(Screen *screen[], int32 rows, int32 columns);
Screen** Screens(); Screen **Screens(void);
bool SetScreenResolution(int32 width, int32 height, uint32 colorspace); bool SetScreenResolution(int32 width, int32 height, uint32 colorspace);
int32 ScreenRows() const { return fRows; } int32 ScreenRows(void) const { return fRows; }
int32 ScreenColumns() const { return fColumns; } int32 ScreenColumns(void) const { return fColumns; }
void SetWorkspaceCount(const int32 count); void SetWorkspaceCount(const int32 count);
int32 WorkspaceCount(void) const; int32 WorkspaceCount(void) const;
@@ -87,16 +88,16 @@ public:
void SetBGColor(const RGBColor &col); void SetBGColor(const RGBColor &col);
RGBColor BGColor(void) const; RGBColor BGColor(void) const;
void AddWinBorderToWorkspaces(WinBorder* winBorder, void AddWinBorderToWorkspaces(WinBorder *winBorder, uint32 wks);
uint32 wks);
void PrintToStream(void);
// ------- debugging methods -------
void PrintToStream();
// "Private" to app_server :-) - they should not be used // "Private" to app_server :-) - they should not be used
void RemoveAppWindow(WinBorder *wb); void RemoveAppWindow(WinBorder *wb);
FMWList fMainFMWList; FMWList fMainFMWList;
BLocker fMainLock; BLocker fMainLock;
private: private:
Desktop *fDesktop; Desktop *fDesktop;
+186 -283
View File
@@ -128,19 +128,24 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
if(string) if(string)
fTitle.SetTo(string); fTitle.SetTo(string);
fFrame = rect; fFrame = rect;
fFlags = wflags; fFlags = wflags;
fLook = wlook; fLook = wlook;
fFeel = wfeel; fFeel = wfeel;
fHandlerToken = handlerID; fHandlerToken = handlerID;
fClientLooperPort = looperPort; fClientLooperPort = looperPort;
fWorkspaces = index;
fClientTeamID = winapp->ClientTeamID(); fClientTeamID = winapp->ClientTeamID();
fWorkspaces = index;
fWorkspace = NULL; fWorkspace = NULL;
fWinBorder = NULL; fWinBorder = NULL;
fTopLayer = NULL; fTopLayer = NULL;
// fClientWinPort is the port to which the app awaits messages from the server // fClientWinPort is the port to which the app awaits messages from the server
fClientWinPort = winport; fClientWinPort = winport;
// fMessagePort is the port to which the app sends messages for the server // fMessagePort is the port to which the app sends messages for the server
fMessagePort = create_port(30,fTitle.String()); fMessagePort = create_port(30,fTitle.String());
@@ -153,9 +158,8 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
winLink.Attach<port_id>(fMessagePort); winLink.Attach<port_id>(fMessagePort);
winLink.Flush(); winLink.Flush();
int32 vCode;
// check the next 2 messages to make sure we receive top_view's attributes. // check the next 2 messages to make sure we receive top_view's attributes.
int32 vCode;
fSession->ReadInt32(&vCode); fSession->ReadInt32(&vCode);
if(vCode != AS_LAYER_CREATE_ROOT) if(vCode != AS_LAYER_CREATE_ROOT)
debugger("SERVER ERROR: ServerWindow(xxx): NO top_view data received! - 1\n"); debugger("SERVER ERROR: ServerWindow(xxx): NO top_view data received! - 1\n");
@@ -164,15 +168,13 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
if(vCode != AS_LAYER_CREATE) if(vCode != AS_LAYER_CREATE)
debugger("SERVER ERROR: ServerWindow(xxx): NO top_view data received! - 2\n"); debugger("SERVER ERROR: ServerWindow(xxx): NO top_view data received! - 2\n");
// start receiving top_view data. pass NULL as the parent view. // Start receiving top_view data -- pass NULL as the parent view.
// This should be the *only* place where this happens. // This should be the *only* place where this happens.
fTopLayer = CreateLayerTree(NULL); fTopLayer = CreateLayerTree(NULL);
fTopLayer->SetAsTopLayer(true); fTopLayer->SetAsTopLayer(true);
cl = fTopLayer; cl = fTopLayer;
// Create a WindoBorder object for our ServerWindow. fWinBorder = new WinBorder( fFrame, fTitle.String(),wlook, wfeel, wflags,
fWinBorder = new WinBorder( fFrame, fTitle.String(),
wlook, wfeel, wflags,
this, desktop->GetDisplayDriver()); this, desktop->GetDisplayDriver());
STRACE(("ServerWindow %s:\n",fTitle.String())); STRACE(("ServerWindow %s:\n",fTitle.String()));
@@ -181,14 +183,16 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
STRACE(("\tWorkspace: %ld\n",index)); STRACE(("\tWorkspace: %ld\n",index));
} }
void ServerWindow::Init(){ void ServerWindow::Init(void)
{
fWinBorder->AddChild(fTopLayer); fWinBorder->AddChild(fTopLayer);
// NOTE: this MUST be before the monitor thread is spawned! // NOTE: this MUST be before the monitor thread is spawned!
desktop->AddWinBorder(fWinBorder); desktop->AddWinBorder(fWinBorder);
// Spawn our message-monitoring fMonitorThreadID // Spawn our message-monitoring thread
fMonitorThreadID = spawn_thread(MonitorWin, fTitle.String(), B_NORMAL_PRIORITY, this); fMonitorThreadID = spawn_thread(MonitorWin, fTitle.String(), B_NORMAL_PRIORITY, this);
if(fMonitorThreadID != B_NO_MORE_THREADS && fMonitorThreadID != B_NO_MEMORY) if(fMonitorThreadID != B_NO_MORE_THREADS && fMonitorThreadID != B_NO_MEMORY)
resume_thread(fMonitorThreadID); resume_thread(fMonitorThreadID);
} }
@@ -201,16 +205,22 @@ STRACE(("*ServerWindow (%s):~ServerWindow()\n",fTitle.String()));
desktop->fGeneralLock.Lock(); desktop->fGeneralLock.Lock();
desktop->RemoveWinBorder(fWinBorder); desktop->RemoveWinBorder(fWinBorder);
STRACE(("SW(%s) Successfuly removed from the desktop\n", fTitle.String())); STRACE(("SW(%s) Successfully removed from the desktop\n", fTitle.String()));
if(fSession){
if(fSession)
{
delete fSession; delete fSession;
fSession = NULL; fSession = NULL;
} }
if (fWinBorder){
if (fWinBorder)
{
delete fWinBorder; delete fWinBorder;
fWinBorder = NULL; fWinBorder = NULL;
} }
cl = NULL; cl = NULL;
if (fTopLayer) if (fTopLayer)
delete fTopLayer; delete fTopLayer;
@@ -262,7 +272,6 @@ STRACE(("ServerWindow %s: Quit\n",fTitle.String()));
//! Shows the window's WinBorder //! Shows the window's WinBorder
void ServerWindow::Show(void) void ServerWindow::Show(void)
{ {
// whaaat?
if(!fWinBorder->IsHidden()) if(!fWinBorder->IsHidden())
return; return;
@@ -278,31 +287,33 @@ void ServerWindow::Show(void)
rl->fMainLock.Lock(); rl->fMainLock.Lock();
STRACE(("ServerWindow(%s)::Show() - Main lock acquired\n", fWinBorder->GetName())); STRACE(("ServerWindow(%s)::Show() - Main lock acquired\n", fWinBorder->GetName()));
// manualy set fWinBorder->_hidden to false because Layer's version also calls FullInvalidate. // manually set fWinBorder->_hidden to false because Layer's version also calls FullInvalidate.
fWinBorder->_hidden=false; fWinBorder->_hidden=false;
if ( (fFeel == B_FLOATING_SUBSET_WINDOW_FEEL || fFeel == B_MODAL_SUBSET_WINDOW_FEEL) if ( (fFeel == B_FLOATING_SUBSET_WINDOW_FEEL || fFeel == B_MODAL_SUBSET_WINDOW_FEEL)
&& fWinBorder->MainWinBorder() == NULL) && fWinBorder->MainWinBorder() == NULL)
{ {
// This window hasn't been added to a normal window subset, // This window hasn't been added to a normal window subset,
// so don't call placement or redrawing methods! // so don't call placement or redrawing methods
goto goOut;
} }
else
{
wksCount = rl->WorkspaceCount(); wksCount = rl->WorkspaceCount();
for(int32 i = 0; i < wksCount; i++){ for(int32 i = 0; i < wksCount; i++)
if (fWorkspaces & (0x00000001UL << i)){ {
if (fWorkspaces & (0x00000001UL << i))
{
Workspace *ws = rl->WorkspaceAt(i+1); Workspace *ws = rl->WorkspaceAt(i+1);
ws->BringToFrontANormalWindow(fWinBorder); ws->BringToFrontANormalWindow(fWinBorder);
ws->SearchAndSetNewFront(fWinBorder); ws->SearchAndSetNewFront(fWinBorder);
ws->SetFocusLayer(fWinBorder); ws->SetFocusLayer(fWinBorder);
} }
} }
}
goOut:
rl->fMainLock.Unlock(); rl->fMainLock.Unlock();
STRACE(("ServerWindow(%s)::Show() - Main lock released\n", fWinBorder->GetName())); STRACE(("ServerWindow(%s)::Show() - Main lock released\n", fWinBorder->GetName()));
desktop->fGeneralLock.Unlock(); desktop->fGeneralLock.Unlock();
STRACE(("ServerWindow(%s)::Show() - General lock released\n", fWinBorder->GetName())); STRACE(("ServerWindow(%s)::Show() - General lock released\n", fWinBorder->GetName()));
} }
@@ -315,7 +326,8 @@ void ServerWindow::Hide(void)
return; return;
STRACE(("ServerWindow %s: Hide\n",fTitle.String())); STRACE(("ServerWindow %s: Hide\n",fTitle.String()));
if(fWinBorder){ if(fWinBorder)
{
RootLayer *rl = fWinBorder->GetRootLayer(); RootLayer *rl = fWinBorder->GetRootLayer();
Workspace *ws = NULL; Workspace *ws = NULL;
@@ -328,21 +340,23 @@ void ServerWindow::Hide(void)
fWinBorder->Hide(); fWinBorder->Hide();
int32 wksCount= rl->WorkspaceCount(); int32 wksCount= rl->WorkspaceCount();
for(int32 i = 0; i < wksCount; i++){ for(int32 i = 0; i < wksCount; i++)
{
ws = rl->WorkspaceAt(i+1); ws = rl->WorkspaceAt(i+1);
if (ws->FrontLayer() == fWinBorder){
if (ws->FrontLayer() == fWinBorder)
{
ws->HideSubsetWindows(fWinBorder); ws->HideSubsetWindows(fWinBorder);
ws->SetFocusLayer(ws->FrontLayer()); ws->SetFocusLayer(ws->FrontLayer());
} }
else{ else
if (ws->FocusLayer() == fWinBorder){ {
if (ws->FocusLayer() == fWinBorder)
ws->SetFocusLayer(fWinBorder); ws->SetFocusLayer(fWinBorder);
} else
else{
ws->Invalidate(); ws->Invalidate();
} }
} }
}
rl->fMainLock.Unlock(); rl->fMainLock.Unlock();
STRACE(("ServerWindow(%s)::Hide() - Main lock released\n", fWinBorder->GetName())); STRACE(("ServerWindow(%s)::Hide() - Main lock released\n", fWinBorder->GetName()));
@@ -359,26 +373,33 @@ bool ServerWindow::IsHidden(void)
{ {
if(fWinBorder) if(fWinBorder)
return fWinBorder->IsHidden(); return fWinBorder->IsHidden();
return true; return true;
} }
void ServerWindow::Minimize(bool status){ void ServerWindow::Minimize(bool status)
{
bool sendMessages = false; bool sendMessages = false;
if (status){ if (status)
if (!IsHidden()){ {
if (!IsHidden())
{
Hide(); Hide();
sendMessages = true; sendMessages = true;
} }
} }
else{ else
if (IsHidden()){ {
if (IsHidden())
{
Show(); Show();
sendMessages = true; sendMessages = true;
} }
} }
if (sendMessages){ if (sendMessages)
{
BMessage msg; BMessage msg;
msg.what = B_MINIMIZE; msg.what = B_MINIMIZE;
msg.AddInt64("when", real_time_clock_usecs()); msg.AddInt64("when", real_time_clock_usecs());
@@ -386,11 +407,13 @@ void ServerWindow::Minimize(bool status){
SendMessageToClient(&msg); SendMessageToClient(&msg);
// TODO: notify tracker! how??? // TODO: Do we need to notify Tracker? The Deskbar? If so, how?
} }
} }
void ServerWindow::Zoom(){ // Sends a message to the client to perform a Zoom
void ServerWindow::Zoom(void)
{
BMessage msg; BMessage msg;
msg.what=B_ZOOM; msg.what=B_ZOOM;
SendMessageToClient(&msg); SendMessageToClient(&msg);
@@ -430,9 +453,10 @@ bool ServerWindow::HasFocus(void)
*/ */
void ServerWindow::WorkspaceActivated(int32 workspace, bool active) void ServerWindow::WorkspaceActivated(int32 workspace, bool active)
{ {
STRACE(("ServerWindow %s: WorkspaceActivated(%ld,%s)\n",fTitle.String(),workspace,(active)?"active":"inactive")); STRACE(("ServerWindow %s: WorkspaceActivated(%ld,%s)\n",fTitle.String(),
BMessage msg; workspace,(active)?"active":"inactive"));
BMessage msg;
msg.what = B_WORKSPACE_ACTIVATED; msg.what = B_WORKSPACE_ACTIVATED;
msg.AddInt32("workspace", workspace); msg.AddInt32("workspace", workspace);
msg.AddBool("active", active); msg.AddBool("active", active);
@@ -448,8 +472,8 @@ STRACE(("ServerWindow %s: WorkspaceActivated(%ld,%s)\n",fTitle.String(),workspac
void ServerWindow::WorkspacesChanged(int32 oldone,int32 newone) void ServerWindow::WorkspacesChanged(int32 oldone,int32 newone)
{ {
STRACE(("ServerWindow %s: WorkspacesChanged(%ld,%ld)\n",fTitle.String(),oldone,newone)); STRACE(("ServerWindow %s: WorkspacesChanged(%ld,%ld)\n",fTitle.String(),oldone,newone));
BMessage msg;
BMessage msg;
msg.what = B_WORKSPACES_CHANGED; msg.what = B_WORKSPACES_CHANGED;
msg.AddInt32("old", oldone); msg.AddInt32("old", oldone);
msg.AddInt32("new", newone); msg.AddInt32("new", newone);
@@ -464,8 +488,8 @@ STRACE(("ServerWindow %s: WorkspacesChanged(%ld,%ld)\n",fTitle.String(),oldone,n
void ServerWindow::WindowActivated(bool active) void ServerWindow::WindowActivated(bool active)
{ {
STRACE(("ServerWindow %s: WindowActivated(%s)\n",fTitle.String(),(active)?"active":"inactive")); STRACE(("ServerWindow %s: WindowActivated(%s)\n",fTitle.String(),(active)?"active":"inactive"));
BMessage msg;
BMessage msg;
msg.what = B_WINDOW_ACTIVATED; msg.what = B_WINDOW_ACTIVATED;
msg.AddBool("active", active); msg.AddBool("active", active);
@@ -516,6 +540,7 @@ BRect ServerWindow::Frame(void)
status_t ServerWindow::Lock(void) status_t ServerWindow::Lock(void)
{ {
STRACE(("ServerWindow %s: Lock\n",fTitle.String())); STRACE(("ServerWindow %s: Lock\n",fTitle.String()));
return (fLocker.Lock())?B_OK:B_ERROR; return (fLocker.Lock())?B_OK:B_ERROR;
} }
@@ -523,6 +548,7 @@ STRACE(("ServerWindow %s: Lock\n",fTitle.String()));
void ServerWindow::Unlock(void) void ServerWindow::Unlock(void)
{ {
STRACE(("ServerWindow %s: Unlock\n",fTitle.String())); STRACE(("ServerWindow %s: Unlock\n",fTitle.String()));
fLocker.Unlock(); fLocker.Unlock();
} }
@@ -535,67 +561,81 @@ bool ServerWindow::IsLocked(void)
return fLocker.IsLocked(); return fLocker.IsLocked();
} }
void ServerWindow::SetLayerFontState(Layer *layer){ /*!
\brief Sets the font state for a layer
\param layer The layer to set the font
*/
void ServerWindow::SetLayerFontState(Layer *layer)
{
uint16 mask; uint16 mask;
fSession->ReadUInt16(&mask); fSession->ReadUInt16(&mask);
if (mask & B_FONT_FAMILY_AND_STYLE){ if (mask & B_FONT_FAMILY_AND_STYLE)
{
uint32 fontID; uint32 fontID;
fSession->ReadInt32((int32*)&fontID); fSession->ReadInt32((int32*)&fontID);
// TODO: implement later. Currently there is no SetFamAndStyle(uint32) // TODO: implement later. Currently there is no SetFamAndStyle(uint32)
// in ServerFont class. DW, could you add one? // in ServerFont class. DW, could you add one?
//layer->_layerdata->font-> //layer->_layerdata->font->
} }
if (mask & B_FONT_SIZE){ if (mask & B_FONT_SIZE)
{
float size; float size;
fSession->ReadFloat(&size); fSession->ReadFloat(&size);
layer->_layerdata->font.SetSize(size); layer->_layerdata->font.SetSize(size);
} }
if (mask & B_FONT_SHEAR){ if (mask & B_FONT_SHEAR)
{
float shear; float shear;
fSession->ReadFloat(&shear); fSession->ReadFloat(&shear);
layer->_layerdata->font.SetShear(shear); layer->_layerdata->font.SetShear(shear);
} }
if (mask & B_FONT_ROTATION){ if (mask & B_FONT_ROTATION)
{
float rotation; float rotation;
fSession->ReadFloat(&rotation); fSession->ReadFloat(&rotation);
layer->_layerdata->font.SetRotation(rotation); layer->_layerdata->font.SetRotation(rotation);
} }
if (mask & B_FONT_SPACING){ if (mask & B_FONT_SPACING)
{
uint8 spacing; uint8 spacing;
fSession->ReadUInt8(&spacing); // uint8 fSession->ReadUInt8(&spacing);
layer->_layerdata->font.SetSpacing(spacing); layer->_layerdata->font.SetSpacing(spacing);
} }
if (mask & B_FONT_ENCODING){ if (mask & B_FONT_ENCODING)
{
uint8 encoding; uint8 encoding;
fSession->ReadUInt8((uint8*)&encoding); // uint8 fSession->ReadUInt8((uint8*)&encoding);
layer->_layerdata->font.SetEncoding(encoding); layer->_layerdata->font.SetEncoding(encoding);
} }
if (mask & B_FONT_FACE){ if (mask & B_FONT_FACE)
{
uint16 face; uint16 face;
fSession->ReadUInt16(&face); // uint16 fSession->ReadUInt16(&face);
layer->_layerdata->font.SetFace(face); layer->_layerdata->font.SetFace(face);
} }
if (mask & B_FONT_FLAGS){ if (mask & B_FONT_FLAGS)
{
uint32 flags; uint32 flags;
fSession->ReadUInt32(&flags); // uint32 fSession->ReadUInt32(&flags);
layer->_layerdata->font.SetFlags(flags); layer->_layerdata->font.SetFlags(flags);
} }
STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer: %s\n",fTitle.String(), layer->_name->String())); STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer: %s\n",
fTitle.String(), layer->_name->String()));
} }
void ServerWindow::SetLayerState(Layer *layer){ void ServerWindow::SetLayerState(Layer *layer)
rgb_color highColor, {
lowColor, rgb_color highColor, lowColor, viewColor;
viewColor;
pattern patt; pattern patt;
int32 clipRegRects; int32 clipRegRects;
@@ -621,7 +661,8 @@ void ServerWindow::SetLayerState(Layer *layer){
layer->_layerdata->lowcolor.SetColor(lowColor); layer->_layerdata->lowcolor.SetColor(lowColor);
layer->_layerdata->viewcolor.SetColor(viewColor); layer->_layerdata->viewcolor.SetColor(viewColor);
if(clipRegRects != 0){ if(clipRegRects != 0)
{
if(layer->_layerdata->clipReg == NULL) if(layer->_layerdata->clipReg == NULL)
layer->_layerdata->clipReg = new BRegion(); layer->_layerdata->clipReg = new BRegion();
else else
@@ -629,21 +670,26 @@ void ServerWindow::SetLayerState(Layer *layer){
BRect rect; BRect rect;
for(int32 i = 0; i < clipRegRects; i++){ for(int32 i = 0; i < clipRegRects; i++)
{
fSession->ReadRect(&rect); fSession->ReadRect(&rect);
layer->_layerdata->clipReg->Include(rect); layer->_layerdata->clipReg->Include(rect);
} }
} }
else{ else
if (layer->_layerdata->clipReg){ {
if (layer->_layerdata->clipReg)
{
delete layer->_layerdata->clipReg; delete layer->_layerdata->clipReg;
layer->_layerdata->clipReg = NULL; layer->_layerdata->clipReg = NULL;
} }
} }
STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_STATE: Layer: %s\n",fTitle.String(), layer->_name->String())); STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_STATE: Layer: %s\n",fTitle.String(),
layer->_name->String()));
} }
Layer* ServerWindow::CreateLayerTree(Layer *localRoot){ Layer * ServerWindow::CreateLayerTree(Layer *localRoot)
{
STRACE(("ServerWindow(%s)::CreateLayerTree()\n", fTitle.String())); STRACE(("ServerWindow(%s)::CreateLayerTree()\n", fTitle.String()));
int32 token; int32 token;
@@ -663,10 +709,11 @@ STRACE(("ServerWindow(%s)::CreateLayerTree()\n", fTitle.String()));
fSession->ReadInt32(&childCount); fSession->ReadInt32(&childCount);
Layer *newLayer; Layer *newLayer;
newLayer = new Layer(frame.OffsetToCopy(0.0, 0.0), name, token, resizeMask, flags, desktop->GetDisplayDriver()); newLayer = new Layer(frame.OffsetToCopy(0.0, 0.0), name, token, resizeMask,
flags, desktop->GetDisplayDriver());
delete name; delete name;
// there is no way of setting this, other than manual. :-) // there is no way of setting this, other than manually :-)
newLayer->_hidden = hidden; newLayer->_hidden = hidden;
int32 dummyMsg; int32 dummyMsg;
@@ -698,7 +745,9 @@ STRACE(("ServerWindow(%s)::CreateLayerTree()\n", fTitle.String()));
else else
debugger("ServerWindow(%s) - AS_LAYER_CREATE Expected!\n"); debugger("ServerWindow(%s) - AS_LAYER_CREATE Expected!\n");
} }
STRACE(("DONE: ServerWindow %s: Message AS_CREATE_LAYER: Parent: %s, Child: %s\n", fTitle.String(), newLayer->_name->String(), name)); STRACE(("DONE: ServerWindow %s: Message AS_CREATE_LAYER: Parent: %s, Child: %s\n", fTitle.String(),
newLayer->_name->String(), name));
return newLayer; return newLayer;
} }
@@ -728,6 +777,8 @@ void ServerWindow::DispatchMessage(int32 code)
cl->fDriver->DrawBitmap(&region, sbmp, src, dst, cl->_layerdata); cl->fDriver->DrawBitmap(&region, sbmp, src, dst, cl->_layerdata);
} }
// TODO: Adi -- shouldn't this sync with the client?
break; break;
} }
case AS_LAYER_DRAW_BITMAP_ASYNC_AT_POINT: case AS_LAYER_DRAW_BITMAP_ASYNC_AT_POINT:
@@ -765,8 +816,16 @@ void ServerWindow::DispatchMessage(int32 code)
ServerBitmap *sbmp = fServerApp->FindBitmap(bitmapToken); ServerBitmap *sbmp = fServerApp->FindBitmap(bitmapToken);
if(sbmp) if(sbmp)
{ {
//cl->fDriver->DrawBitmap(&region, sbmp, srcRect, dstRect, cl->_layerdata); BRegion region;
BRect dst;
region = cl->_parent->ConvertFromParent(&(cl->_full));
dst = cl->_parent->ConvertFromParent(cl->_full.Frame());
dstRect.OffsetBy(dst.left, dst.top);
cl->fDriver->DrawBitmap(&region, sbmp, srcRect, dstRect, cl->_layerdata);
} }
// TODO: Adi -- shouldn't this sync with the client?
break; break;
} }
case AS_LAYER_DRAW_BITMAP_ASYNC_IN_RECT: case AS_LAYER_DRAW_BITMAP_ASYNC_IN_RECT:
@@ -788,9 +847,6 @@ void ServerWindow::DispatchMessage(int32 code)
dstRect.OffsetBy(dst.left, dst.top); dstRect.OffsetBy(dst.left, dst.top);
cl->fDriver->DrawBitmap(&region, sbmp, srcRect, dstRect, cl->_layerdata); cl->fDriver->DrawBitmap(&region, sbmp, srcRect, dstRect, cl->_layerdata);
//printf("%d %d %d %d %d %d %d %d %d %d\n", (int)cl->_boundsLeftTop.x, (int)cl->_boundsLeftTop.y,
// (int)cl->_frame.left, (int)cl->_frame.top, (int)cl->_frame.right, (int)cl->_frame.bottom,
// (int)cl->_parent->_frame.left, (int)cl->_parent->_frame.top, (int)cl->_parent->_frame.right, (int)cl->_parent->_frame.bottom);
} }
break; break;
} }
@@ -801,6 +857,7 @@ void ServerWindow::DispatchMessage(int32 code)
fSession->ReadInt32(&token); fSession->ReadInt32(&token);
Layer *current = FindLayer(fTopLayer, token); Layer *current = FindLayer(fTopLayer, token);
if (current) if (current)
cl=current; cl=current;
else // hope this NEVER happens! :-) else // hope this NEVER happens! :-)
@@ -820,7 +877,8 @@ void ServerWindow::DispatchMessage(int32 code)
// the less taxing operation - we call PruneTree() on the removed // the less taxing operation - we call PruneTree() on the removed
// layer, detach the layer itself, delete it, and invalidate the // layer, detach the layer itself, delete it, and invalidate the
// area assuming that the view was visible when removed // area assuming that the view was visible when removed
STRACE(("SW %s: AS_LAYER_DELETE(self)...\n", fTitle.String()));
STRACE(("ServerWindow %s: AS_LAYER_DELETE(self)...\n", fTitle.String()));
Layer *parent; Layer *parent;
parent = cl->_parent; parent = cl->_parent;
@@ -828,7 +886,7 @@ void ServerWindow::DispatchMessage(int32 code)
cl->RemoveSelf(); cl->RemoveSelf();
// TODO: invalidate the region occupied by this view. // TODO: invalidate the region occupied by this view.
// Should be done in Layer::RemoveChild() though! // Should be done in Layer::RemoveChild() though
cl->PruneTree(); cl->PruneTree();
parent->PrintTree(); parent->PrintTree();
@@ -865,8 +923,9 @@ void ServerWindow::DispatchMessage(int32 code)
vc = ld->viewcolor.GetColor32(); vc = ld->viewcolor.GetColor32();
patt = ld->patt.GetInt64(); patt = ld->patt.GetInt64();
// TODO: DW implement such a method in ServerFont class! // TODO: DW implement such a method in ServerFont class
fSession->WriteUInt32(0UL /*uint32 ld->font.GetFamAndStyle()*/); // fSession->WriteUInt32(ld->font.GetFamAndStyle());
fSession->WriteUInt32(0UL);
fSession->WriteFloat(ld->font.Size()); fSession->WriteFloat(ld->font.Size());
fSession->WriteFloat(ld->font.Shear()); fSession->WriteFloat(ld->font.Shear());
fSession->WriteFloat(ld->font.Rotation()); fSession->WriteFloat(ld->font.Rotation());
@@ -897,9 +956,8 @@ void ServerWindow::DispatchMessage(int32 code)
fSession->WriteInt32(noOfRects); fSession->WriteInt32(noOfRects);
for(int i = 0; i < noOfRects; i++){ for(int i = 0; i < noOfRects; i++)
fSession->WriteRect(ld->clipReg->RectAt(i)); fSession->WriteRect(ld->clipReg->RectAt(i));
}
fSession->WriteFloat(cl->_frame.left); fSession->WriteFloat(cl->_frame.left);
fSession->WriteFloat(cl->_frame.top); fSession->WriteFloat(cl->_frame.top);
@@ -1007,9 +1065,9 @@ void ServerWindow::DispatchMessage(int32 code)
{ {
int8 lineCap, lineJoin; int8 lineCap, lineJoin;
// TODO: speak with DW! Shouldn't we lock before modifying certain memebers? // TODO: DW: Shouldn't we lock before modifying certain memebers?
// Because redraw code might use an updated value instead of one for witch // Redraw code might use an updated value instead of one for which
// it was called. e.g.: different lineCap or lineJoin. Strange result // it was called. e.g.: different lineCap or lineJoin. Strange results
// would appear. // would appear.
fSession->ReadInt8(&lineCap); fSession->ReadInt8(&lineCap);
@@ -1045,7 +1103,8 @@ void ServerWindow::DispatchMessage(int32 code)
} }
case AS_LAYER_POP_STATE: case AS_LAYER_POP_STATE:
{ {
if (!(cl->_layerdata->prevState)) { if (!(cl->_layerdata->prevState))
{
STRACE(("WARNING: SW(%s): User called BView(%s)::PopState(), but there is NO state on stack!\n", fTitle.String(), cl->_name->String())); STRACE(("WARNING: SW(%s): User called BView(%s)::PopState(), but there is NO state on stack!\n", fTitle.String(), cl->_name->String()));
break; break;
} }
@@ -1229,7 +1288,8 @@ void ServerWindow::DispatchMessage(int32 code)
// if we had a picture to clip to, include the FULL visible region(if any) in the area to be redrawn // if we had a picture to clip to, include the FULL visible region(if any) in the area to be redrawn
// in other words: invalidate what ever is visible for this layer and his children. // in other words: invalidate what ever is visible for this layer and his children.
if (cl->clipToPicture && cl->_fullVisible.CountRects() > 0){ if (cl->clipToPicture && cl->_fullVisible.CountRects() > 0)
{
reg.Include(&cl->_fullVisible); reg.Include(&cl->_fullVisible);
redraw = true; redraw = true;
} }
@@ -1243,42 +1303,46 @@ void ServerWindow::DispatchMessage(int32 code)
if (!sp) if (!sp)
break; break;
if(sp->GetToken() == pictureToken){ if(sp->GetToken() == pictureToken)
{
//cl->clipToPicture = sp; //cl->clipToPicture = sp;
// TODO: increase that picture's reference count.(~ allocate a picture) // TODO: increase that picture's reference count.(~ allocate a picture)
break; break;
} }
} }
// avoid compiler warning // avoid compiler warning
i = 0; i = 0;
// we have a new picture to clip to, so rebuild our full region // we have a new picture to clip to, so rebuild our full region
if(cl->clipToPicture) { if(cl->clipToPicture)
{
cl->clipToPictureInverse = false; cl->clipToPictureInverse = false;
cl->RebuildFullRegion(); cl->RebuildFullRegion();
} }
// we need to rebuild the visible region, we may have a valid one. // we need to rebuild the visible region, we may have a valid one.
if (cl->_parent && !(cl->_hidden)){ if (cl->_parent && !(cl->_hidden))
{
//cl->_parent->RebuildChildRegions(cl->_full.Frame(), cl); //cl->_parent->RebuildChildRegions(cl->_full.Frame(), cl);
} }
else{ else
{
// will this happen? Maybe... // will this happen? Maybe...
//cl->RebuildRegions(cl->_full.Frame()); //cl->RebuildRegions(cl->_full.Frame());
} }
// include our full visible region in the region to be redrawn // include our full visible region in the region to be redrawn
if (!(cl->_hidden) && (cl->_fullVisible.CountRects() > 0)){ if (!(cl->_hidden) && (cl->_fullVisible.CountRects() > 0))
{
reg.Include(&(cl->_fullVisible)); reg.Include(&(cl->_fullVisible));
redraw = true; redraw = true;
} }
// redraw if: we had OR if we NOW have a picture to clip to. // redraw if we previously had or if we have acquired a picture to clip to.
if (redraw){ if (redraw)
cl->Invalidate(reg); cl->Invalidate(reg);
}
STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -1301,8 +1365,10 @@ void ServerWindow::DispatchMessage(int32 code)
if (!sp) if (!sp)
break; break;
if(sp->GetToken() == pictureToken){ if(sp->GetToken() == pictureToken)
{
//cl->clipToPicture = sp; //cl->clipToPicture = sp;
// TODO: increase that picture's reference count.(~ allocate a picture) // TODO: increase that picture's reference count.(~ allocate a picture)
break; break;
} }
@@ -1311,16 +1377,15 @@ void ServerWindow::DispatchMessage(int32 code)
i = 0; i = 0;
// if a picture has been found... // if a picture has been found...
if(cl->clipToPicture) { if(cl->clipToPicture)
{
cl->clipToPictureInverse = true; cl->clipToPictureInverse = true;
cl->RebuildFullRegion(); cl->RebuildFullRegion();
//cl->RequestDraw(cl->clipToPicture->Frame()); //cl->RequestDraw(cl->clipToPicture->Frame());
} }
STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",fTitle.String(),
cl->_name->String()));
break; break;
} }
case AS_LAYER_GET_CLIP_REGION: case AS_LAYER_GET_CLIP_REGION:
@@ -1337,15 +1402,16 @@ void ServerWindow::DispatchMessage(int32 code)
reg.IntersectWith(ld->clipReg); reg.IntersectWith(ld->clipReg);
while((ld = ld->prevState)) while((ld = ld->prevState))
{
if(ld->clipReg) if(ld->clipReg)
reg.IntersectWith(ld->clipReg); reg.IntersectWith(ld->clipReg);
}
noOfRects = reg.CountRects(); noOfRects = reg.CountRects();
fSession->WriteInt32(noOfRects); fSession->WriteInt32(noOfRects);
for(int i = 0; i < noOfRects; i++){ for(int i = 0; i < noOfRects; i++)
fSession->WriteRect(reg.RectAt(i)); fSession->WriteRect(reg.RectAt(i));
}
fSession->Sync(); fSession->Sync();
@@ -1365,19 +1431,18 @@ void ServerWindow::DispatchMessage(int32 code)
fSession->ReadInt32(&noOfRects); fSession->ReadInt32(&noOfRects);
for(int i = 0; i < noOfRects; i++){ for(int i = 0; i < noOfRects; i++)
{
fSession->ReadRect(&r); fSession->ReadRect(&r);
cl->_layerdata->clipReg->Include(r); cl->_layerdata->clipReg->Include(r);
} }
cl->RebuildFullRegion(); cl->RebuildFullRegion();
// cl->RequestDraw(cl->clipToPicture->Frame()); // cl->RequestDraw(cl->clipToPicture->Frame());
STRACE(("ServerWindow %s: Message AS_LAYER_SET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_INVAL_RECT: case AS_LAYER_INVAL_RECT:
{ {
// TODO: watch out for the coordinate system // TODO: watch out for the coordinate system
@@ -1386,7 +1451,6 @@ void ServerWindow::DispatchMessage(int32 code)
fSession->ReadRect(&invalRect); fSession->ReadRect(&invalRect);
cl->Invalidate(invalRect); cl->Invalidate(invalRect);
//cl->RequestDraw(invalRect); //cl->RequestDraw(invalRect);
STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->_name->String()));
@@ -1401,30 +1465,28 @@ void ServerWindow::DispatchMessage(int32 code)
fSession->ReadInt32(&noOfRects); fSession->ReadInt32(&noOfRects);
for(int i = 0; i < noOfRects; i++){ for(int i = 0; i < noOfRects; i++)
{
fSession->ReadRect(&rect); fSession->ReadRect(&rect);
invalReg.Include(rect); invalReg.Include(rect);
} }
cl->Invalidate(invalReg); cl->Invalidate(invalReg);
// cl->RequestDraw(invalReg.Frame()); // cl->RequestDraw(invalReg.Frame());
STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
// ********** END: BView Messages ***********
/********** END: BView Messages ***********/ // ********* BWindow Messages ***********
/********** BWindow Messages ***********/
case AS_LAYER_DELETE_ROOT: case AS_LAYER_DELETE_ROOT:
{ {
// Received when a window deletes its internal top view // Received when a window deletes its internal top view
// TODO: Implement // TODO: Implement
STRACE(("ServerWindow %s: Message Delete_Layer_Root unimplemented\n",fTitle.String())); STRACE(("ServerWindow %s: Message Delete_Layer_Root unimplemented\n",fTitle.String()));
break; break;
} }
case AS_SHOW_WINDOW: case AS_SHOW_WINDOW:
@@ -1479,13 +1541,15 @@ void ServerWindow::DispatchMessage(int32 code)
fSession->ReadData(&teamID, sizeof(team_id)); fSession->ReadData(&teamID, sizeof(team_id));
wb = desktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID); wb = desktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID);
if(wb){ if(wb)
{
fSession->WriteInt32(SERVER_TRUE); fSession->WriteInt32(SERVER_TRUE);
fSession->Sync(); fSession->Sync();
fWinBorder->AddToSubsetOf(wb); fWinBorder->AddToSubsetOf(wb);
} }
else{ else
{
fSession->WriteInt32(SERVER_FALSE); fSession->WriteInt32(SERVER_FALSE);
fSession->Sync(); fSession->Sync();
} }
@@ -1501,13 +1565,15 @@ void ServerWindow::DispatchMessage(int32 code)
fSession->ReadData(&teamID, sizeof(team_id)); fSession->ReadData(&teamID, sizeof(team_id));
wb = desktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID); wb = desktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID);
if(wb){ if(wb)
{
fSession->WriteInt32(SERVER_TRUE); fSession->WriteInt32(SERVER_TRUE);
fSession->Sync(); fSession->Sync();
fWinBorder->RemoveFromSubsetOf(wb); fWinBorder->RemoveFromSubsetOf(wb);
} }
else{ else
{
fSession->WriteInt32(SERVER_FALSE); fSession->WriteInt32(SERVER_FALSE);
fSession->Sync(); fSession->Sync();
} }
@@ -1628,8 +1694,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer)
return; return;
// TODO: fix! // TODO: fix!
/* /* WindowClipRegion.Set(fWinBorder->Frame());
WindowClipRegion.Set(fWinBorder->Frame());
sibling = fWinBorder->UpperSibling(); sibling = fWinBorder->UpperSibling();
while (sibling) while (sibling)
{ {
@@ -1647,8 +1712,10 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer)
{ {
code = read_from_buffer<int32>(&msgbuffer); code = read_from_buffer<int32>(&msgbuffer);
view_token = read_from_buffer<int32>(&msgbuffer); view_token = read_from_buffer<int32>(&msgbuffer);
//TODO: fix! //TODO: fix!
layer = NULL;//fWorkspace->GetRoot()->FindLayer(view_token); layer = NULL;//fWorkspace->GetRoot()->FindLayer(view_token);
if (layer) if (layer)
{ {
// TODO: fix! // TODO: fix!
@@ -1662,6 +1729,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer)
layerdata = NULL; layerdata = NULL;
STRACE(("ServerWindow %s received invalid view token %lx",fTitle.String(),view_token)); STRACE(("ServerWindow %s received invalid view token %lx",fTitle.String(),view_token));
} }
switch (code) switch (code)
{ {
case AS_SET_HIGH_COLOR: case AS_SET_HIGH_COLOR:
@@ -2046,7 +2114,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer)
} }
case AS_FILL_ROUNDRECT: case AS_FILL_ROUNDRECT:
{ {
// TODO:: Add clipping // TODO: Add clipping
if (sizeRemaining >= AS_FILL_ROUNDRECT_MSG_SIZE) if (sizeRemaining >= AS_FILL_ROUNDRECT_MSG_SIZE)
{ {
float left, top, right, bottom, xrad, yrad; float left, top, right, bottom, xrad, yrad;
@@ -2189,7 +2257,6 @@ int32 ServerWindow::MonitorWin(void *data)
} }
default: default:
{ {
//STRACE(("ServerWindow %s: got a message to dispatch\n",win->Title()));
win->DispatchMessage(code); win->DispatchMessage(code);
break; break;
} }
@@ -2198,170 +2265,6 @@ int32 ServerWindow::MonitorWin(void *data)
return 0; return 0;
} }
/*!
\brief PasfSession mouse event messages to the appropriate window
\param code Message code of the mouse message
\param buffer Attachment buffer for the mouse message
*/
//void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
void ServerWindow::HandleMouseEvent(PortMessage *msg)
{
/* ServerWindow *mousewin=NULL;
// int8 *index=buffer;
// Find the window which will receive our mouse event.
//TODO: resolve
Layer *root=NULL;//GetRootLayer(CurrentWorkspace(),ActiveScreen());
WinBorder *fWinBorder;
// activeborder is used to remember windows when resizing/moving windows
// or sliding a tab
if(!root)
{
printf("ERROR: HandleMouseEvent has NULL root layer!!!\n");
return;
}
// Dispatch the mouse event to the proper window
// switch(code)
switch(msg->Code())
{
case B_MOUSE_DOWN:
{
// Attached data:
// 1) int64 - time of mouse click
// 2) float - x coordinate of mouse click
// 3) float - y coordinate of mouse click
// 4) int32 - modifier keys down
// 5) int32 - buttons down
// 6) int32 - clicks
// index+=sizeof(int64);
// float x=*((float*)index); index+=sizeof(float);
// float y=*((float*)index); index+=sizeof(float);
// BPoint pt(x,y);
float x;
float y;
int64 dummy;
msg->Read<int64>(&dummy);
msg->Read<float>(&x);
msg->Read<float>(&y);
//TODO: resolve
// BPoint pt(x,y);
// If we have clicked on a window,
active_winborder = fWinBorder = NULL;
if(fWinBorder)
{
mousewin=fWinBorder->Window();
fWinBorder->MouseDown((int8*)msg->Buffer());
}
break;
}
case B_MOUSE_UP:
{
// Attached data:
// 1) int64 - time of mouse click
// 2) float - x coordinate of mouse click
// 3) float - y coordinate of mouse click
// 4) int32 - modifier keys down
// index+=sizeof(int64);
// float x=*((float*)index); index+=sizeof(float);
// float y=*((float*)index); index+=sizeof(float);
// BPoint pt(x,y);
float x;
float y;
int64 dummy;
msg->Read(&dummy);
msg->Read(&x);
msg->Read(&y);
//TODO: resolve
// BPoint pt(x,y);
// set_is_sliding_tab(false);
// set_is_moving_window(false);
// set_is_resizing_window(false);
//TODO: resolve
fWinBorder = NULL;//WindowContainsPoint(pt);
active_winborder=NULL;
if(fWinBorder)
{
mousewin=fWinBorder->Window();
// Eventually, we will build in MouseUp messages with buttons specified
// For now, we just "assume" no mouse specification with a 0.
fWinBorder->MouseUp((int8*)msg->Buffer());
}
break;
}
case B_MOUSE_MOVED:
{
// Attached data:
// 1) int64 - time of mouse click
// 2) float - x coordinate of mouse click
// 3) float - y coordinate of mouse click
// 4) int32 - buttons down
// index+=sizeof(int64);
// float x=*((float*)index); index+=sizeof(float);
// float y=*((float*)index); index+=sizeof(float);
// BPoint pt(x,y);
float x;
float y;
int64 dummy;
msg->Read(&dummy);
msg->Read(&x);
msg->Read(&y);
// BPoint pt(x,y);
//
// if(is_moving_window() || is_resizing_window() || is_sliding_tab())
// {
// active_winborder->MouseMoved((int8*)msg->Buffer());
// }
// else
// {
// fWinBorder = WindowContainsPoint(pt);
// if(fWinBorder)
// {
// mousewin=fWinBorder->Window();
// fWinBorder->MouseMoved((int8*)msg->Buffer());
// }
// }
break;
}
default:
{
break;
}
}
*/
}
/*!
\brief PasfSession key event messages to the appropriate window
\param code Message code of the key message
\param buffer Attachment buffer for the key message
*/
void ServerWindow::HandleKeyEvent(int32 code, int8 *buffer)
{
/*
STRACE_KEY(("ServerWindow::HandleKeyEvent unimplemented\n"));
ServerWindow *keywin=NULL;
// Dispatch the key event to the active window
keywin=GetActiveWindow();
if(keywin)
{
keywin->Lock();
keywin->fWinLink->SetOpCode(code);
keywin->fWinLink
keywin->Unlock();
}
*/
}
/*! /*!
\brief Send a message to the ServerWindow \brief Send a message to the ServerWindow
\param code ID code of the message to post \param code ID code of the message to post
+23 -43
View File
@@ -65,17 +65,9 @@ class Layer;
class ServerWindow class ServerWindow
{ {
public: public:
ServerWindow( BRect rect, ServerWindow(BRect rect, const char *string, uint32 wlook, uint32 wfeel, uint32 wflags,
const char *string, ServerApp *winapp, port_id winport, port_id looperPort, port_id replyport,
uint32 wlook, uint32 index,int32 handlerID);
uint32 wfeel,
uint32 wflags,
ServerApp *winapp,
port_id winport,
port_id looperPort,
port_id replyport,
uint32 index,
int32 handlerID);
virtual ~ServerWindow(void); virtual ~ServerWindow(void);
void Init(); void Init();
@@ -103,25 +95,20 @@ public:
status_t Lock(void); status_t Lock(void);
void Unlock(void); void Unlock(void);
bool IsLocked(void); bool IsLocked(void);
thread_id ThreadID(void) const thread_id ThreadID(void) const { return fMonitorThreadID;}
{ return fMonitorThreadID;}
void DispatchMessage(int32 code); void DispatchMessage(int32 code);
void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer); void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer);
static int32 MonitorWin(void *data); static int32 MonitorWin(void *data);
static void HandleMouseEvent(PortMessage *msg);
static void HandleKeyEvent(int32 code, int8 *buffer);
void PostMessage(int32 code, size_t size=0, int8 *buffer=NULL); void PostMessage(int32 code, size_t size=0, int8 *buffer=NULL);
//! Returns the index of the workspaces to which it belongs //! Returns the index of the workspaces to which it belongs
int32 GetWorkspaceIndex(void) int32 GetWorkspaceIndex(void) { return fWorkspaces; }
{ return fWorkspaces; }
Workspace *GetWorkspace(void); Workspace *GetWorkspace(void);
void SetWorkspace(Workspace *wkspc); void SetWorkspace(Workspace *wkspc);
//! Returns the window's title //! Returns the window's title
const char* Title(void) const char *Title(void) { return fTitle.String(); }
{ return fTitle.String(); }
Layer *CreateLayerTree(Layer *localRoot); Layer *CreateLayerTree(Layer *localRoot);
void SetLayerState(Layer *layer); void SetLayerState(Layer *layer);
@@ -130,30 +117,21 @@ public:
Layer *FindLayer(const Layer *start, int32 token) const; Layer *FindLayer(const Layer *start, int32 token) const;
void SendMessageToClient( const BMessage *msg ) const; void SendMessageToClient( const BMessage *msg ) const;
int32 Look(void) const int32 Look(void) const { return fLook; }
{ return fLook; } int32 Feel(void) const { return fFeel; }
int32 Feel(void) const uint32 Flags(void) const { return fFlags; }
{ return fFeel; } team_id ClientTeamID(void) const { return fClientTeamID; }
uint32 Flags(void) const ServerApp *App(void) const { return fServerApp; }
{ return fFlags; } uint32 Workspaces(void) const { return fWorkspaces; }
team_id ClientTeamID(void) const WinBorder *GetWinBorder(void) const { return fWinBorder; }
{ return fClientTeamID; }
ServerApp* App(void) const
{ return fServerApp; }
uint32 Workspaces(void) const
{ return fWorkspaces; }
WinBorder* GetWinBorder(void) const
{ return fWinBorder; }
// server "private" - try not to use // server "private" - try not to use
void QuietlySetWorkspaces(uint32 wks) void QuietlySetWorkspaces(uint32 wks) { fWorkspaces = wks; }
{ fWorkspaces = wks; } void QuietlySetFeel(int32 feel) { fFeel = feel; }
void QuietlySetFeel(int32 feel) int32 ClientToken(void) const { return fHandlerToken; }
{ fFeel = feel; }
int32 ClientToken(void) const
{ return fHandlerToken; }
FMWList fWinFMWList; FMWList fWinFMWList;
protected: protected:
friend class ServerApp; friend class ServerApp;
friend class WinBorder; friend class WinBorder;
@@ -161,9 +139,9 @@ protected:
friend class Layer; friend class Layer;
BString fTitle; BString fTitle;
int32 fLook, int32 fLook;
fFeel, int32 fFeel;
fFlags; int32 fFlags;
uint32 fWorkspaces; uint32 fWorkspaces;
Workspace *fWorkspace; Workspace *fWorkspace;
bool fIsActive; bool fIsActive;
@@ -185,7 +163,9 @@ protected:
BSession *fSession; BSession *fSession;
Layer *fTopLayer; Layer *fTopLayer;
Layer* cl; // short for currentLayer. We'll use it a lot, that's why it's short :-)
// cl is short for currentLayer. We'll use it a lot, that's why it's short :-)
Layer *cl;
}; };
#endif #endif