Removed global gDesktop variable - there is now an sDesktop variable in AppServer.cpp, but

that will go away, too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14590 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-10-31 11:05:52 +00:00
parent 3ab795e374
commit 959a5a68bc
11 changed files with 57 additions and 53 deletions
+18 -18
View File
@@ -64,7 +64,7 @@
// Globals // Globals
Desktop *gDesktop; static Desktop *sDesktop;
port_id gAppServerPort; port_id gAppServerPort;
@@ -163,9 +163,9 @@ AppServer::AppServer()
gBitmapManager = new BitmapManager(); gBitmapManager = new BitmapManager();
// Set up the Desktop // Set up the Desktop
gDesktop = new Desktop(); sDesktop = new Desktop();
gDesktop->Init(); sDesktop->Init();
gDesktop->Run(); sDesktop->Run();
#if 0 #if 0
LaunchCursorThread(); LaunchCursorThread();
@@ -275,7 +275,7 @@ AppServer::CursorThread(void* data)
p.y = *server->fCursorAddr & 0x7fff; p.y = *server->fCursorAddr & 0x7fff;
p.x = *server->fCursorAddr >> 15 & 0x7fff; p.x = *server->fCursorAddr >> 15 & 0x7fff;
gDesktop->GetHWInterface()->MoveCursorTo(p.x, p.y); sDesktop->GetHWInterface()->MoveCursorTo(p.x, p.y);
STRACE(("CursorThread : %f, %f\n", p.x, p.y)); STRACE(("CursorThread : %f, %f\n", p.x, p.y));
} }
@@ -318,7 +318,7 @@ AppServer::_DispatchMessage(int32 code, BPrivate::LinkReceiver& msg)
BPrivate::LinkSender reply(replyPort); BPrivate::LinkSender reply(replyPort);
reply.StartMessage(B_OK); reply.StartMessage(B_OK);
reply.Attach<port_id>(gDesktop->MessagePort()); reply.Attach<port_id>(sDesktop->MessagePort());
reply.Flush(); reply.Flush();
break; break;
} }
@@ -350,13 +350,13 @@ AppServer::_DispatchMessage(int32 code, BPrivate::LinkReceiver& msg)
#if TEST_MODE #if TEST_MODE
case B_QUIT_REQUESTED: case B_QUIT_REQUESTED:
{ {
thread_id thread = gDesktop->Thread(); thread_id thread = sDesktop->Thread();
// We've been asked to quit, so (for now) broadcast to all // We've been asked to quit, so (for now) broadcast to all
// test apps to quit. This situation will occur only when the server // test apps to quit. This situation will occur only when the server
// is compiled as a regular Be application. // is compiled as a regular Be application.
gDesktop->PostMessage(B_QUIT_REQUESTED); sDesktop->PostMessage(B_QUIT_REQUESTED);
fQuitting = true; fQuitting = true;
// we just wait for the desktop to kill itself // we just wait for the desktop to kill itself
@@ -374,7 +374,7 @@ AppServer::_DispatchMessage(int32 code, BPrivate::LinkReceiver& msg)
case AS_SET_SYSCURSOR_DEFAULTS: case AS_SET_SYSCURSOR_DEFAULTS:
{ {
gDesktop->GetCursorManager().SetDefaults(); sDesktop->GetCursorManager().SetDefaults();
break; break;
} }
@@ -399,30 +399,30 @@ AppServer::_DispatchMessage(int32 code, BPrivate::LinkReceiver& msg)
// activate one of the app's windows. // activate one of the app's windows.
if (error == B_OK) { if (error == B_OK) {
error = B_BAD_TEAM_ID; error = B_BAD_TEAM_ID;
if (gDesktop->Lock()) { if (sDesktop->Lock()) {
// search for an unhidden window to give focus to // search for an unhidden window to give focus to
int32 windowCount = gDesktop->WindowList().CountItems(); int32 windowCount = sDesktop->WindowList().CountItems();
Layer *layer; Layer *layer;
for (int32 i = 0; i < windowCount; ++i) for (int32 i = 0; i < windowCount; ++i)
// is this layer in fact a WinBorder? // is this layer in fact a WinBorder?
if ((layer = static_cast<Layer*>(gDesktop->WindowList().ItemAtFast(i)))) { if ((layer = static_cast<Layer*>(sDesktop->WindowList().ItemAtFast(i)))) {
WinBorder *winBorder = dynamic_cast<WinBorder*>(layer); WinBorder *winBorder = dynamic_cast<WinBorder*>(layer);
// if winBorder is valid and not hidden, then we've found our target // if winBorder is valid and not hidden, then we've found our target
if (winBorder && !winBorder->IsHidden() if (winBorder && !winBorder->IsHidden()
&& winBorder->App()->ClientTeam() == team) { && winBorder->App()->ClientTeam() == team) {
if (gDesktop->ActiveRootLayer() if (sDesktop->ActiveRootLayer()
&& gDesktop->ActiveRootLayer()->Lock()) { && sDesktop->ActiveRootLayer()->Lock()) {
gDesktop->ActiveRootLayer()->SetActive(winBorder); sDesktop->ActiveRootLayer()->SetActive(winBorder);
gDesktop->ActiveRootLayer()->Unlock(); sDesktop->ActiveRootLayer()->Unlock();
if (gDesktop->ActiveRootLayer()->Active() == winBorder) if (sDesktop->ActiveRootLayer()->Active() == winBorder)
error = B_OK; error = B_OK;
else else
error = B_ERROR; error = B_ERROR;
} }
} }
} }
gDesktop->Unlock(); sDesktop->Unlock();
} }
} }
-2
View File
@@ -116,6 +116,4 @@ class Desktop : public MessageLooper, public ScreenOwner {
CursorManager fCursorManager; CursorManager fCursorManager;
}; };
extern Desktop *gDesktop;
#endif // _DESKTOP_H_ #endif // _DESKTOP_H_
+4 -5
View File
@@ -964,10 +964,10 @@ RootLayer::_ProcessMouseMovedEvent(BMessage *msg)
// change focus in FFM mode // change focus in FFM mode
WinBorder* winBorderTarget = dynamic_cast<WinBorder*>(target); WinBorder* winBorderTarget = dynamic_cast<WinBorder*>(target);
if (winBorderTarget) { if (winBorderTarget) {
DesktopSettings ds(gDesktop); DesktopSettings desktopSettings(fDesktop);
// TODO: Focus should be a RootLayer option/feature, NOT a Workspace one!!! // TODO: Focus should be a RootLayer option/feature, NOT a Workspace one!!!
WinBorder* exFocus = Focus(); WinBorder* exFocus = Focus();
if (ds.MouseMode() != B_NORMAL_MOUSE && exFocus != winBorderTarget) { if (desktopSettings.MouseMode() != B_NORMAL_MOUSE && exFocus != winBorderTarget) {
ActiveWorkspace()->AttemptToSetFocus(winBorderTarget); ActiveWorkspace()->AttemptToSetFocus(winBorderTarget);
// Workspace::SetFocus() *attempts* to set a new focus WinBorder, it may not succeed // Workspace::SetFocus() *attempts* to set a new focus WinBorder, it may not succeed
if (exFocus != Focus()) { if (exFocus != Focus()) {
@@ -1544,10 +1544,9 @@ RootLayer::change_winBorder_feel(WinBorder *winBorder, int32 newFeel)
} }
} }
gDesktop->SetWinBorderFeel(winBorder, newFeel); fDesktop->SetWinBorderFeel(winBorder, newFeel);
if (isVisible) if (isVisible) {
{
// just show, don't invalidate // just show, don't invalidate
winBorder->Show(false); winBorder->Show(false);
// all workspaces must be up-to-date with this change of feel. // all workspaces must be up-to-date with this change of feel.
+6 -5
View File
@@ -70,11 +70,12 @@ public:
Desktop *desktop, DisplayDriver *driver); Desktop *desktop, DisplayDriver *driver);
virtual ~RootLayer(void); virtual ~RootLayer(void);
Desktop* GetDesktop() const { return fDesktop; }
virtual void MoveBy(float x, float y); virtual void MoveBy(float x, float y);
virtual void ResizeBy(float x, float y); virtual void ResizeBy(float x, float y);
virtual void ScrollBy(float x, float y) virtual void ScrollBy(float x, float y)
{ // not allowed { /* not allowed */ }
}
// For the active workspaces // For the active workspaces
virtual Layer* FirstChild() const; virtual Layer* FirstChild() const;
@@ -85,8 +86,7 @@ public:
void HideWinBorder(WinBorder* winBorder); void HideWinBorder(WinBorder* winBorder);
void ShowWinBorder(WinBorder* winBorder); void ShowWinBorder(WinBorder* winBorder);
void SetWinBorderWorskpaces(WinBorder *winBorder, void SetWinBorderWorskpaces(WinBorder *winBorder,
uint32 oldIndex, uint32 oldIndex, uint32 newIndex);
uint32 newIndex);
void RevealNewWMState(Workspace::State &oldWMState); void RevealNewWMState(Workspace::State &oldWMState);
// TODO: we need to replace Winborder* with Layer* // TODO: we need to replace Winborder* with Layer*
@@ -117,7 +117,8 @@ public:
void SetDragMessage(BMessage *msg); void SetDragMessage(BMessage *msg);
BMessage* DragMessage(void) const; BMessage* DragMessage(void) const;
bool AddToInputNotificationLists(Layer *lay, uint32 mask, uint32 options); bool AddToInputNotificationLists(Layer *lay, uint32 mask,
uint32 options);
bool SetNotifyLayer(Layer *lay, uint32 mask, uint32 options); bool SetNotifyLayer(Layer *lay, uint32 mask, uint32 options);
void ClearNotifyLayer(); void ClearNotifyLayer();
+1 -1
View File
@@ -8,7 +8,7 @@
* Stephan Aßmus <[email protected]> * Stephan Aßmus <[email protected]>
* Stefano Ceccherini ([email protected]) * Stefano Ceccherini ([email protected])
* Axel Dörfler, [email protected] * Axel Dörfler, [email protected]
* Jérôme Duval, [email protected] * Jérôme Duval, [email protected]
*/ */
/*! /*!
+2
View File
@@ -70,6 +70,8 @@ class ServerApp : public MessageLooper {
AreaPool *AppAreaPool() { return &fSharedMem; } AreaPool *AppAreaPool() { return &fSharedMem; }
Desktop* GetDesktop() const { return fDesktop; }
// ToDo: public? // ToDo: public?
SubWindowList fAppSubWindowList; SubWindowList fAppSubWindowList;
+14 -13
View File
@@ -132,6 +132,7 @@ ServerWindow::ServerWindow(const char *title, ServerApp *app,
port_id clientPort, port_id looperPort, int32 handlerID) port_id clientPort, port_id looperPort, int32 handlerID)
: MessageLooper(title && *title ? title : "Unnamed Window"), : MessageLooper(title && *title ? title : "Unnamed Window"),
fTitle(title), fTitle(title),
fDesktop(app->GetDesktop()),
fServerApp(app), fServerApp(app),
fWinBorder(NULL), fWinBorder(NULL),
fClientTeam(app->ClientTeam()), fClientTeam(app->ClientTeam()),
@@ -155,7 +156,7 @@ ServerWindow::~ServerWindow()
STRACE(("*ServerWindow(%s@%p):~ServerWindow()\n", fTitle, this)); STRACE(("*ServerWindow(%s@%p):~ServerWindow()\n", fTitle, this));
if (!fWinBorder->IsOffscreenWindow()) if (!fWinBorder->IsOffscreenWindow())
gDesktop->RemoveWinBorder(fWinBorder); fDesktop->RemoveWinBorder(fWinBorder);
delete fWinBorder; delete fWinBorder;
@@ -191,7 +192,7 @@ ServerWindow::Init(BRect frame, uint32 look, uint32 feel, uint32 flags, uint32 w
return B_NO_MEMORY; return B_NO_MEMORY;
if (!fWinBorder->IsOffscreenWindow()) if (!fWinBorder->IsOffscreenWindow())
gDesktop->AddWinBorder(fWinBorder); fDesktop->AddWinBorder(fWinBorder);
return B_OK; return B_OK;
} }
@@ -487,7 +488,7 @@ ServerWindow::CreateLayerTree(BPrivate::LinkReceiver &link, Layer **_parent)
flags, fWinBorder->GetDisplayDriver()); flags, fWinBorder->GetDisplayDriver());
} else { } else {
newLayer = new Layer(frame, name, token, resizeMask, newLayer = new Layer(frame, name, token, resizeMask,
flags, gDesktop->GetDisplayDriver()); flags, fDesktop->GetDisplayDriver());
} }
free(name); free(name);
@@ -1273,13 +1274,13 @@ myRootLayer->Unlock();
STRACE(("ServerWindow %s: Message Send_Behind unimplemented\n", Title())); STRACE(("ServerWindow %s: Message Send_Behind unimplemented\n", Title()));
int32 token; int32 token;
team_id teamID; team_id teamID;
WinBorder *behindOf;
status_t status = B_NAME_NOT_FOUND; status_t status = B_NAME_NOT_FOUND;
link.Read<int32>(&token); link.Read<int32>(&token);
link.Read<team_id>(&teamID); link.Read<team_id>(&teamID);
if ((behindOf = gDesktop->FindWinBorderByClientToken(token, teamID))) { WinBorder *behindOf;
if ((behindOf = fDesktop->FindWinBorderByClientToken(token, teamID)) != NULL) {
fWinBorder->GetRootLayer()->Lock(); fWinBorder->GetRootLayer()->Lock();
// TODO: move to back ATM. Fix this later! // TODO: move to back ATM. Fix this later!
fWinBorder->GetRootLayer()->SetActive(fWinBorder, false); fWinBorder->GetRootLayer()->SetActive(fWinBorder, false);
@@ -1337,13 +1338,13 @@ myRootLayer->Unlock();
link.Read<int32>(&mainToken); link.Read<int32>(&mainToken);
link.Read(&teamID, sizeof(team_id)); link.Read(&teamID, sizeof(team_id));
windowBorder = gDesktop->FindWinBorderByClientToken(mainToken, teamID); windowBorder = fDesktop->FindWinBorderByClientToken(mainToken, teamID);
if (windowBorder) { if (windowBorder) {
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Flush(); fLink.Flush();
fWinBorder->GetRootLayer()->Lock(); fWinBorder->GetRootLayer()->Lock();
gDesktop->AddWinBorderToSubset(fWinBorder, windowBorder); fDesktop->AddWinBorderToSubset(fWinBorder, windowBorder);
fWinBorder->GetRootLayer()->Unlock(); fWinBorder->GetRootLayer()->Unlock();
} else { } else {
fLink.StartMessage(SERVER_FALSE); fLink.StartMessage(SERVER_FALSE);
@@ -1361,13 +1362,13 @@ myRootLayer->Unlock();
link.Read<int32>(&mainToken); link.Read<int32>(&mainToken);
link.Read(&teamID, sizeof(team_id)); link.Read(&teamID, sizeof(team_id));
windowBorder = gDesktop->FindWinBorderByClientToken(mainToken, teamID); windowBorder = fDesktop->FindWinBorderByClientToken(mainToken, teamID);
if (windowBorder) { if (windowBorder) {
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Flush(); fLink.Flush();
fWinBorder->GetRootLayer()->Lock(); fWinBorder->GetRootLayer()->Lock();
gDesktop->RemoveWinBorderFromSubset(fWinBorder, windowBorder); fDesktop->RemoveWinBorderFromSubset(fWinBorder, windowBorder);
fWinBorder->GetRootLayer()->Unlock(); fWinBorder->GetRootLayer()->Unlock();
} else { } else {
fLink.StartMessage(SERVER_FALSE); fLink.StartMessage(SERVER_FALSE);
@@ -1641,8 +1642,8 @@ myRootLayer->Unlock();
// 1) BPoint mouse location // 1) BPoint mouse location
// 2) int32 button state // 2) int32 button state
fLink.Attach<BPoint>(gDesktop->GetHWInterface()->GetCursorPosition()); fLink.Attach<BPoint>(fDesktop->GetHWInterface()->GetCursorPosition());
fLink.Attach<int32>(gDesktop->ActiveRootLayer()->Buttons()); fLink.Attach<int32>(fDesktop->ActiveRootLayer()->Buttons());
fLink.Flush(); fLink.Flush();
break; break;
@@ -2384,7 +2385,7 @@ ServerWindow::MakeWinBorder(BRect frame, const char* name,
{ {
// The non-offscreen ServerWindow uses the DisplayDriver instance from the desktop. // The non-offscreen ServerWindow uses the DisplayDriver instance from the desktop.
return new(nothrow) WinBorder(frame, name, look, feel, flags, return new(nothrow) WinBorder(frame, name, look, feel, flags,
workspace, this, gDesktop->GetDisplayDriver()); workspace, this, fDesktop->GetDisplayDriver());
} }
@@ -2418,7 +2419,7 @@ ServerWindow::_HandleDirectConnection(direct_buffer_state state)
if ((state & B_DIRECT_MODE_MASK) != B_DIRECT_STOP) { if ((state & B_DIRECT_MODE_MASK) != B_DIRECT_STOP) {
// TODO: Locking ? // TODO: Locking ?
RenderingBuffer *buffer = gDesktop->GetHWInterface()->FrontBuffer(); RenderingBuffer *buffer = fDesktop->GetHWInterface()->FrontBuffer();
fDirectWindowData->direct_info->bits = buffer->Bits(); fDirectWindowData->direct_info->bits = buffer->Bits();
fDirectWindowData->direct_info->pci_bits = NULL; // TODO fDirectWindowData->direct_info->pci_bits = NULL; // TODO
fDirectWindowData->direct_info->bytes_per_row = buffer->BytesPerRow(); fDirectWindowData->direct_info->bytes_per_row = buffer->BytesPerRow();
+2
View File
@@ -32,6 +32,7 @@ class BMessenger;
class BPoint; class BPoint;
class BMessage; class BMessage;
class Desktop;
class ServerApp; class ServerApp;
class Decorator; class Decorator;
class WinBorder; class WinBorder;
@@ -129,6 +130,7 @@ private:
private: private:
const char* fTitle; const char* fTitle;
Desktop* fDesktop;
ServerApp* fServerApp; ServerApp* fServerApp;
WinBorder* fWinBorder; WinBorder* fWinBorder;
+4 -3
View File
@@ -125,7 +125,7 @@ WinBorder::WinBorder(const BRect &frame,
uint16 width, height; uint16 width, height;
uint32 colorSpace; uint32 colorSpace;
float frequency; float frequency;
gDesktop->ActiveScreen()->GetMode(width, height, colorSpace, frequency); GetRootLayer()->GetDesktop()->ScreenAt(0)->GetMode(width, height, colorSpace, frequency);
_ResizeBy(width - frame.Width(), height - frame.Height()); _ResizeBy(width - frame.Width(), height - frame.Height());
} else } else
_ResizeBy(0, 0); _ResizeBy(0, 0);
@@ -428,7 +428,7 @@ WinBorder::SetSizeLimits(float minWidth, float maxWidth,
ResizeBy(xDiff, yDiff); ResizeBy(xDiff, yDiff);
} }
// GetSizeLimits
void void
WinBorder::GetSizeLimits(float* minWidth, float* maxWidth, WinBorder::GetSizeLimits(float* minWidth, float* maxWidth,
float* minHeight, float* maxHeight) const float* minHeight, float* maxHeight) const
@@ -439,10 +439,11 @@ WinBorder::GetSizeLimits(float* minWidth, float* maxWidth,
*maxHeight = fMaxHeight; *maxHeight = fMaxHeight;
} }
void void
WinBorder::MouseDown(const BMessage *msg) WinBorder::MouseDown(const BMessage *msg)
{ {
DesktopSettings desktopSettings(gDesktop); DesktopSettings desktopSettings(GetRootLayer()->GetDesktop());
BPoint where(0,0); BPoint where(0,0);
msg->FindPoint("where", &where); msg->FindPoint("where", &where);
+1 -1
View File
@@ -178,7 +178,7 @@ WorkspacesLayer::_DrawWorkspace(int32 index)
uint16 width, height; uint16 width, height;
uint32 colorSpace; uint32 colorSpace;
float frequency; float frequency;
gDesktop->ScreenAt(0)->GetMode(width, height, colorSpace, frequency); GetRootLayer()->GetDesktop()->ScreenAt(0)->GetMode(width, height, colorSpace, frequency);
BRect screenFrame(0, 0, width - 1, height - 1); BRect screenFrame(0, 0, width - 1, height - 1);
BRegion workspaceRegion(rect); BRegion workspaceRegion(rect);
@@ -71,7 +71,7 @@ class FontLocker {
}; };
// pragma mark - // #pragma mark -
// constructor // constructor