ServerWindow is no more a ServerApp's friend. Some cleanups.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12663 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2005-05-14 13:22:26 +00:00
parent d5b04e50f8
commit cb80e15b3c
3 changed files with 53 additions and 46 deletions

View File

@ -1956,6 +1956,14 @@ ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
}
}
int32
ServerApp::CountBitmaps() const
{
return fBitmapList ? fBitmapList->CountItems() : 0;
}
/*!
\brief Looks up a ServerApp's ServerBitmap in its list
\param token ID token of the bitmap to find
@ -1975,6 +1983,27 @@ ServerApp::FindBitmap(int32 token) const
}
int32
ServerApp::CountPictures() const
{
return fPictureList ? fPictureList->CountItems() : 0;
}
ServerPicture *
ServerApp::FindPicture(int32 token) const
{
ServerPicture *picture;
for (int32 i = 0; i < fPictureList->CountItems(); i++) {
picture = static_cast<ServerPicture *>(fPictureList->ItemAt(i));
if (picture && picture->GetToken() == token)
return picture;
}
return NULL;
}
team_id
ServerApp::ClientTeamID() const
{

View File

@ -40,6 +40,7 @@ class BList;
class DisplayDriver;
class LinkMsgReader;
class LinkMsgSender;
class ServerPicture;
class ServerCursor;
class ServerBitmap;
@ -74,18 +75,22 @@ public:
void SetAppCursor(void);
ServerBitmap *FindBitmap(int32 token) const;
team_id ClientTeamID() const;
thread_id MonitorThreadID() const;
const char *Title() const { return fSignature.String(); }
int32 CountBitmaps() const;
ServerBitmap *FindBitmap(int32 token) const;
int32 CountPictures() const;
ServerPicture *FindPicture(int32 token) const;
AreaPool *AppAreaPool() { return fSharedMem; }
FMWList fAppFMWList;
const char *Title() const { return fSignature.String(); }
private:
friend class ServerWindow;
void DispatchMessage(int32 code, LinkMsgReader &link);
static int32 MonitorApp(void *data);
@ -107,6 +112,9 @@ private:
LinkMsgReader *fMsgReader;
LinkMsgSender *fMsgSender;
// TODO:
// - Are really Bitmaps and Pictures stored per application and not globally ?
// - As we reference these stuff by token, what about putting them in hash tables ?
BList *fSWindowList,
*fBitmapList,
*fPictureList;

View File

@ -1039,25 +1039,10 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
}
// search for a picture with the specified token.
ServerPicture *sp = NULL;
int32 i = 0;
while(1)
{
sp=static_cast<ServerPicture*>(cl->fServerWin->fServerApp->fPictureList->ItemAt(i++));
if (!sp)
break;
if(sp->GetToken() == pictureToken)
{
//cl->clipToPicture = sp;
// TODO: Increase that picture's reference count.(~ allocate a picture)
break;
}
}
// avoid compiler warning
i = 0;
ServerPicture *sp = cl->fServerWin->fServerApp->FindPicture(pictureToken);
// TODO: Increase that picture's reference count.(~ allocate a picture)
if (sp == NULL)
break;
// we have a new picture to clip to, so rebuild our full region
if(cl->clipToPicture)
@ -1102,26 +1087,11 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
link.Read<int32>(&pictureToken);
link.Read<BPoint>(&where);
ServerPicture *sp = NULL;
int32 i = 0;
while(1)
{
sp= static_cast<ServerPicture*>(cl->fServerWin->fServerApp->fPictureList->ItemAt(i++));
if (!sp)
break;
if(sp->GetToken() == pictureToken)
{
//cl->clipToPicture = sp;
// TODO: Increase that picture's reference count.(~ allocate a picture)
break;
}
}
// avoid compiler warning
i = 0;
// TODO: Increase that picture's reference count.(~ allocate a picture)
ServerPicture *sp = cl->fServerWin->fServerApp->FindPicture(pictureToken);
if (sp == NULL)
break;
// if a picture has been found...
if(cl->clipToPicture)
{
@ -2023,7 +1993,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
// This is a very special case in the sense that when ServerMemIO is used for this
// purpose, it will be set to NOT automatically free the memory which it had
// requested. This is the server's job once the message has been dispatched.
fServerApp->fSharedMem->ReleaseBuffer(msgpointer);
fServerApp->AppAreaPool()->ReleaseBuffer(msgpointer);
break;
}