2005-06-23 21:40:35 +04:00
|
|
|
/*
|
2006-02-02 23:19:29 +03:00
|
|
|
* Copyright 2001-2006, Haiku.
|
2005-06-23 21:40:35 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
* Adrian Oanca <adioanca@cotty.iren.ro>
|
|
|
|
* Stephan Aßmus <superstippi@gmx.de>
|
|
|
|
* Stefano Ceccherini (burton666@libero.it)
|
|
|
|
* Axel Dörfler, axeld@pinc-software.de
|
|
|
|
*/
|
2006-02-02 23:19:29 +03:00
|
|
|
#ifndef SERVER_APP_H
|
|
|
|
#define SERVER_APP_H
|
2003-01-24 17:36:15 +03:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
|
* Implemented a new client allocation method: instead of having all bitmaps of
all teams in serveral server areas, and instead of having to eventually clone
them all several times in BBitmap, we now have one or more areas per team,
and BBitmap will only clone areas once if needed. As a side effect, this
method should be magnitudes faster than the previous version.
* This method is also much more secure: instead of putting the allocation
maintenance structures into those everyone-read-write areas, they are now
separated, so that faulty applications cannot crash the app_server this
way anymore. This should fix bug #172.
* Freeing memory is not yet implemented though! (although all memory will
be freed upon app exit)
* There are now 3 different bitmap allocation strategies: per ClientMemoryAllocator
(ie. via ServerApp), per area (for overlays, not yet implemented), and using
malloc()/free() for server-only bitmaps.
* ServerBitmap now deletes its buffers itself.
* Cleaned up BBitmap and BApplication a bit.
* The test environment currently doesn't build anymore, will fix it next.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16826 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-18 16:43:26 +03:00
|
|
|
#include "ClientMemoryAllocator.h"
|
2005-07-23 22:30:48 +04:00
|
|
|
#include "MessageLooper.h"
|
2003-08-31 21:38:34 +04:00
|
|
|
|
2005-11-24 16:14:49 +03:00
|
|
|
#include <ObjectList.h>
|
|
|
|
#include <TokenSpace.h>
|
|
|
|
|
* Implemented a new client allocation method: instead of having all bitmaps of
all teams in serveral server areas, and instead of having to eventually clone
them all several times in BBitmap, we now have one or more areas per team,
and BBitmap will only clone areas once if needed. As a side effect, this
method should be magnitudes faster than the previous version.
* This method is also much more secure: instead of putting the allocation
maintenance structures into those everyone-read-write areas, they are now
separated, so that faulty applications cannot crash the app_server this
way anymore. This should fix bug #172.
* Freeing memory is not yet implemented though! (although all memory will
be freed upon app exit)
* There are now 3 different bitmap allocation strategies: per ClientMemoryAllocator
(ie. via ServerApp), per area (for overlays, not yet implemented), and using
malloc()/free() for server-only bitmaps.
* ServerBitmap now deletes its buffers itself.
* Cleaned up BBitmap and BApplication a bit.
* The test environment currently doesn't build anymore, will fix it next.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16826 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-18 16:43:26 +03:00
|
|
|
#include <Messenger.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
2005-07-23 22:30:48 +04:00
|
|
|
|
2005-05-07 19:56:15 +04:00
|
|
|
class AreaPool;
|
2003-01-24 17:36:15 +03:00
|
|
|
class BMessage;
|
|
|
|
class BList;
|
2005-11-14 15:08:21 +03:00
|
|
|
class Desktop;
|
2005-11-04 18:23:54 +03:00
|
|
|
class DrawingEngine;
|
2005-05-14 17:22:26 +04:00
|
|
|
class ServerPicture;
|
2003-01-27 22:43:15 +03:00
|
|
|
class ServerCursor;
|
2004-02-24 14:58:25 +03:00
|
|
|
class ServerBitmap;
|
2005-11-14 15:08:21 +03:00
|
|
|
class ServerWindow;
|
2003-01-24 17:36:15 +03:00
|
|
|
|
2005-06-15 01:28:56 +04:00
|
|
|
namespace BPrivate {
|
|
|
|
class PortLink;
|
|
|
|
};
|
|
|
|
|
2005-07-23 22:30:48 +04:00
|
|
|
class ServerApp : public MessageLooper {
|
2006-01-12 14:59:24 +03:00
|
|
|
public:
|
|
|
|
ServerApp(Desktop* desktop,
|
|
|
|
port_id clientAppPort,
|
|
|
|
port_id clientLooperPort,
|
|
|
|
team_id clientTeamID,
|
|
|
|
int32 handlerID,
|
|
|
|
const char* signature);
|
|
|
|
virtual ~ServerApp();
|
|
|
|
|
|
|
|
status_t InitCheck();
|
|
|
|
void Quit(sem_id shutdownSemaphore = -1);
|
|
|
|
|
|
|
|
virtual port_id MessagePort() const { return fMessagePort; }
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Determines whether the application is the active one
|
|
|
|
\return true if active, false if not.
|
|
|
|
*/
|
|
|
|
bool IsActive(void) const { return fIsActive; }
|
|
|
|
void Activate(bool value);
|
|
|
|
|
|
|
|
void SendMessageToClient(BMessage* message) const;
|
|
|
|
|
2006-03-09 21:37:28 +03:00
|
|
|
void SetCurrentCursor(ServerCursor* cursor);
|
|
|
|
ServerCursor* CurrentCursor() const;
|
2006-01-12 14:59:24 +03:00
|
|
|
|
|
|
|
team_id ClientTeam() const;
|
|
|
|
const char* Signature() const { return fSignature.String(); }
|
* Implemented a new client allocation method: instead of having all bitmaps of
all teams in serveral server areas, and instead of having to eventually clone
them all several times in BBitmap, we now have one or more areas per team,
and BBitmap will only clone areas once if needed. As a side effect, this
method should be magnitudes faster than the previous version.
* This method is also much more secure: instead of putting the allocation
maintenance structures into those everyone-read-write areas, they are now
separated, so that faulty applications cannot crash the app_server this
way anymore. This should fix bug #172.
* Freeing memory is not yet implemented though! (although all memory will
be freed upon app exit)
* There are now 3 different bitmap allocation strategies: per ClientMemoryAllocator
(ie. via ServerApp), per area (for overlays, not yet implemented), and using
malloc()/free() for server-only bitmaps.
* ServerBitmap now deletes its buffers itself.
* Cleaned up BBitmap and BApplication a bit.
* The test environment currently doesn't build anymore, will fix it next.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16826 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-18 16:43:26 +03:00
|
|
|
const char* SignatureLeaf() const { return fSignature.String() + 12; }
|
2006-01-12 14:59:24 +03:00
|
|
|
|
2006-04-22 02:43:23 +04:00
|
|
|
bool AddWindow(ServerWindow* window);
|
2006-01-12 14:59:24 +03:00
|
|
|
void RemoveWindow(ServerWindow* window);
|
|
|
|
bool InWorkspace(int32 index) const;
|
|
|
|
uint32 Workspaces() const;
|
|
|
|
int32 InitialWorkspace() const { return fInitialWorkspace; }
|
|
|
|
|
|
|
|
int32 CountBitmaps() const;
|
|
|
|
ServerBitmap* FindBitmap(int32 token) const;
|
2006-03-09 21:37:28 +03:00
|
|
|
|
2006-01-12 14:59:24 +03:00
|
|
|
int32 CountPictures() const;
|
|
|
|
ServerPicture* CreatePicture(const ServerPicture* original = NULL);
|
|
|
|
ServerPicture* FindPicture(const int32& token) const;
|
|
|
|
bool DeletePicture(const int32& token);
|
2006-03-09 21:37:28 +03:00
|
|
|
|
2006-01-12 14:59:24 +03:00
|
|
|
Desktop* GetDesktop() const { return fDesktop; }
|
2006-03-09 21:37:28 +03:00
|
|
|
|
2006-01-12 14:59:24 +03:00
|
|
|
BPrivate::BTokenSpace& ViewTokens() { return fViewTokens; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual void _DispatchMessage(int32 code,
|
|
|
|
BPrivate::LinkReceiver& link);
|
|
|
|
virtual void _MessageLooper();
|
|
|
|
virtual void _GetLooperName(char* name, size_t size);
|
|
|
|
status_t _CreateWindow(int32 code,
|
|
|
|
BPrivate::LinkReceiver& link,
|
|
|
|
port_id& clientReplyPort);
|
|
|
|
|
2006-03-10 01:54:10 +03:00
|
|
|
bool _HasWindowUnderMouse();
|
|
|
|
|
2006-01-12 14:59:24 +03:00
|
|
|
port_id fMessagePort;
|
|
|
|
port_id fClientReplyPort;
|
|
|
|
// our BApplication's event port
|
|
|
|
|
|
|
|
BMessenger fHandlerMessenger;
|
|
|
|
port_id fClientLooperPort;
|
|
|
|
int32 fClientToken;
|
|
|
|
// To send a BMessage to the client
|
|
|
|
// (port + token)
|
|
|
|
|
2006-02-02 23:19:29 +03:00
|
|
|
Desktop* fDesktop;
|
|
|
|
BString fSignature;
|
|
|
|
team_id fClientTeam;
|
2006-01-12 14:59:24 +03:00
|
|
|
|
|
|
|
mutable BLocker fWindowListLock;
|
|
|
|
BObjectList<ServerWindow> fWindowList;
|
|
|
|
BPrivate::BTokenSpace fViewTokens;
|
|
|
|
|
|
|
|
int32 fInitialWorkspace;
|
|
|
|
|
|
|
|
// NOTE: Bitmaps and Pictures are stored globally, but ServerApps remember
|
|
|
|
// which ones they own so that they can destroy them when they quit.
|
2005-07-23 22:30:48 +04:00
|
|
|
// TODO:
|
|
|
|
// - As we reference these stuff by token, what about putting them in hash tables ?
|
2006-01-12 14:59:24 +03:00
|
|
|
BList fBitmapList;
|
|
|
|
BList fPictureList;
|
2005-06-23 21:40:35 +04:00
|
|
|
|
2006-01-12 14:59:24 +03:00
|
|
|
ServerCursor* fAppCursor;
|
2006-03-09 21:37:28 +03:00
|
|
|
ServerCursor* fViewCursor;
|
2006-01-12 14:59:24 +03:00
|
|
|
int32 fCursorHideLevel;
|
|
|
|
// 0 = cursor visible
|
2005-06-24 08:01:16 +04:00
|
|
|
|
2006-01-12 14:59:24 +03:00
|
|
|
bool fIsActive;
|
2005-06-24 08:01:16 +04:00
|
|
|
|
* Implemented a new client allocation method: instead of having all bitmaps of
all teams in serveral server areas, and instead of having to eventually clone
them all several times in BBitmap, we now have one or more areas per team,
and BBitmap will only clone areas once if needed. As a side effect, this
method should be magnitudes faster than the previous version.
* This method is also much more secure: instead of putting the allocation
maintenance structures into those everyone-read-write areas, they are now
separated, so that faulty applications cannot crash the app_server this
way anymore. This should fix bug #172.
* Freeing memory is not yet implemented though! (although all memory will
be freed upon app exit)
* There are now 3 different bitmap allocation strategies: per ClientMemoryAllocator
(ie. via ServerApp), per area (for overlays, not yet implemented), and using
malloc()/free() for server-only bitmaps.
* ServerBitmap now deletes its buffers itself.
* Cleaned up BBitmap and BApplication a bit.
* The test environment currently doesn't build anymore, will fix it next.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16826 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-18 16:43:26 +03:00
|
|
|
ClientMemoryAllocator fMemoryAllocator;
|
2003-01-24 17:36:15 +03:00
|
|
|
};
|
|
|
|
|
2006-02-02 23:19:29 +03:00
|
|
|
#endif // SERVER_APP_H
|