modified the way BView data is received.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7149 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca 2004-04-03 15:05:49 +00:00
parent 9d5fb2696a
commit 3350f57dd7
2 changed files with 124 additions and 108 deletions

View File

@ -21,6 +21,7 @@
//
// File Name: ServerWindow.cpp
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Adi Oanca <adioanca@mymail.ro>
// Description: Shadow BWindow class
//
//------------------------------------------------------------------------------
@ -152,35 +153,28 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
winLink.Attach<port_id>(fMessagePort);
winLink.Flush();
// Wait for top_view data and create ServerWindow's top most Layer
int32 vCode;
int32 vToken;
BRect vFrame;
uint32 vResizeMode;
uint32 vFlags;
char* vName = NULL;
// check the next 2 messages to make sure we receive top_view's attributes.
fSession->ReadInt32(&vCode);
if(vCode != AS_LAYER_CREATE_ROOT)
debugger("SERVER ERROR: ServerWindow(xxx): NO top_view data received!\n");
fSession->ReadInt32(&vToken);
fSession->ReadRect(&vFrame);
fSession->ReadUInt32(&vResizeMode);
fSession->ReadUInt32(&vFlags);
vName = fSession->ReadString();
debugger("SERVER ERROR: ServerWindow(xxx): NO top_view data received! - 1\n");
// Create the top layer.
fTopLayer = new Layer(vFrame, vName, vToken, vResizeMode, vFlags, desktop->GetDisplayDriver());
fSession->ReadInt32(&vCode);
if(vCode != AS_LAYER_CREATE)
debugger("SERVER ERROR: ServerWindow(xxx): NO top_view data received! - 2\n");
// start receiving top_view data. pass NULL as the parent view.
// This should be the *only* place where this happens.
fTopLayer = CreateLayerTree(NULL);
fTopLayer->SetAsTopLayer(true);
cl = fTopLayer;
// Create a WindoBorder object for our ServerWindow.
fWinBorder = new WinBorder( fFrame, fTitle.String(),
wlook, wfeel, wflags,
this, desktop->GetDisplayDriver());
delete vName;
cl = fTopLayer;
STRACE(("ServerWindow %s:\n",fTitle.String()));
STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom));
STRACE(("\tPort: %ld\n",fMessagePort));
@ -268,6 +262,7 @@ STRACE(("ServerWindow %s: Quit\n",fTitle.String()));
//! Shows the window's WinBorder
void ServerWindow::Show(void)
{
// whaaat?
if(!fWinBorder->IsHidden())
return;
@ -310,6 +305,8 @@ void ServerWindow::Show(void)
desktop->fGeneralLock.Unlock();
STRACE(("ServerWindow(%s)::Show() - General lock released\n", fWinBorder->GetName()));
}
snooze(1000000);
fWinBorder->MoveBy(100,100);
}
//! Hides the window's WinBorder
@ -549,7 +546,7 @@ void ServerWindow::SetLayerFontState(Layer *layer){
// in ServerFont class. DW, could you add one?
//layer->_layerdata->font->
}
if (mask & B_FONT_SIZE){
float size;
fSession->ReadFloat(&size);
@ -591,7 +588,7 @@ void ServerWindow::SetLayerFontState(Layer *layer){
fSession->ReadUInt32(&flags); // uint32
layer->_layerdata->font.SetFlags(flags);
}
STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer: %s\n",fTitle.String(), cl->_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){
@ -642,13 +639,11 @@ void ServerWindow::SetLayerState(Layer *layer){
layer->_layerdata->clippReg = NULL;
}
}
STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_STATE: Layer: %s\n",fTitle.String(), cl->_name->String()));
STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_STATE: Layer: %s\n",fTitle.String(), layer->_name->String()));
}
void ServerWindow::CreateLayerTree(Layer *localRoot){
Layer* ServerWindow::CreateLayerTree(Layer *localRoot){
STRACE(("ServerWindow(%s)::CreateLayerTree()\n", fTitle.String()));
if(!localRoot)
debugger("ServerWindow(%s)::CreateLayerTree() - NO localRoot Layer specified!\n");
int32 token;
BRect frame;
@ -684,13 +679,14 @@ STRACE(("ServerWindow(%s)::CreateLayerTree()\n", fTitle.String()));
//lastly, the BView's graphic state
fSession->ReadInt32(&dummyMsg);
if (dummyMsg == AS_LAYER_SET_FONT_STATE)
if (dummyMsg == AS_LAYER_SET_STATE)
SetLayerState(newLayer);
else
debugger("ServerWindow(%s) - AS_LAYER_SET_STATE Expected!\n");
// add the new Layer to the tree structure.
localRoot->AddChild(newLayer);
if (localRoot)
localRoot->AddChild(newLayer);
// attach newLayer's children...
for(int i = 0; i < childCount; i++)
@ -701,7 +697,8 @@ STRACE(("ServerWindow(%s)::CreateLayerTree()\n", fTitle.String()));
else
debugger("ServerWindow(%s) - AS_LAYER_CREATE Expected!\n");
}
STRACE(("DONE: ServerWindow %s: Message AS_CREATE_LAYER: Parent: %s, Child: %s\n", fTitle.String(), cl->_name->String(), name));
STRACE(("DONE: ServerWindow %s: Message AS_CREATE_LAYER: Parent: %s, Child: %s\n", fTitle.String(), newLayer->_name->String(), name));
return newLayer;
}
void ServerWindow::DispatchMessage(int32 code)

View File

