btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / servers / app / ServerApp.h
blob433ea472f6c1b3c10c3a34d128a68125f8225fe2
1 /*
2 * Copyright 2001-2013, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
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
12 #ifndef SERVER_APP_H
13 #define SERVER_APP_H
16 #include "ClientMemoryAllocator.h"
17 #include "MessageLooper.h"
18 #include "ServerFont.h"
20 #include <ObjectList.h>
21 #include <TokenSpace.h>
23 #include <Messenger.h>
24 #include <String.h>
27 class AreaPool;
28 class BMessage;
29 class BList;
30 class Desktop;
31 class DrawingEngine;
32 class ServerPicture;
33 class ServerCursor;
34 class ServerBitmap;
35 class ServerWindow;
37 namespace BPrivate {
38 class PortLink;
42 class ServerApp : public MessageLooper {
43 public:
44 ServerApp(Desktop* desktop,
45 port_id clientAppPort,
46 port_id clientLooperPort,
47 team_id clientTeamID, int32 handlerID,
48 const char* signature);
49 virtual ~ServerApp();
51 status_t InitCheck();
53 virtual void Quit();
54 void Quit(sem_id shutdownSemaphore);
56 virtual port_id MessagePort() const { return fMessagePort; }
58 /*!
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);
100 private:
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;
117 private:
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;
127 int32 fClientToken;
128 // To send a BMessage to the client
129 // (port + token)
131 Desktop* fDesktop;
132 BString fSignature;
133 team_id fClientTeam;
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
148 // they quit.
149 mutable BLocker fMapLocker;
150 BitmapMap fBitmapMap;
151 PictureMap fPictureMap;
153 ServerCursor* fAppCursor;
154 ServerCursor* fViewCursor;
155 int32 fCursorHideLevel;
156 // 0 = cursor visible
158 bool fIsActive;
160 ClientMemoryAllocator* fMemoryAllocator;
164 #endif // SERVER_APP_H