From 76d4213d606fe24b7c9fa365be49aa04634a306f Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Tue, 5 Oct 2004 23:00:47 +0000 Subject: [PATCH] Removed a couple of unnecessary includes (Hopefully) patched a crash under the BApplication Quit2 test Speedup for CursorManager::RemoveAppCursors git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9216 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/server/CursorManager.cpp | 9 ++----- src/servers/app/server/CursorManager.h | 2 +- src/servers/app/server/ServerApp.cpp | 31 +++++++++++++++++++++--- src/servers/app/server/ServerApp.h | 1 + src/servers/app/server/ServerCursor.cpp | 3 +++ src/servers/app/server/ServerWindow.cpp | 1 - src/servers/app/server/WinBorder.cpp | 1 - 7 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/servers/app/server/CursorManager.cpp b/src/servers/app/server/CursorManager.cpp index b3811e1271..19443f656f 100644 --- a/src/servers/app/server/CursorManager.cpp +++ b/src/servers/app/server/CursorManager.cpp @@ -153,23 +153,18 @@ void CursorManager::DeleteCursor(int32 token) \brief Removes and deletes all of an application's cursors \param signature Signature to which the cursors belong */ -void CursorManager::RemoveAppCursors(const char *signature) +void CursorManager::RemoveAppCursors(team_id team) { - // OPTIMIZATION: For an optimization, it perhaps may be wise down - // the road to replace the ServerCursor's app signature with a - // pointer to its application and compare ServerApp pointers instead. Lock(); ServerCursor *temp; for(int32 i=0; iCountItems();i++) { temp=(ServerCursor*)fCursorList->ItemAt(i); - if(temp && temp->GetAppSignature() && - strcmp(signature, temp->GetAppSignature())==0) + if(temp && temp->OwningTeam()==team) { fCursorList->RemoveItem(i); delete temp; - break; } } Unlock(); diff --git a/src/servers/app/server/CursorManager.h b/src/servers/app/server/CursorManager.h index 0cab4a4cfb..e4ca248c49 100644 --- a/src/servers/app/server/CursorManager.h +++ b/src/servers/app/server/CursorManager.h @@ -50,7 +50,7 @@ public: ~CursorManager(void); int32 AddCursor(ServerCursor *sc); void DeleteCursor(int32 token); - void RemoveAppCursors(const char *signature); + void RemoveAppCursors(team_id team); void ShowCursor(void); void HideCursor(void); void ObscureCursor(void); diff --git a/src/servers/app/server/ServerApp.cpp b/src/servers/app/server/ServerApp.cpp index 3fdafcb9f5..ea7b1d05ac 100644 --- a/src/servers/app/server/ServerApp.cpp +++ b/src/servers/app/server/ServerApp.cpp @@ -98,10 +98,18 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort fBitmapList=new BList(0); fPictureList=new BList(0); fIsActive=false; + + char *dummy; + fSharedMem=create_area("rw_shared_area",(void**)&dummy,B_ANY_ADDRESS,4096,B_NO_LOCK, + B_READ_AREA|B_WRITE_AREA); + + if(fSharedMem<0) + printf("PANIC: Couldn't create shared app_server area!\n"); ServerCursor *defaultc=cursormanager->GetCursor(B_CURSOR_DEFAULT); fAppCursor=(defaultc)?new ServerCursor(defaultc):NULL; + fAppCursor->SetOwningTeam(fClientTeamID); fLockSem=create_sem(1,"ServerApp sem"); // Does this even belong here any more? --DW @@ -148,7 +156,7 @@ ServerApp::~ServerApp(void) delete fAppCursor; - cursormanager->RemoveAppCursors(fSignature.String()); + cursormanager->RemoveAppCursors(fClientTeamID); delete_sem(fLockSem); STRACE(("#ServerApp %s:~ServerApp()\n",fSignature.String())); @@ -157,6 +165,7 @@ ServerApp::~ServerApp(void) thread_info info; if(get_thread_info(fMonitorThreadID,&info)==B_OK) kill_thread(fMonitorThreadID); + delete_area(fSharedMem); } /*! @@ -367,7 +376,7 @@ void ServerApp::_DispatchMessage(int32 code, BPortLink& msg) } case AS_UPDATE_COLORS: { - // Eventually we will have windows which will notify their children of changes in + // NOTE: R2: Eventually we will have windows which will notify their children of changes in // system colors /* STRACE(("ServerApp %s: Received global UI color update notification\n",fSignature.String())); @@ -386,7 +395,7 @@ void ServerApp::_DispatchMessage(int32 code, BPortLink& msg) } case AS_UPDATE_FONTS: { - // Eventually we will have windows which will notify their children of changes in + // NOTE: R2: Eventually we will have windows which will notify their children of changes in // system fonts /* STRACE(("ServerApp %s: Received global font update notification\n",fSignature.String())); @@ -403,6 +412,20 @@ void ServerApp::_DispatchMessage(int32 code, BPortLink& msg) } */ break; } + case AS_ACQUIRE_SERVERMEM: + { + // Received from a ServerMemIO object requesting operating memory + // Attached Data: + // 1) size_t requested size + + // TODO: Implement AS_ACQUIRE_SERVERMEM + break; + } + case AS_RELEASE_SERVERMEM: + { + // TODO: Implement AS_RELEASE_SERVERMEM + break; + } case AS_UPDATE_DECORATOR: { STRACE(("ServerApp %s: Received decorator update notification\n",fSignature.String())); @@ -683,6 +706,7 @@ void ServerApp::_DispatchMessage(int32 code, BPortLink& msg) cursormanager->DeleteCursor(fAppCursor->ID()); fAppCursor=new ServerCursor(cdata); + fAppCursor->SetOwningTeam(fClientTeamID); fAppCursor->SetAppSignature(fSignature.String()); cursormanager->AddCursor(fAppCursor); cursormanager->SetCursor(fAppCursor->ID()); @@ -730,6 +754,7 @@ void ServerApp::_DispatchMessage(int32 code, BPortLink& msg) msg.Read(&replyport); fAppCursor=new ServerCursor(cdata); + fAppCursor->SetOwningTeam(fClientTeamID); fAppCursor->SetAppSignature(fSignature.String()); cursormanager->AddCursor(fAppCursor); diff --git a/src/servers/app/server/ServerApp.h b/src/servers/app/server/ServerApp.h index c6f6b637db..3b4aaefd02 100644 --- a/src/servers/app/server/ServerApp.h +++ b/src/servers/app/server/ServerApp.h @@ -103,6 +103,7 @@ protected: bool fCursorHidden; bool fIsActive; int32 fHandlerToken; + area_id fSharedMem; }; #endif diff --git a/src/servers/app/server/ServerCursor.cpp b/src/servers/app/server/ServerCursor.cpp index cbb779e786..bbcdd74e96 100644 --- a/src/servers/app/server/ServerCursor.cpp +++ b/src/servers/app/server/ServerCursor.cpp @@ -40,6 +40,7 @@ ServerCursor::ServerCursor(BRect r, color_space cspace, int32 flags, BPoint hots { fHotSpot=hotspot; fHotSpot.ConstrainTo(Bounds()); + fOwningTeam=-1; _AllocateBuffer(); } @@ -59,6 +60,7 @@ ServerCursor::ServerCursor(int8 *data) if(data) { fInitialized=true; + fOwningTeam=-1; uint32 black=0xFF000000, white=0xFFFFFFFF, *bmppos; @@ -113,6 +115,7 @@ ServerCursor::ServerCursor(const ServerCursor *cursor) { _AllocateBuffer(); fInitialized=true; + fOwningTeam=-1; if(cursor) { diff --git a/src/servers/app/server/ServerWindow.cpp b/src/servers/app/server/ServerWindow.cpp index 6bcc6f38f4..20e25dd85b 100644 --- a/src/servers/app/server/ServerWindow.cpp +++ b/src/servers/app/server/ServerWindow.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include "Desktop.h" #include "AppServer.h" #include "Layer.h" diff --git a/src/servers/app/server/WinBorder.cpp b/src/servers/app/server/WinBorder.cpp index d120790679..cf11ec2569 100644 --- a/src/servers/app/server/WinBorder.cpp +++ b/src/servers/app/server/WinBorder.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include "PortLink.h" #include "View.h" // for mouse button defines #include "ServerWindow.h"