@ -65,108 +65,127 @@ class Layer;
class ServerWindow
{
public:
ServerWindow(BRect rect, const char *string, uint32 wlook, uint32 wfeel, uint32 wflags,
ServerApp *winapp, port_id winport, port_id looperPort, port_id replyport,
uint32 index, int32 handlerID);
~ServerWindow(void);
ServerWindow( BRect rect,
const char *string,
uint32 wlook,
uint32 wfeel,
uint32 wflags,
ServerApp *winapp,
port_id winport,
port_id looperPort,
port_id replyport,
uint32 index,
int32 handlerID);
virtual ~ServerWindow(void);
void Init();
void Init();
void ReplaceDecorator(void);
void Quit(void);
void Show(void);
void Hide(void);
bool IsHidden(void);
void Minimize(bool status);
void Zoom(void);
void SetFocus(bool value);
bool HasFocus(void);
void RequestDraw(BRect rect);
void RequestDraw(void);
void ReplaceDecorator(void);
void Quit(void);
void Show(void);
void Hide(void);
bool IsHidden(void);
void Minimize(bool status);
void Zoom(void);
void SetFocus(bool value);
bool HasFocus(void);
void RequestDraw(BRect rect);
void RequestDraw(void);
void WorkspaceActivated(int32 workspace, bool active);
void WorkspacesChanged(int32 oldone,int32 newone);
void WindowActivated(bool active);
void ScreenModeChanged(const BRect frame, const color_space cspace);
void WorkspaceActivated(int32 workspace, bool active);
void WorkspacesChanged(int32 oldone,int32 newone);
void WindowActivated(bool active);
void ScreenModeChanged(const BRect frame, const color_space cspace);
void SetFrame(const BRect &rect);
BRect Frame(void);
void SetFrame(const BRect &rect);
BRect Frame(void);
status_t Lock(void);
void Unlock(void);
bool IsLocked(void);
thread_id ThreadID(void) const { return fMonitorThreadID;}
status_t Lock(void);
void Unlock(void);
bool IsLocked(void);
thread_id ThreadID(void) const
{ return fMonitorThreadID;}
void DispatchMessage(int32 code);
void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer);
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 DispatchMessage(int32 code);
void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer);
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);
//! Returns the index of the workspaces to which it belongs
int32 GetWorkspaceIndex(void) { return fWorkspaces; }
Workspace *GetWorkspace(void);
void SetWorkspace(Workspace *wkspc);
//! Returns the index of the workspaces to which it belongs
int32 GetWorkspaceIndex(void)
{ return fWorkspaces; }
Workspace* GetWorkspace(void);
void SetWorkspace(Workspace *wkspc);
//! Returns the window's title
const char *Title(void) { return fTitle.String(); }
//! Returns the window's title
const char* Title(void)
{ return fTitle.String(); }
void CreateLayerTree(Layer *localRoot);
void SetLayerState(Layer *layer);
void SetLayerFontState(Layer *layer);
Layer* CreateLayerTree(Layer *localRoot);
void SetLayerState(Layer *layer);
void SetLayerFontState(Layer *layer);
Layer* FindLayer(const Layer* start, int32 token) const;
void SendMessageToClient( const BMessage* msg ) const;
Layer* FindLayer(const Layer* start, int32 token) const;
void SendMessageToClient( const BMessage* msg ) const;
int32 Look(void) const { return fLook; }
int32 Feel(void) const { return fFeel; }
uint32 Flags(void) const { return fFlags; }
team_id ClientTeamID(void) const { return fClientTeamID; }
ServerApp *App(void) const { return fServerApp; }
uint32 Workspaces(void) const { return fWorkspaces; }
WinBorder *GetWinBorder(void) const { return fWinBorder; }
int32 Look(void) const
{ return fLook; }
int32 Feel(void) const
{ return fFeel; }
uint32 Flags(void) const
{ return fFlags; }
team_id ClientTeamID(void) const
{ 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
void QuietlySetWorkspaces(uint32 wks) { fWorkspaces = wks; }
void QuietlySetFeel(int32 feel) { fFeel = feel; }
int32 ClientToken(void) const { return fHandlerToken; }
// server "private" - try not to use
void QuietlySetWorkspaces(uint32 wks)
{ fWorkspaces = wks; }
void QuietlySetFeel(int32 feel)
{ fFeel = feel; }
int32 ClientToken(void) const
{ return fHandlerToken; }
FMWList fWinFMWList;
FMWList fWinFMWList;
protected:
friend class ServerApp;
friend class WinBorder;
friend class Screen;
friend class Layer;
friend class ServerApp;
friend class WinBorder;
friend class Screen;
friend class Layer;
BString fTitle;
int32 fLook,
fFeel,
fFlags;
uint32 fWorkspaces;
Workspace *fWorkspace;
bool fIsActive;
BString fTitle;
int32 fLook,
fFeel,
fFlags;
uint32 fWorkspaces;
Workspace* fWorkspace;
bool fIsActive;
ServerApp *fServerApp;
WinBorder *fWinBorder;
ServerApp* fServerApp;
WinBorder* fWinBorder;
team_id fClientTeamID;
thread_id fMonitorThreadID;
team_id fClientTeamID;
thread_id fMonitorThreadID;
port_id fMessagePort;
port_id fClientWinPort;
port_id fClientLooperPort;
port_id fMessagePort;
port_id fClientWinPort;
port_id fClientLooperPort;
BLocker fLocker;
BRect fFrame;
uint32 fToken;
int32 fHandlerToken;
BLocker fLocker;
BRect fFrame;
uint32 fToken;
int32 fHandlerToken;
BSession *fSession;
Layer *fTopLayer;
Layer *cl; // short for currentLayer. We'll use it a lot, that's why it's short :-)
BSession* fSession;
Layer* fTopLayer;
Layer* cl; // short for currentLayer. We'll use it a lot, that's why it's short :-)
};
void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin);
#endif