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 RegisterInputServer(port_id port); 53 port_id InputServerPort() { return fInputPort; } 54 55 void BroadcastToAllApps(int32 code); 56 57 // Methods for multiple monitors. 58 inline Screen* ScreenAt(int32 index) const 59 { return fActiveScreen; } 60 inline Screen* ActiveScreen() const 61 { return fActiveScreen; } 62 inline RootLayer* ActiveRootLayer() const { return fRootLayer; } 63 inline CursorManager& GetCursorManager() { return fCursorManager; } 64 65 virtual void ScreenRemoved(Screen* screen) {} 66 virtual void ScreenAdded(Screen* screen) {} 67 virtual bool ReleaseScreen(Screen* screen) { return false; } 68 69 const ::VirtualScreen& VirtualScreen() const { return fVirtualScreen; } 70 inline DrawingEngine* GetDrawingEngine() const 71 { return fVirtualScreen.DrawingEngine(); } 72 inline HWInterface* GetHWInterface() const 73 { return fVirtualScreen.HWInterface(); } 74 75 // Methods for layer(WinBorder) manipulation. 76 void AddWinBorder(WinBorder *winBorder); 77 void RemoveWinBorder(WinBorder *winBorder); 78 void SetWinBorderFeel(WinBorder *winBorder, 79 uint32 feel); 80 void AddWinBorderToSubset(WinBorder *winBorder, 81 WinBorder *toWinBorder); 82 void RemoveWinBorderFromSubset(WinBorder *winBorder, 83 WinBorder *fromWinBorder); 84 85 WinBorder* FindWinBorderByClientToken(int32 token, team_id teamID); 86 //WinBorder* FindWinBorderByServerToken(int32 token); 87 88 // get list of registed windows 89 const BObjectList<WinBorder>& WindowList() const; 90 91 void WriteWindowList(team_id team, BPrivate::LinkSender& sender); 92 void WriteWindowInfo(int32 serverToken, BPrivate::LinkSender& sender); 93 94 private: 95 status_t _ActivateApp(team_id team); 96 virtual void _GetLooperName(char* name, size_t size); 97 virtual void _PrepareQuit(); 98 virtual void _DispatchMessage(int32 code, BPrivate::LinkReceiver &link); 99 100 private: 101 friend class DesktopSettings; 102 103 uid_t fUserID; 104 ::VirtualScreen fVirtualScreen; 105 DesktopSettings::Private* fSettings; 106 port_id fMessagePort; 107 port_id fInputPort; 108 109 BLocker fAppListLock; 110 BList fAppList; 111 112 sem_id fShutdownSemaphore; 113 int32 fShutdownCount; 114 115 BObjectList<WinBorder> fWinBorderList; 116 117 RootLayer* fRootLayer; 118 Screen* fActiveScreen; 119 120 CursorManager fCursorManager; 121 }; 122 123 #endif // _DESKTOP_H_ 124