2005-07-05 22:14:24 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2001-2005, Haiku.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Adrian Oanca <adioanca@cotty.iren.ro>
|
|
|
|
* Stephan Aßmus <superstippi@gmx.de>
|
|
|
|
* Axel Dörfler, axeld@pinc-software.de
|
|
|
|
*/
|
2005-11-29 02:36:59 +03:00
|
|
|
#ifndef DESKTOP_H
|
|
|
|
#define DESKTOP_H
|
2003-01-24 18:19:27 +03:00
|
|
|
|
2005-11-17 17:58:19 +03:00
|
|
|
|
2005-08-21 14:28:40 +04:00
|
|
|
#include "CursorManager.h"
|
2005-11-17 17:58:19 +03:00
|
|
|
#include "EventDispatcher.h"
|
2005-07-15 16:45:23 +04:00
|
|
|
#include "ScreenManager.h"
|
|
|
|
#include "ServerScreen.h"
|
|
|
|
#include "VirtualScreen.h"
|
2005-07-17 20:25:48 +04:00
|
|
|
#include "DesktopSettings.h"
|
2005-07-24 21:14:17 +04:00
|
|
|
#include "MessageLooper.h"
|
2005-12-08 15:41:19 +03:00
|
|
|
#include "WindowList.h"
|
2005-11-29 02:36:59 +03:00
|
|
|
#include "Workspace.h"
|
2005-11-30 22:56:44 +03:00
|
|
|
#include "WorkspacePrivate.h"
|
2005-07-15 16:45:23 +04:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
#include <ObjectList.h>
|
|
|
|
|
|
|
|
#include <Autolock.h>
|
2005-06-24 03:46:17 +04:00
|
|
|
#include <InterfaceDefs.h>
|
2004-01-12 01:12:55 +03:00
|
|
|
#include <List.h>
|
2003-07-06 23:48:17 +04:00
|
|
|
#include <Menu.h>
|
2005-12-08 15:41:19 +03:00
|
|
|
#include <Region.h>
|
2005-12-01 16:59:04 +03:00
|
|
|
#include <Window.h>
|
2005-07-05 22:14:24 +04:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
#define USE_MULTI_LOCKER 0
|
|
|
|
|
|
|
|
#if USE_MULTI_LOCKER
|
|
|
|
# include "MultiLocker.h"
|
|
|
|
#else
|
|
|
|
# include <Locker.h>
|
|
|
|
#endif
|
2003-01-24 18:19:27 +03:00
|
|
|
|
2005-06-24 03:46:17 +04:00
|
|
|
class BMessage;
|
2005-07-05 22:14:24 +04:00
|
|
|
|
2005-11-04 18:23:54 +03:00
|
|
|
class DrawingEngine;
|
2005-06-24 03:46:17 +04:00
|
|
|
class HWInterface;
|
2005-12-08 15:41:19 +03:00
|
|
|
class ServerApp;
|
2005-12-09 19:20:01 +03:00
|
|
|
class WorkspacesLayer;
|
2003-01-24 18:19:27 +03:00
|
|
|
|
2005-07-05 22:14:24 +04:00
|
|
|
namespace BPrivate {
|
|
|
|
class LinkSender;
|
|
|
|
};
|
|
|
|
|
2005-07-24 21:14:17 +04:00
|
|
|
class Desktop : public MessageLooper, public ScreenOwner {
|
2005-11-29 02:36:59 +03:00
|
|
|
public:
|
2005-10-31 22:35:46 +03:00
|
|
|
Desktop(uid_t userID);
|
2005-11-29 02:36:59 +03:00
|
|
|
virtual ~Desktop();
|
2005-06-24 03:46:17 +04:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
void Init();
|
2005-10-31 22:35:46 +03:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
uid_t UserID() const { return fUserID; }
|
|
|
|
virtual port_id MessagePort() const { return fMessagePort; }
|
2005-07-26 01:08:34 +04:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
::EventDispatcher& EventDispatcher() { return fEventDispatcher; }
|
2005-11-15 22:59:53 +03:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
void BroadcastToAllApps(int32 code);
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
// Screen and drawing related methods
|
|
|
|
|
|
|
|
Screen* ScreenAt(int32 index) const
|
2005-07-15 16:45:23 +04:00
|
|
|
{ return fActiveScreen; }
|
2005-11-29 02:36:59 +03:00
|
|
|
Screen* ActiveScreen() const
|
2005-06-25 12:45:00 +04:00
|
|
|
{ return fActiveScreen; }
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
CursorManager& GetCursorManager() { return fCursorManager; }
|
2005-06-25 12:45:00 +04:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
void ScreenChanged(Screen* screen);
|
2005-11-26 19:56:52 +03:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
void ScreenRemoved(Screen* screen) {}
|
|
|
|
void ScreenAdded(Screen* screen) {}
|
|
|
|
bool ReleaseScreen(Screen* screen) { return false; }
|
2005-06-25 12:45:00 +04:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
const ::VirtualScreen& VirtualScreen() const { return fVirtualScreen; }
|
|
|
|
DrawingEngine* GetDrawingEngine() const
|
2005-11-04 18:23:54 +03:00
|
|
|
{ return fVirtualScreen.DrawingEngine(); }
|
2005-11-29 02:36:59 +03:00
|
|
|
::HWInterface* HWInterface() const
|
2005-07-15 16:45:23 +04:00
|
|
|
{ return fVirtualScreen.HWInterface(); }
|
2005-06-24 03:46:17 +04:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
// Workspace methods
|
|
|
|
|
|
|
|
void SetWorkspace(int32 index);
|
|
|
|
int32 CurrentWorkspace()
|
|
|
|
{ return fCurrentWorkspace; }
|
2005-11-30 22:56:44 +03:00
|
|
|
Workspace::Private& WorkspaceAt(int32 index)
|
2005-11-29 02:36:59 +03:00
|
|
|
{ return fWorkspaces[index]; }
|
2005-12-08 15:41:19 +03:00
|
|
|
void UpdateWorkspaces();
|
2005-11-29 02:36:59 +03:00
|
|
|
|
|
|
|
// WindowLayer methods
|
|
|
|
|
|
|
|
void ActivateWindow(WindowLayer* window);
|
2005-12-08 15:41:19 +03:00
|
|
|
void SendWindowBehind(WindowLayer* window,
|
|
|
|
WindowLayer* behindOf = NULL);
|
2005-11-29 02:36:59 +03:00
|
|
|
|
2005-11-30 13:45:01 +03:00
|
|
|
void ShowWindow(WindowLayer* window);
|
|
|
|
void HideWindow(WindowLayer* window);
|
|
|
|
|
2005-12-01 13:31:30 +03:00
|
|
|
void MoveWindowBy(WindowLayer* window, float x, float y);
|
|
|
|
void ResizeWindowBy(WindowLayer* window, float x, float y);
|
|
|
|
|
2005-11-30 18:47:01 +03:00
|
|
|
void SetWindowWorkspaces(WindowLayer* window,
|
|
|
|
uint32 workspaces);
|
2005-11-29 02:36:59 +03:00
|
|
|
|
2005-12-01 16:59:04 +03:00
|
|
|
void AddWindow(WindowLayer* window);
|
|
|
|
void RemoveWindow(WindowLayer* window);
|
|
|
|
|
2005-12-09 16:17:43 +03:00
|
|
|
bool AddWindowToSubset(WindowLayer* subset,
|
|
|
|
WindowLayer* window);
|
|
|
|
void RemoveWindowFromSubset(WindowLayer* subset,
|
|
|
|
WindowLayer* window);
|
|
|
|
|
2005-12-01 16:59:04 +03:00
|
|
|
void SetWindowLook(WindowLayer* window, window_look look);
|
|
|
|
void SetWindowFeel(WindowLayer* window, window_feel feel);
|
|
|
|
void SetWindowFlags(WindowLayer* window, uint32 flags);
|
2005-12-09 01:15:12 +03:00
|
|
|
void SetWindowTitle(WindowLayer* window, const char* title);
|
2005-11-29 02:36:59 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
WindowLayer* FocusWindow() const { return fFocus; }
|
|
|
|
WindowLayer* FrontWindow() const { return fFront; }
|
|
|
|
WindowLayer* BackWindow() const { return fBack; }
|
|
|
|
|
|
|
|
WindowLayer* WindowAt(BPoint where);
|
|
|
|
|
|
|
|
WindowLayer* MouseEventWindow() const { return fMouseEventWindow; }
|
|
|
|
void SetMouseEventWindow(WindowLayer* window);
|
|
|
|
|
|
|
|
void SetFocusWindow(WindowLayer* window);
|
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
WindowLayer* FindWindowLayerByClientToken(int32 token, team_id teamID);
|
|
|
|
//WindowLayer* FindWindowLayerByServerToken(int32 token);
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
#if USE_MULTI_LOCKER
|
2005-12-12 13:41:31 +03:00
|
|
|
bool LockSingleWindow() { return fWindowLock.ReadLock(); }
|
|
|
|
void UnlockSingleWindow() { fWindowLock.ReadUnlock(); }
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2005-12-12 13:41:31 +03:00
|
|
|
bool LockAllWindows() { return fWindowLock.WriteLock(); }
|
|
|
|
void UnlockAllWindows() { fWindowLock.WriteUnlock(); }
|
2005-12-08 15:41:19 +03:00
|
|
|
#else // USE_MULTI_LOCKER
|
2005-12-12 13:41:31 +03:00
|
|
|
bool LockSingleWindow() { return fWindowLock.Lock(); }
|
|
|
|
void UnlockSingleWindow() { fWindowLock.Unlock(); }
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2005-12-12 13:41:31 +03:00
|
|
|
bool LockAllWindows() { return fWindowLock.Lock(); }
|
|
|
|
void UnlockAllWindows() { fWindowLock.Unlock(); }
|
2005-12-08 15:41:19 +03:00
|
|
|
#endif // USE_MULTI_LOCKER
|
|
|
|
|
|
|
|
void MarkDirty(BRegion& region);
|
|
|
|
|
|
|
|
BRegion& BackgroundRegion()
|
|
|
|
{ return fBackgroundRegion; }
|
2005-11-29 02:36:59 +03:00
|
|
|
|
|
|
|
void WriteWindowList(team_id team,
|
|
|
|
BPrivate::LinkSender& sender);
|
|
|
|
void WriteWindowInfo(int32 serverToken,
|
|
|
|
BPrivate::LinkSender& sender);
|
|
|
|
|
|
|
|
private:
|
2005-12-08 15:41:19 +03:00
|
|
|
void _ShowWindow(WindowLayer* window,
|
|
|
|
bool affectsOtherWindows = true);
|
|
|
|
void _HideWindow(WindowLayer* window);
|
|
|
|
|
2005-12-09 16:17:43 +03:00
|
|
|
void _UpdateSubsetWorkspaces(WindowLayer* window);
|
2005-11-30 18:47:01 +03:00
|
|
|
void _ChangeWindowWorkspaces(WindowLayer* window,
|
|
|
|
uint32 oldWorkspaces, uint32 newWorkspaces);
|
2005-12-08 15:41:19 +03:00
|
|
|
void _BringWindowsToFront(WindowList& windows,
|
|
|
|
int32 list, bool wereVisible);
|
2005-11-29 02:36:59 +03:00
|
|
|
status_t _ActivateApp(team_id team);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
|
|
|
void _RebuildClippingForAllWindows(BRegion& stillAvailableOnScreen);
|
|
|
|
void _TriggerWindowRedrawing(BRegion& newDirtyRegion);
|
|
|
|
void _SetBackground(BRegion& background);
|
|
|
|
|
2005-12-09 16:17:43 +03:00
|
|
|
void _UpdateFloating(int32 previousWorkspace = -1,
|
|
|
|
int32 nextWorkspace = -1);
|
2005-12-08 15:41:19 +03:00
|
|
|
void _UpdateBack();
|
2005-12-09 16:17:43 +03:00
|
|
|
void _UpdateFront(bool updateFloating = true);
|
|
|
|
void _UpdateFronts(bool updateFloating = true);
|
|
|
|
bool _WindowHasModal(WindowLayer* window);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2005-12-09 19:20:01 +03:00
|
|
|
void _WindowChanged(WindowLayer* window);
|
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
void _GetLooperName(char* name, size_t size);
|
|
|
|
void _PrepareQuit();
|
|
|
|
void _DispatchMessage(int32 code,
|
|
|
|
BPrivate::LinkReceiver &link);
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
WindowList& _CurrentWindows();
|
2005-12-09 16:17:43 +03:00
|
|
|
WindowList& _Windows(int32 index);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
private:
|
|
|
|
friend class DesktopSettings;
|
|
|
|
|
|
|
|
uid_t fUserID;
|
|
|
|
::VirtualScreen fVirtualScreen;
|
|
|
|
DesktopSettings::Private* fSettings;
|
|
|
|
port_id fMessagePort;
|
|
|
|
::EventDispatcher fEventDispatcher;
|
|
|
|
port_id fInputPort;
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
BLocker fApplicationsLock;
|
|
|
|
BObjectList<ServerApp> fApplications;
|
2005-11-29 02:36:59 +03:00
|
|
|
|
|
|
|
sem_id fShutdownSemaphore;
|
|
|
|
int32 fShutdownCount;
|
|
|
|
|
2005-11-30 22:56:44 +03:00
|
|
|
::Workspace::Private fWorkspaces[32];
|
2005-11-29 02:36:59 +03:00
|
|
|
int32 fCurrentWorkspace;
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
WindowList fAllWindows;
|
2005-12-09 16:17:43 +03:00
|
|
|
WindowList fSubsetWindows;
|
2005-12-09 19:20:01 +03:00
|
|
|
WorkspacesLayer* fWorkspacesLayer;
|
2005-11-29 02:36:59 +03:00
|
|
|
|
|
|
|
Screen* fActiveScreen;
|
|
|
|
|
|
|
|
CursorManager fCursorManager;
|
2005-12-08 15:41:19 +03:00
|
|
|
|
|
|
|
#if USE_MULTI_LOCKER
|
|
|
|
MultiLocker fWindowLock;
|
|
|
|
#else
|
|
|
|
BLocker fWindowLock;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BRegion fBackgroundRegion;
|
|
|
|
BRegion fScreenRegion;
|
|
|
|
|
|
|
|
bool fFocusFollowsMouse;
|
|
|
|
|
|
|
|
WindowLayer* fMouseEventWindow;
|
|
|
|
WindowLayer* fFocus;
|
|
|
|
WindowLayer* fFront;
|
|
|
|
WindowLayer* fBack;
|
2004-01-12 01:12:55 +03:00
|
|
|
};
|
2003-07-06 23:48:17 +04:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
#endif // DESKTOP_H
|