2005-07-05 22:14:24 +04:00
|
|
|
/*
|
2008-03-04 15:47:34 +03:00
|
|
|
* Copyright 2001-2008, 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
|
2008-07-10 12:29:50 +04:00
|
|
|
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
|
2005-07-05 22:14:24 +04:00
|
|
|
*/
|
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"
|
2008-04-02 15:12:39 +04:00
|
|
|
#include "DesktopSettings.h"
|
2005-11-17 17:58:19 +03:00
|
|
|
#include "EventDispatcher.h"
|
2008-04-02 15:12:39 +04:00
|
|
|
#include "MessageLooper.h"
|
2008-03-08 15:45:54 +03:00
|
|
|
#include "Screen.h"
|
2005-07-15 16:45:23 +04:00
|
|
|
#include "ScreenManager.h"
|
2008-04-02 15:12:39 +04:00
|
|
|
#include "ServerCursor.h"
|
2005-07-15 16:45:23 +04:00
|
|
|
#include "VirtualScreen.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;
|
2008-03-08 15:45:54 +03:00
|
|
|
class Window;
|
|
|
|
class WorkspacesView;
|
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; }
|
2008-03-28 21:59:08 +03: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);
|
2008-04-02 15:12:39 +04:00
|
|
|
ServerCursorReference Cursor() const;
|
2007-10-02 18:09:11 +04:00
|
|
|
void SetLastMouseState(const BPoint& position,
|
|
|
|
int32 buttons);
|
|
|
|
// for use by the mouse filter only
|
|
|
|
// both mouse position calls require
|
|
|
|
// the Desktop object to be locked
|
|
|
|
// already
|
|
|
|
void GetLastMouseState(BPoint* position,
|
|
|
|
int32* buttons) const;
|
|
|
|
// for use by ServerWindow
|
2006-02-05 22:43:44 +03:00
|
|
|
|
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
|
|
|
|
|
2007-10-02 18:09:11 +04:00
|
|
|
void SetWorkspaceAsync(int32 index);
|
2005-11-29 02:36:59 +03:00
|
|
|
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]; }
|
2006-08-26 19:13:08 +04:00
|
|
|
status_t SetWorkspacesCount(int32 newCount);
|
2005-11-29 02:36:59 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
// Window methods
|
2005-11-29 02:36:59 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
void ActivateWindow(Window* window);
|
|
|
|
void SendWindowBehind(Window* window,
|
|
|
|
Window* behindOf = NULL);
|
2005-11-29 02:36:59 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
void ShowWindow(Window* window);
|
|
|
|
void HideWindow(Window* window);
|
2005-11-30 13:45:01 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
void MoveWindowBy(Window* window, float x, float y,
|
2006-03-14 01:05:49 +03:00
|
|
|
int32 workspace = -1);
|
2008-03-28 21:59:08 +03:00
|
|
|
void ResizeWindowBy(Window* window, float x,
|
|
|
|
float y);
|
|
|
|
bool SetWindowTabLocation(Window* window,
|
|
|
|
float location);
|
2008-03-08 15:45:54 +03:00
|
|
|
bool SetWindowDecoratorSettings(Window* window,
|
2008-03-28 21:59:08 +03:00
|
|
|
const BMessage& settings);
|
2005-12-01 13:31:30 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
void SetWindowWorkspaces(Window* window,
|
2005-11-30 18:47:01 +03:00
|
|
|
uint32 workspaces);
|
2005-11-29 02:36:59 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
void AddWindow(Window* window);
|
|
|
|
void RemoveWindow(Window* window);
|
2005-12-01 16:59:04 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
bool AddWindowToSubset(Window* subset,
|
|
|
|
Window* window);
|
|
|
|
void RemoveWindowFromSubset(Window* subset,
|
|
|
|
Window* window);
|
2005-12-09 16:17:43 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
void SetWindowLook(Window* window, window_look look);
|
|
|
|
void SetWindowFeel(Window* window, window_feel feel);
|
|
|
|
void SetWindowFlags(Window* window, uint32 flags);
|
2008-03-28 21:59:08 +03:00
|
|
|
void SetWindowTitle(Window* window,
|
|
|
|
const char* title);
|
2005-11-29 02:36:59 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
Window* FocusWindow() const { return fFocus; }
|
|
|
|
Window* FrontWindow() const { return fFront; }
|
|
|
|
Window* BackWindow() const { return fBack; }
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
Window* WindowAt(BPoint where);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2008-03-28 21:59:08 +03:00
|
|
|
Window* MouseEventWindow() const
|
|
|
|
{ return fMouseEventWindow; }
|
2008-03-08 15:45:54 +03:00
|
|
|
void SetMouseEventWindow(Window* window);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2008-03-28 21:59:08 +03:00
|
|
|
void SetViewUnderMouse(const Window* window,
|
|
|
|
int32 viewToken);
|
2008-03-08 15:45:54 +03:00
|
|
|
int32 ViewUnderMouse(const Window* window);
|
2006-03-10 16:03:41 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
void SetFocusWindow(Window* window = NULL);
|
2006-10-30 17:21:28 +03:00
|
|
|
EventTarget* KeyboardEventTarget();
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
Window* FindWindowByClientToken(int32 token,
|
|
|
|
team_id teamID);
|
2005-11-29 02:36:59 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
#if USE_MULTI_LOCKER
|
2008-03-28 21:59:08 +03:00
|
|
|
bool LockSingleWindow()
|
|
|
|
{ return fWindowLock.ReadLock(); }
|
|
|
|
void UnlockSingleWindow()
|
|
|
|
{ fWindowLock.ReadUnlock(); }
|
|
|
|
|
|
|
|
bool LockAllWindows()
|
|
|
|
{ return fWindowLock.WriteLock(); }
|
|
|
|
void UnlockAllWindows()
|
|
|
|
{ fWindowLock.WriteUnlock(); }
|
2005-12-08 15:41:19 +03:00
|
|
|
#else // USE_MULTI_LOCKER
|
2008-03-28 21:59:08 +03:00
|
|
|
bool LockSingleWindow()
|
|
|
|
{ return fWindowLock.Lock(); }
|
|
|
|
void UnlockSingleWindow()
|
|
|
|
{ fWindowLock.Unlock(); }
|
|
|
|
|
|
|
|
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);
|
2008-07-10 12:29:50 +04:00
|
|
|
void Redraw();
|
2005-12-08 15:41:19 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
void AddWorkspacesView(WorkspacesView* view);
|
|
|
|
void RemoveWorkspacesView(WorkspacesView* view);
|
2008-03-08 14:42:20 +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:
|
2006-12-24 01:59:06 +03:00
|
|
|
void _LaunchInputServer();
|
2006-08-26 19:13:08 +04:00
|
|
|
void _SetWorkspace(int32 index);
|
2008-03-08 15:45:54 +03:00
|
|
|
void _ShowWindow(Window* window,
|
2005-12-08 15:41:19 +03:00
|
|
|
bool affectsOtherWindows = true);
|
2008-03-08 15:45:54 +03:00
|
|
|
void _HideWindow(Window* window);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
void _UpdateSubsetWorkspaces(Window* window,
|
2006-08-24 01:21:45 +04:00
|
|
|
int32 previousIndex = -1,
|
|
|
|
int32 newIndex = -1);
|
2008-03-08 15:45:54 +03:00
|
|
|
void _ChangeWindowWorkspaces(Window* window,
|
2005-11-30 18:47:01 +03:00
|
|
|
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);
|
2008-03-08 15:45:54 +03:00
|
|
|
void _SendFakeMouseMoved(Window* window = NULL);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2008-03-28 21:59:08 +03:00
|
|
|
void _RebuildClippingForAllWindows(
|
|
|
|
BRegion& stillAvailableOnScreen);
|
|
|
|
void _TriggerWindowRedrawing(
|
|
|
|
BRegion& newDirtyRegion);
|
2005-12-08 15:41:19 +03:00
|
|
|
void _SetBackground(BRegion& background);
|
|
|
|
|
2005-12-09 16:17:43 +03:00
|
|
|
void _UpdateFloating(int32 previousWorkspace = -1,
|
2006-08-24 01:49:59 +04:00
|
|
|
int32 nextWorkspace = -1,
|
2008-03-08 15:45:54 +03:00
|
|
|
Window* mouseEventWindow = NULL);
|
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);
|
2008-03-08 15:45:54 +03:00
|
|
|
bool _WindowHasModal(Window* window);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
void _WindowChanged(Window* window);
|
|
|
|
void _WindowRemoved(Window* window);
|
2005-12-09 19:20:01 +03:00
|
|
|
|
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;
|
2006-08-26 19:13:08 +04:00
|
|
|
friend class LockedDesktopSettings;
|
2005-11-29 02:36:59 +03:00
|
|
|
|
|
|
|
uid_t fUserID;
|
|
|
|
::VirtualScreen fVirtualScreen;
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate* fSettings;
|
2005-11-29 02:36:59 +03:00
|
|
|
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;
|
2008-03-04 15:47:34 +03:00
|
|
|
WindowList fFocusList;
|
2008-03-14 16:21:17 +03:00
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
BObjectList<WorkspacesView> fWorkspacesViews;
|
2008-03-14 16:21:17 +03:00
|
|
|
BLocker fWorkspacesLock;
|
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;
|
|
|
|
|
2008-03-08 15:45:54 +03:00
|
|
|
Window* fMouseEventWindow;
|
|
|
|
const Window* fWindowUnderMouse;
|
2006-03-10 16:03:41 +03:00
|
|
|
int32 fViewUnderMouse;
|
2007-10-02 18:09:11 +04:00
|
|
|
BPoint fLastMousePosition;
|
|
|
|
int32 fLastMouseButtons;
|
2006-03-10 16:03:41 +03:00
|
|
|
|
2008-03-28 21:59:08 +03:00
|
|
|
Window* fFocus;
|
|
|
|
Window* fFront;
|
|
|
|
Window* 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
|