Improved the fake mouse-moved mechanism quite a bit:
* EventDispatcher now adopts the cursor position from the HWInterface upon assignment, so that even the initial cursor reports match the on screen visuals. * The message was never sent because "target" in Desktop::_SendFakeMouseMoved() was never set. * EventDispatcher::SendFakeMouseMoved() now accepts an EventTarget and no longer a BMessenger (fits better to the rest of the API). * EventDispatcher::SendFakeMouseMoved() now sends out the exit transit message to the previous target directly (doesn't wait until the next actual mouse move), and updates the previous target as well, so that scrolling now works in that new window. * This only partially fixes bug #762, though, as GetMouse() can still steal this mouse message (BTextViews do that in WindowActivated()). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18596 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
524c811b5d
commit
5c87242ea3
@ -361,6 +361,13 @@ Desktop::Init()
|
||||
// TODO: temporary workaround, fActiveScreen will be removed
|
||||
fActiveScreen = fVirtualScreen.ScreenAt(0);
|
||||
|
||||
SetCursor(NULL);
|
||||
// this will set the default cursor
|
||||
|
||||
fVirtualScreen.HWInterface()->MoveCursorTo(fVirtualScreen.Frame().Width() / 2,
|
||||
fVirtualScreen.Frame().Height() / 2);
|
||||
fVirtualScreen.HWInterface()->SetCursorVisible(true);
|
||||
|
||||
#if TEST_MODE
|
||||
gInputManager->AddStream(new InputServerStream);
|
||||
#endif
|
||||
@ -370,13 +377,6 @@ Desktop::Init()
|
||||
fEventDispatcher.SetMouseFilter(new MouseFilter(this));
|
||||
fEventDispatcher.SetKeyboardFilter(new KeyboardFilter(this));
|
||||
|
||||
SetCursor(NULL);
|
||||
// this will set the default cursor
|
||||
|
||||
fVirtualScreen.HWInterface()->MoveCursorTo(fVirtualScreen.Frame().Width() / 2,
|
||||
fVirtualScreen.Frame().Height() / 2);
|
||||
fVirtualScreen.HWInterface()->SetCursorVisible(true);
|
||||
|
||||
// draw the background
|
||||
|
||||
fScreenRegion = fVirtualScreen.Frame();
|
||||
@ -1083,7 +1083,7 @@ Desktop::_SendFakeMouseMoved(WindowLayer* window)
|
||||
EventDispatcher().GetMouse(where, buttons);
|
||||
|
||||
int32 viewToken = B_NULL_TOKEN;
|
||||
BMessenger target;
|
||||
EventTarget* target = NULL;
|
||||
|
||||
LockAllWindows();
|
||||
|
||||
@ -1095,6 +1095,9 @@ Desktop::_SendFakeMouseMoved(WindowLayer* window)
|
||||
if (window != NULL) {
|
||||
BMessage message;
|
||||
window->MouseMoved(&message, where, &viewToken, true);
|
||||
|
||||
if (viewToken != B_NULL_TOKEN)
|
||||
target = &window->EventTarget();
|
||||
}
|
||||
|
||||
if (viewToken != B_NULL_TOKEN)
|
||||
@ -1106,8 +1109,8 @@ Desktop::_SendFakeMouseMoved(WindowLayer* window)
|
||||
|
||||
UnlockAllWindows();
|
||||
|
||||
if (viewToken != B_NULL_TOKEN)
|
||||
EventDispatcher().SendFakeMouseMoved(target, viewToken);
|
||||
if (target != NULL)
|
||||
EventDispatcher().SendFakeMouseMoved(*target, viewToken);
|
||||
}
|
||||
|
||||
|
||||
|
@ -486,14 +486,13 @@ EventDispatcher::GetMouse(BPoint& where, int32& buttons)
|
||||
|
||||
|
||||
void
|
||||
EventDispatcher::SendFakeMouseMoved(BMessenger& target, int32 viewToken)
|
||||
EventDispatcher::SendFakeMouseMoved(EventTarget& target, int32 viewToken)
|
||||
{
|
||||
BAutolock _(this);
|
||||
|
||||
BMessage moved(B_MOUSE_MOVED);
|
||||
moved.AddPoint("screen_where", fLastCursorPosition);
|
||||
moved.AddInt32("buttons", fLastButtons);
|
||||
moved.AddInt32("_view_token", viewToken);
|
||||
|
||||
if (fDraggingMessage) {
|
||||
/* moved.AddInt32("_msg_data", );
|
||||
@ -502,7 +501,20 @@ EventDispatcher::SendFakeMouseMoved(BMessenger& target, int32 viewToken)
|
||||
moved.AddMessage("be:drag_message", &fDragMessage);
|
||||
}
|
||||
|
||||
_SendMessage(target, &moved, kMouseTransitImportance);
|
||||
if (fPreviousMouseTarget != NULL
|
||||
&& fPreviousMouseTarget != &target) {
|
||||
_AddTokens(&moved, fPreviousMouseTarget, B_POINTER_EVENTS);
|
||||
_SendMessage(fPreviousMouseTarget->Messenger(), &moved,
|
||||
kMouseTransitImportance);
|
||||
|
||||
_RemoveTokens(&moved);
|
||||
}
|
||||
|
||||
moved.AddInt32("_view_token", viewToken);
|
||||
// this only belongs to the new target
|
||||
|
||||
_SendMessage(target.Messenger(), &moved, kMouseTransitImportance);
|
||||
fPreviousMouseTarget = ⌖
|
||||
}
|
||||
|
||||
|
||||
@ -523,6 +535,10 @@ EventDispatcher::SetHWInterface(HWInterface* interface)
|
||||
BAutolock _(fCursorLock);
|
||||
|
||||
fHWInterface = interface;
|
||||
|
||||
// adopt the cursor position of the new HW interface
|
||||
if (interface != NULL)
|
||||
fLastCursorPosition = interface->CursorPosition();
|
||||
}
|
||||
|
||||
|
||||
|
@ -81,7 +81,7 @@ class EventDispatcher : public BLocker {
|
||||
void SetKeyboardFilter(EventFilter* filter);
|
||||
|
||||
void GetMouse(BPoint& where, int32& buttons);
|
||||
void SendFakeMouseMoved(BMessenger& target, int32 viewToken);
|
||||
void SendFakeMouseMoved(EventTarget& target, int32 viewToken);
|
||||
|
||||
bool HasCursorThread();
|
||||
void SetHWInterface(HWInterface* interface);
|
||||
|
Loading…
Reference in New Issue
Block a user