2 * Copyright 2001-2013, Haiku.
3 * Distributed under the terms of the MIT License.
6 * DarkWyrm <bpmagic@columbus.rr.com>
7 * Adrian Oanca <adioanca@cotty.iren.ro>
8 * Stephan Aßmus <superstippi@gmx.de>
9 * Stefano Ceccherini (burton666@libero.it)
10 * Axel Dörfler, axeld@pinc-software.de
16 #include "ClientMemoryAllocator.h"
17 #include "MessageLooper.h"
18 #include "ServerFont.h"
20 #include <ObjectList.h>
21 #include <TokenSpace.h>
23 #include <Messenger.h>
42 class ServerApp
: public MessageLooper
{
44 ServerApp(Desktop
* desktop
,
45 port_id clientAppPort
,
46 port_id clientLooperPort
,
47 team_id clientTeamID
, int32 handlerID
,
48 const char* signature
);
54 void Quit(sem_id shutdownSemaphore
);
56 virtual port_id
MessagePort() const { return fMessagePort
; }
59 \brief Determines whether the application is the active one
60 \return true if active, false if not.
62 bool IsActive() const { return fIsActive
; }
63 void Activate(bool value
);
65 void SendMessageToClient(BMessage
* message
) const;
67 void SetCurrentCursor(ServerCursor
* cursor
);
68 ServerCursor
* CurrentCursor() const;
70 team_id
ClientTeam() const { return fClientTeam
; }
72 const char* Signature() const
73 { return fSignature
.String(); }
74 const char* SignatureLeaf() const
75 { return fSignature
.String() + 12; }
77 bool AddWindow(ServerWindow
* window
);
78 void RemoveWindow(ServerWindow
* window
);
79 bool InWorkspace(int32 index
) const;
80 uint32
Workspaces() const;
81 int32
InitialWorkspace() const
82 { return fInitialWorkspace
; }
84 ServerBitmap
* GetBitmap(int32 token
) const;
86 ServerPicture
* CreatePicture(
87 const ServerPicture
* original
= NULL
);
88 ServerPicture
* GetPicture(int32 token
) const;
89 bool AddPicture(ServerPicture
* picture
);
90 void RemovePicture(ServerPicture
* picture
);
92 Desktop
* GetDesktop() const { return fDesktop
; }
94 const ServerFont
& PlainFont() const { return fPlainFont
; }
96 BPrivate::BTokenSpace
& ViewTokens() { return fViewTokens
; }
98 void NotifyDeleteClientArea(area_id serverArea
);
101 virtual void _GetLooperName(char* name
, size_t size
);
102 virtual void _DispatchMessage(int32 code
,
103 BPrivate::LinkReceiver
& link
);
104 virtual void _MessageLooper();
105 status_t
_CreateWindow(int32 code
,
106 BPrivate::LinkReceiver
& link
,
107 port_id
& clientReplyPort
);
109 bool _HasWindowUnderMouse();
111 bool _AddBitmap(ServerBitmap
* bitmap
);
112 void _DeleteBitmap(ServerBitmap
* bitmap
);
113 ServerBitmap
* _FindBitmap(int32 token
) const;
115 ServerPicture
* _FindPicture(int32 token
) const;
118 typedef std::map
<int32
, ServerBitmap
*> BitmapMap
;
119 typedef std::map
<int32
, ServerPicture
*> PictureMap
;
121 port_id fMessagePort
;
122 port_id fClientReplyPort
;
123 // our BApplication's event port
125 BMessenger fHandlerMessenger
;
126 port_id fClientLooperPort
;
128 // To send a BMessage to the client
135 ServerFont fPlainFont
;
136 ServerFont fBoldFont
;
137 ServerFont fFixedFont
;
139 mutable BLocker fWindowListLock
;
140 BObjectList
<ServerWindow
> fWindowList
;
141 BPrivate::BTokenSpace fViewTokens
;
143 int32 fInitialWorkspace
;
144 uint32 fTemporaryDisplayModeChange
;
146 // NOTE: Bitmaps and Pictures are stored globally, but ServerApps
147 // remember which ones they own so that they can destroy them when
149 mutable BLocker fMapLocker
;
150 BitmapMap fBitmapMap
;
151 PictureMap fPictureMap
;
153 ServerCursor
* fAppCursor
;
154 ServerCursor
* fViewCursor
;
155 int32 fCursorHideLevel
;
156 // 0 = cursor visible
160 ClientMemoryAllocator
* fMemoryAllocator
;
164 #endif // SERVER_APP_H