diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 1ba7eda1db..f5a84559ce 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -91,6 +91,7 @@ ServerApp::ServerApp(Desktop* desktop, port_id clientReplyPort, fClientTeam(clientTeam), fWindowListLock("window list"), fAppCursor(NULL), + fViewCursor(NULL), fCursorHideLevel(0), fIsActive(false), fSharedMem("shared memory", 32768) @@ -281,17 +282,29 @@ ServerApp::Activate(bool value) fIsActive = value; - if (fIsActive) - SetCursor(); + if (fIsActive) { + // Set the cursor to the application cursor, if any + fDesktop->SetCursor(CurrentCursor()); + fDesktop->HWInterface()->SetCursorVisible(fCursorHideLevel == 0); + } } -//! Sets the cursor to the application cursor, if any. void -ServerApp::SetCursor() +ServerApp::SetCurrentCursor(ServerCursor* cursor) { - fDesktop->SetCursor(fAppCursor); - fDesktop->HWInterface()->SetCursorVisible(fCursorHideLevel == 0); + fViewCursor = cursor; + fDesktop->SetCursor(CurrentCursor()); +} + + +ServerCursor* +ServerApp::CurrentCursor() const +{ + if (fViewCursor != NULL) + return fViewCursor; + + return fAppCursor; } @@ -928,6 +941,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) case AS_SET_CURSOR: { STRACE(("ServerApp %s: SetCursor\n", Signature())); + // Attached data: // 1) bool flag to send a reply // 2) int32 token ID of the cursor to set @@ -941,13 +955,11 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) ServerCursor* oldCursor = fAppCursor; fAppCursor = fDesktop->GetCursorManager().FindCursor(token); - if (fAppCursor != NULL) { + if (fAppCursor != NULL) fAppCursor->Acquire(); - fDesktop->HWInterface()->SetCursor(fAppCursor); - } - // TODO: This is wrong: We need to take view cursors into account here! - fDesktop->SetCursor(fAppCursor); + if (fIsActive) + fDesktop->SetCursor(CurrentCursor()); if (oldCursor != NULL) oldCursor->Release(); @@ -1014,9 +1026,6 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) if (link.Read(&pendingViewCursor) != B_OK) break; - if (fAppCursor && fAppCursor->Token() == token) - fAppCursor = NULL; - ServerCursor* cursor = fDesktop->GetCursorManager().FindCursor(token); if (cursor) { if (pendingViewCursor) diff --git a/src/servers/app/ServerApp.h b/src/servers/app/ServerApp.h index ee07f73851..37f84b46d2 100644 --- a/src/servers/app/ServerApp.h +++ b/src/servers/app/ServerApp.h @@ -61,8 +61,8 @@ class ServerApp : public MessageLooper { void SendMessageToClient(BMessage* message) const; - void SetCursor(); - ServerCursor* Cursor() const { return fAppCursor; } + void SetCurrentCursor(ServerCursor* cursor); + ServerCursor* CurrentCursor() const; team_id ClientTeam() const; const char* Signature() const { return fSignature.String(); } @@ -74,16 +74,16 @@ class ServerApp : public MessageLooper { int32 CountBitmaps() const; ServerBitmap* FindBitmap(int32 token) const; - + int32 CountPictures() const; ServerPicture* CreatePicture(const ServerPicture* original = NULL); ServerPicture* FindPicture(const int32& token) const; bool DeletePicture(const int32& token); - + AreaPool* AppAreaPool() { return &fSharedMem; } - + Desktop* GetDesktop() const { return fDesktop; } - + BPrivate::BTokenSpace& ViewTokens() { return fViewTokens; } private: @@ -123,6 +123,7 @@ class ServerApp : public MessageLooper { BList fPictureList; ServerCursor* fAppCursor; + ServerCursor* fViewCursor; int32 fCursorHideLevel; // 0 = cursor visible diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 4c77fc23ca..3043c6898c 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -590,7 +590,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) } case AS_SEND_BEHIND: { - STRACE(("ServerWindow %s: Message Send_Behind unimplemented\n", Title())); + STRACE(("ServerWindow %s: Message AS_SEND_BEHIND\n", Title())); int32 token; team_id teamID; status_t status; @@ -650,7 +650,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) } case AS_NEEDS_UPDATE: { - STRACE(("ServerWindow %s: Message Needs_Update unimplemented\n", Title())); + STRACE(("ServerWindow %s: Message AS_NEEDS_UPDATE\n", Title())); if (fWindowLayer->NeedsUpdate()) fLink.StartMessage(B_OK); else @@ -1240,7 +1240,9 @@ ServerWindow::_DispatchViewMessage(int32 code, } case AS_LAYER_SET_CURSOR: { - DTRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: ViewLayer: %s - NOT IMPLEMENTED\n", Title(), fCurrentLayer->Name())); + DTRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: ViewLayer: %s\n", Title(), + fCurrentLayer->Name())); + int32 token; if (link.Read(&token) != B_OK) break; @@ -1253,7 +1255,7 @@ ServerWindow::_DispatchViewMessage(int32 code, fDesktop->UnlockSingleWindow(); if (fDesktop->EventDispatcher().ViewUnderMouse(fEventTarget) == fCurrentLayer->Token()) - fDesktop->SetCursor(cursor); + fServerApp->SetCurrentCursor(cursor); fDesktop->LockSingleWindow(); } diff --git a/src/servers/app/WindowLayer.cpp b/src/servers/app/WindowLayer.cpp index 95634bfab1..c936434893 100644 --- a/src/servers/app/WindowLayer.cpp +++ b/src/servers/app/WindowLayer.cpp @@ -990,12 +990,7 @@ WindowLayer::MouseMoved(BMessage *msg, BPoint where, int32* _viewToken, if (IsFocus()) { // TODO: there is more for real cursor support, ie. if a window is closed, // new app cursor shouldn't override view cursor, ... - ServerCursor* cursor = ServerWindow()->App()->Cursor(); - - if (view != NULL && view->Cursor() != NULL) - cursor = view->Cursor(); - - fDesktop->SetCursor(cursor); + ServerWindow()->App()->SetCurrentCursor(view != NULL ? view->Cursor() : NULL); } }