From 87b1f40c0f241325ebc66f8734e3eb889ac386b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 9 Mar 2006 22:54:10 +0000 Subject: [PATCH] * Fixed misbehaviour of AS_SET_CURSOR: it will no longer set the mouse cursor when it's not over a view of the application. * The application cursor is no longer applied when the mouse cursor is over the border (or tab) of a window. * Gave up and imitate BeOS behaviour: the mouse cursor now always get the shape the view below dictates, ie. it will no longer fall back to the default cursor outside the focus window. * The window is now set to the default in case there is no window under it at all (ie. if Tracker isn't running). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16685 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Desktop.cpp | 4 +++- src/servers/app/ServerApp.cpp | 24 +++++++++++++++++++++--- src/servers/app/ServerApp.h | 2 ++ src/servers/app/WindowLayer.cpp | 4 ++-- 4 files changed, 28 insertions(+), 6 deletions(-) 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()); } }