xref: /haiku/src/servers/app/Desktop.h (revision d29f332ad4210e2e2b5ef42231531dd937ebc52e)
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 #include <ObjectList.h>
26 
27 
28 class BMessage;
29 
30 class DrawingEngine;
31 class HWInterface;
32 class Layer;
33 class RootLayer;
34 class WinBorder;
35 
36 namespace BPrivate {
37 	class LinkSender;
38 };
39 
40 
41 class Desktop : public MessageLooper, public ScreenOwner {
42  public:
43 	// startup methods
44 								Desktop(uid_t userID);
45 	virtual						~Desktop();
46 
47 			void				Init();
48 
49 			uid_t				UserID() const { return fUserID; }
50 	virtual port_id				MessagePort() const { return fMessagePort; }
51 
52 			void				BroadcastToAllApps(int32 code);
53 
54 	// Methods for multiple monitors.
55 	inline	Screen*				ScreenAt(int32 index) const
56 									{ return fActiveScreen; }
57 	inline	Screen*				ActiveScreen() const
58 									{ return fActiveScreen; }
59 	inline	RootLayer*			ActiveRootLayer() const { return fRootLayer; }
60 	inline	CursorManager&		GetCursorManager() { return fCursorManager; }
61 
62 	virtual void				ScreenRemoved(Screen* screen) {}
63 	virtual void				ScreenAdded(Screen* screen) {}
64 	virtual bool				ReleaseScreen(Screen* screen) { return false; }
65 
66 	const	::VirtualScreen&	VirtualScreen() const { return fVirtualScreen; }
67 	inline	DrawingEngine*		GetDrawingEngine() const
68 									{ return fVirtualScreen.DrawingEngine(); }
69 	inline	HWInterface*		GetHWInterface() const
70 									{ return fVirtualScreen.HWInterface(); }
71 
72 	// Methods for layer(WinBorder) manipulation.
73 			void				AddWinBorder(WinBorder *winBorder);
74 			void				RemoveWinBorder(WinBorder *winBorder);
75 			void				SetWinBorderFeel(WinBorder *winBorder,
76 												 uint32 feel);
77 			void				AddWinBorderToSubset(WinBorder *winBorder,
78 													 WinBorder *toWinBorder);
79 			void				RemoveWinBorderFromSubset(WinBorder *winBorder,
80 														  WinBorder *fromWinBorder);
81 
82 			WinBorder*			FindWinBorderByClientToken(int32 token, team_id teamID);
83 			//WinBorder*		FindWinBorderByServerToken(int32 token);
84 
85 			// get list of registed windows
86 			const BObjectList<WinBorder>& WindowList() const;
87 
88 			void				WriteWindowList(team_id team, BPrivate::LinkSender& sender);
89 			void				WriteWindowInfo(int32 serverToken, BPrivate::LinkSender& sender);
90 
91  private:
92  			status_t			_ActivateApp(team_id team);
93 	virtual void				_GetLooperName(char* name, size_t size);
94 	virtual void				_PrepareQuit();
95 	virtual void				_DispatchMessage(int32 code, BPrivate::LinkReceiver &link);
96 
97  private:
98 			friend class DesktopSettings;
99 
100 			uid_t				fUserID;
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 			BObjectList<WinBorder> fWinBorderList;
112 
113 			RootLayer*			fRootLayer;
114 			Screen*				fActiveScreen;
115 
116 			CursorManager		fCursorManager;
117 };
118 
119 #endif	// _DESKTOP_H_
120