2005-07-05 22:14:24 +04:00
|
|
|
/*
|
2006-02-05 22:43:44 +03:00
|
|
|
* Copyright 2001-2006, Haiku.
|
2005-07-05 22:14:24 +04:00
|
|
|
* 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
|
|
|
|
2006-04-07 23:14:25 +04:00
|
|
|
#define USE_MULTI_LOCKER 1
|
2005-12-08 15:41:19 +03:00
|
|
|
|
|
|
|
#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;
|
2006-04-26 00:12:06 +04:00
|
|
|
struct server_read_only_memory;
|
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
|
|
|
|
2006-04-26 00:12:06 +04:00
|
|
|
status_t 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; }
|
2006-04-26 00:12:06 +04:00
|
|
|
area_id SharedReadOnlyArea() const { return fSharedReadOnlyArea; }
|
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
|
|
|
|
2006-02-05 22:43:44 +03:00
|
|
|
void SetCursor(ServerCursor* cursor);
|
|
|
|
ServerCursor* Cursor() const;
|
|
|
|
|
2006-02-06 16:36:46 +03:00
|
|
|
void ScreenChanged(Screen* screen, bool makeDefault);
|
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);
|
|
|
|
|
2006-03-14 01:05:49 +03:00
|
|
|
void MoveWindowBy(WindowLayer* window, float x, float y,
|
|
|
|
int32 workspace = -1);
|
2005-12-01 13:31:30 +03:00
|
|
|
void ResizeWindowBy(WindowLayer* window, float x, float y);
|
2006-05-24 15:05:25 +04:00
|
|
|
bool SetWindowTabLocation(WindowLayer* window, float location);
|
2006-05-25 16:01:28 +04:00
|
|
|
bool SetWindowDecoratorSettings(WindowLayer* window,
|
|
|
|
const BMessage& settings);
|
2005-12-01 13:31:30 +03:00
|
|
|
|
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);
|
|
|
|
|
2006-03-10 16:03:41 +03:00
|
|
|
void SetViewUnderMouse(const WindowLayer* window, int32 viewToken);
|
|
|
|
int32 ViewUnderMouse(const WindowLayer* window);
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
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
|
|
|
|
2006-02-13 16:12:10 +03:00
|
|
|
void RedrawBackground();
|
2006-04-13 00:55:36 +04:00
|
|
|
void StoreWorkspaceConfiguration(int32 index);
|
2006-02-13 16:12:10 +03:00
|
|
|
|
2006-02-09 21:53:36 +03:00
|
|
|
void MinimizeApplication(team_id team);
|
|
|
|
void BringApplicationToFront(team_id team);
|
2006-02-28 21:31:16 +03:00
|
|
|
void WindowAction(int32 windowToken, int32 action);
|
2006-02-09 21:53:36 +03:00
|
|
|
|
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);
|
|
|
|
|
2006-08-24 01:21:45 +04:00
|
|
|
void _UpdateSubsetWorkspaces(WindowLayer* window,
|
|
|
|
int32 previousIndex = -1,
|
|
|
|
int32 newIndex = -1);
|
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);
|
2006-04-01 19:43:25 +04:00
|
|
|
void _SendFakeMouseMoved(WindowLayer* window = NULL);
|
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;
|
2006-04-26 00:12:06 +04:00
|
|
|
area_id fSharedReadOnlyArea;
|
|
|
|
server_read_only_memory* fServerReadOnlyMemory;
|
2005-11-29 02:36:59 +03:00
|
|
|
|
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;
|
|
|
|
|
2006-04-13 00:55:36 +04:00
|
|
|
::Workspace::Private fWorkspaces[kMaxWorkspaces];
|
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;
|
2006-03-10 16:03:41 +03:00
|
|
|
const WindowLayer* fWindowUnderMouse;
|
|
|
|
int32 fViewUnderMouse;
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
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
|