diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index e17c544d91..496ed399b8 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -244,8 +244,10 @@ MouseFilter::Filter(BMessage* message, EventTarget** _target, int32* _viewToken, *_target = &window->EventTarget(); else *_target = NULL; - } else + } else { + fDesktop->SetCursor(NULL); *_target = NULL; + } fDesktop->UnlockAllWindows(); diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index f5a84559ce..9767f2d2ce 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -265,6 +265,22 @@ ServerApp::SendMessageToClient(BMessage *msg) const } +bool +ServerApp::_HasWindowUnderMouse() +{ + BAutolock locker(fWindowListLock); + + for (int32 i = fWindowList.CountItems(); i-- > 0;) { + ServerWindow* window = fWindowList.ItemAt(i); + + if (fDesktop->EventDispatcher().ViewUnderMouse(window->EventTarget()) != B_NULL_TOKEN) + return true; + } + + return false; +} + + /*! \brief Sets the ServerApp's active status \param value The new status of the ServerApp. @@ -283,8 +299,10 @@ ServerApp::Activate(bool value) fIsActive = value; if (fIsActive) { - // Set the cursor to the application cursor, if any - fDesktop->SetCursor(CurrentCursor()); + if (_HasWindowUnderMouse()) { + // Set the cursor to the application cursor, if any + fDesktop->SetCursor(CurrentCursor()); + } fDesktop->HWInterface()->SetCursorVisible(fCursorHideLevel == 0); } } @@ -958,7 +976,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) if (fAppCursor != NULL) fAppCursor->Acquire(); - if (fIsActive) + if (_HasWindowUnderMouse()) fDesktop->SetCursor(CurrentCursor()); if (oldCursor != NULL) diff --git a/src/servers/app/ServerApp.h b/src/servers/app/ServerApp.h index 37f84b46d2..c56d6e372a 100644 --- a/src/servers/app/ServerApp.h +++ b/src/servers/app/ServerApp.h @@ -95,6 +95,8 @@ class ServerApp : public MessageLooper { BPrivate::LinkReceiver& link, port_id& clientReplyPort); + bool _HasWindowUnderMouse(); + port_id fMessagePort; port_id fClientReplyPort; // our BApplication's event port diff --git a/src/servers/app/WindowLayer.cpp b/src/servers/app/WindowLayer.cpp index c936434893..396b406e49 100644 --- a/src/servers/app/WindowLayer.cpp +++ b/src/servers/app/WindowLayer.cpp @@ -987,10 +987,10 @@ WindowLayer::MouseMoved(BMessage *msg, BPoint where, int32* _viewToken, // mouse cursor - if (IsFocus()) { + if (view != NULL) { // TODO: there is more for real cursor support, ie. if a window is closed, // new app cursor shouldn't override view cursor, ... - ServerWindow()->App()->SetCurrentCursor(view != NULL ? view->Cursor() : NULL); + ServerWindow()->App()->SetCurrentCursor(view->Cursor()); } }