Moved the ViewUnderMouse() functionality from the EventDispatcher to the Desktop;
this saves us some locking headaches and solves a possible deadlock in ServerApp::Activate(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16688 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -240,11 +240,15 @@ MouseFilter::Filter(BMessage* message, EventTarget** _target, int32* _viewToken,
|
||||
break;
|
||||
}
|
||||
|
||||
if (*_viewToken != B_NULL_TOKEN)
|
||||
if (*_viewToken != B_NULL_TOKEN) {
|
||||
fDesktop->SetViewUnderMouse(window, *_viewToken);
|
||||
*_target = &window->EventTarget();
|
||||
else
|
||||
} else {
|
||||
fDesktop->SetViewUnderMouse(NULL, B_NULL_TOKEN);
|
||||
*_target = NULL;
|
||||
}
|
||||
} else {
|
||||
fDesktop->SetViewUnderMouse(NULL, B_NULL_TOKEN);
|
||||
fDesktop->SetCursor(NULL);
|
||||
*_target = NULL;
|
||||
}
|
||||
@@ -1756,6 +1760,24 @@ Desktop::SetMouseEventWindow(WindowLayer* window)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Desktop::SetViewUnderMouse(const WindowLayer* window, int32 viewToken)
|
||||
{
|
||||
fWindowUnderMouse = window;
|
||||
fViewUnderMouse = viewToken;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
Desktop::ViewUnderMouse(const WindowLayer* window)
|
||||
{
|
||||
if (fWindowUnderMouse == window)
|
||||
return fViewUnderMouse;
|
||||
|
||||
return B_NULL_TOKEN;
|
||||
}
|
||||
|
||||
|
||||
WindowLayer *
|
||||
Desktop::FindWindowLayerByClientToken(int32 token, team_id teamID)
|
||||
{
|
||||
|
||||
@@ -134,6 +134,9 @@ class Desktop : public MessageLooper, public ScreenOwner {
|
||||
WindowLayer* MouseEventWindow() const { return fMouseEventWindow; }
|
||||
void SetMouseEventWindow(WindowLayer* window);
|
||||
|
||||
void SetViewUnderMouse(const WindowLayer* window, int32 viewToken);
|
||||
int32 ViewUnderMouse(const WindowLayer* window);
|
||||
|
||||
void SetFocusWindow(WindowLayer* window);
|
||||
|
||||
WindowLayer* FindWindowLayerByClientToken(int32 token, team_id teamID);
|
||||
@@ -241,6 +244,9 @@ class Desktop : public MessageLooper, public ScreenOwner {
|
||||
bool fFocusFollowsMouse;
|
||||
|
||||
WindowLayer* fMouseEventWindow;
|
||||
const WindowLayer* fWindowUnderMouse;
|
||||
int32 fViewUnderMouse;
|
||||
|
||||
WindowLayer* fFocus;
|
||||
WindowLayer* fFront;
|
||||
WindowLayer* fBack;
|
||||
|
||||
@@ -219,7 +219,6 @@ EventDispatcher::EventDispatcher()
|
||||
fThread(-1),
|
||||
fCursorThread(-1),
|
||||
fPreviousMouseTarget(NULL),
|
||||
fPreviousViewToken(B_NULL_TOKEN),
|
||||
fFocus(NULL),
|
||||
fSuspendFocus(false),
|
||||
fMouseFilter(NULL),
|
||||
@@ -507,24 +506,11 @@ EventDispatcher::SetHWInterface(HWInterface* interface)
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
EventDispatcher::ViewUnderMouse(EventTarget& target)
|
||||
{
|
||||
BAutolock _(this);
|
||||
|
||||
if (&target == fPreviousMouseTarget)
|
||||
return fPreviousViewToken;
|
||||
|
||||
return B_NULL_TOKEN;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EventDispatcher::SetDragMessage(BMessage& message,
|
||||
ServerBitmap* bitmap,
|
||||
const BPoint& offsetFromCursor)
|
||||
ServerBitmap* bitmap, const BPoint& offsetFromCursor)
|
||||
{
|
||||
// printf("EventDispatcher::SetDragMessage()\n");
|
||||
ETRACE(("EventDispatcher::SetDragMessage()\n"));
|
||||
|
||||
if (fDragBitmap != bitmap) {
|
||||
if (fDragBitmap)
|
||||
@@ -541,10 +527,10 @@ EventDispatcher::SetDragMessage(BMessage& message,
|
||||
BAutolock _(this);
|
||||
|
||||
fDragMessage = message;
|
||||
|
||||
fDraggingMessage = true;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - Message methods
|
||||
|
||||
|
||||
@@ -641,9 +627,9 @@ EventDispatcher::_UnsetFeedFocus(BMessage* message)
|
||||
void
|
||||
EventDispatcher::_DeliverDragMessage()
|
||||
{
|
||||
// printf("EventDispatcher::_DeliverDragMessage()\n");
|
||||
ETRACE(("EventDispatcher::_DeliverDragMessage()\n"));
|
||||
|
||||
if (fDraggingMessage && fPreviousMouseTarget) {
|
||||
if (fDraggingMessage && fPreviousMouseTarget != NULL) {
|
||||
fDragMessage.RemoveName("_original_what");
|
||||
fDragMessage.AddInt32("_original_what", fDragMessage.what);
|
||||
fDragMessage.what = _MESSAGE_DROPPED_;
|
||||
@@ -777,7 +763,6 @@ EventDispatcher::_EventLoop()
|
||||
}
|
||||
|
||||
current = fPreviousMouseTarget = mouseTarget;
|
||||
fPreviousViewToken = viewToken;
|
||||
|
||||
if (current != NULL) {
|
||||
int32 focusView = viewToken;
|
||||
|
||||
@@ -85,8 +85,6 @@ class EventDispatcher : public BLocker {
|
||||
bool HasCursorThread();
|
||||
void SetHWInterface(HWInterface* interface);
|
||||
|
||||
int32 ViewUnderMouse(EventTarget& target);
|
||||
|
||||
void SetDragMessage(BMessage& message, ServerBitmap* bitmap,
|
||||
const BPoint& offsetFromCursor);
|
||||
// the message should be delivered on the next
|
||||
@@ -127,7 +125,6 @@ class EventDispatcher : public BLocker {
|
||||
thread_id fCursorThread;
|
||||
|
||||
EventTarget* fPreviousMouseTarget;
|
||||
int32 fPreviousViewToken;
|
||||
EventTarget* fFocus;
|
||||
bool fSuspendFocus;
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ ServerApp::_HasWindowUnderMouse()
|
||||
for (int32 i = fWindowList.CountItems(); i-- > 0;) {
|
||||
ServerWindow* window = fWindowList.ItemAt(i);
|
||||
|
||||
if (fDesktop->EventDispatcher().ViewUnderMouse(window->EventTarget()) != B_NULL_TOKEN)
|
||||
if (fDesktop->ViewUnderMouse(window->Window()) != B_NULL_TOKEN)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1246,12 +1246,8 @@ ServerWindow::_DispatchViewMessage(int32 code,
|
||||
|
||||
if (fWindowLayer->IsFocus()) {
|
||||
// The cursor might need to be updated now
|
||||
fDesktop->UnlockSingleWindow();
|
||||
|
||||
if (fDesktop->EventDispatcher().ViewUnderMouse(fEventTarget) == fCurrentLayer->Token())
|
||||
if (fDesktop->ViewUnderMouse(fWindowLayer) == fCurrentLayer->Token())
|
||||
fServerApp->SetCurrentCursor(cursor);
|
||||
|
||||
fDesktop->LockSingleWindow();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user