xref: /haiku/src/servers/app/Desktop.h (revision 94978fa6a71bdb289ed6a14fa0292adaeceb5380)
1 /*
2  * Copyright 2001-2005, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Adrian Oanca <adioanca@cotty.iren.ro>
7  *		Stephan Aßmus <superstippi@gmx.de>
8  *		Axel Dörfler, axeld@pinc-software.de
9  */
10 #ifndef _DESKTOP_H_
11 #define _DESKTOP_H_
12 
13 #include "CursorManager.h"
14 #include "ScreenManager.h"
15 #include "ServerScreen.h"
16 #include "VirtualScreen.h"
17 #include "DesktopSettings.h"
18 #include "MessageLooper.h"
19 
20 #include <InterfaceDefs.h>
21 #include <List.h>
22 #include <Locker.h>
23 #include <Menu.h>
24 #include <Autolock.h>
25 
26 
27 class BMessage;
28 
29 class DisplayDriver;
30 class HWInterface;
31 class Layer;
32 class RootLayer;
33 class WinBorder;
34 
35 namespace BPrivate {
36 	class LinkSender;
37 };
38 
39 
40 class Desktop : public MessageLooper, public ScreenOwner {
41  public:
42 	// startup methods
43 								Desktop();
44 	virtual						~Desktop();
45 
46 			void				Init();
47 	virtual port_id				MessagePort() const { return fMessagePort; }
48 
49 			void				BroadcastToAllApps(int32 code);
50 
51 	// Methods for multiple monitors.
52 	inline	Screen*				ScreenAt(int32 index) const
53 									{ return fActiveScreen; }
54 	inline	Screen*				ActiveScreen() const
55 									{ return fActiveScreen; }
56 	inline	RootLayer*			ActiveRootLayer() const { return fRootLayer; }
57 	inline	CursorManager&		GetCursorManager() { return fCursorManager; }
58 
59 	virtual void				ScreenRemoved(Screen* screen) {}
60 	virtual void				ScreenAdded(Screen* screen) {}
61 	virtual bool				ReleaseScreen(Screen* screen) { return false; }
62 
63 	const	::VirtualScreen&	VirtualScreen() const { return fVirtualScreen; }
64 	inline	DisplayDriver*		GetDisplayDriver() const
65 									{ return fVirtualScreen.DisplayDriver(); }
66 	inline	HWInterface*		GetHWInterface() const
67 									{ return fVirtualScreen.HWInterface(); }
68 
69 	// Methods for layer(WinBorder) manipulation.
70 			void				AddWinBorder(WinBorder *winBorder);
71 			void				RemoveWinBorder(WinBorder *winBorder);
72 			void				SetWinBorderFeel(WinBorder *winBorder,
73 												 uint32 feel);
74 			void				AddWinBorderToSubset(WinBorder *winBorder,
75 													 WinBorder *toWinBorder);
76 			void				RemoveWinBorderFromSubset(WinBorder *winBorder,
77 														  WinBorder *fromWinBorder);
78 
79 			WinBorder*			FindWinBorderByClientToken(int32 token, team_id teamID);
80 			//WinBorder*		FindWinBorderByServerToken(int32 token);
81 
82 	// get list of registed windows
83 			const BList&		WindowList() const
84 								{
85 									if (!IsLocked())
86 										debugger("You must lock before getting registered windows list\n");
87 									return fWinBorderList;
88 								}
89 
90 			void				WriteWindowList(team_id team, BPrivate::LinkSender& sender);
91 			void				WriteWindowInfo(int32 serverToken, BPrivate::LinkSender& sender);
92 
93  private:
94 	virtual void				_GetLooperName(char* name, size_t size);
95 	virtual void				_PrepareQuit();
96 	virtual void				_DispatchMessage(int32 code, BPrivate::LinkReceiver &link);
97 
98  private:
99 			friend class DesktopSettings;
100 
101 			::VirtualScreen		fVirtualScreen;
102 			DesktopSettings::Private* fSettings;
103 			port_id				fMessagePort;
104 
105 			BLocker				fAppListLock;
106 			BList				fAppList;
107 
108 			sem_id				fShutdownSemaphore;
109 			int32				fShutdownCount;
110 
111 			BList				fWinBorderList;
112 
113 			RootLayer*			fRootLayer;
114 			Screen*				fActiveScreen;
115 
116 			CursorManager		fCursorManager;
117 };
118 
119 #endif	// _DESKTOP_H_
120