From 84b62fccc086cec3c3ac33d8cdd075234e863547 Mon Sep 17 00:00:00 2001 From: Adi Oanca Date: Thu, 20 Jan 2005 18:39:08 +0000 Subject: [PATCH] * closing a window no longer takes you to debugger * send mouse_[move/up/weel] only if the cursor is inside a window(not above decorator) * added WinBorder::MouseWheel() git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10912 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/server/RootLayer.cpp | 39 +++++----------------------- src/servers/app/server/WinBorder.cpp | 37 +++++++++++++++++++++++++- src/servers/app/server/WinBorder.h | 1 + 3 files changed, 44 insertions(+), 33 deletions(-) diff --git a/src/servers/app/server/RootLayer.cpp b/src/servers/app/server/RootLayer.cpp index 6268f25d3e..658702cc2f 100644 --- a/src/servers/app/server/RootLayer.cpp +++ b/src/servers/app/server/RootLayer.cpp @@ -941,15 +941,10 @@ void RootLayer::MouseEventHandler(int32 code, BPortLink& msg) fMouseTarget->Window()->Lock(); fMouseTarget->MouseUp(evt); - - BMessage upmsg(B_MOUSE_UP); - upmsg.AddInt64("when",evt.when); - upmsg.AddPoint("where",evt.where); - upmsg.AddInt32("modifiers",evt.modifiers); - - fMouseTarget->Window()->SendMessageToClient(&upmsg); fMouseTarget->Window()->Unlock(); + fMouseTarget=NULL; + STRACE(("MOUSE UP: at (%f, %f)\n", evt.where.x, evt.where.y)); break; @@ -981,13 +976,6 @@ void RootLayer::MouseEventHandler(int32 code, BPortLink& msg) fMouseTarget->Window()->Lock(); fMouseTarget->MouseMoved(evt); - - BMessage movemsg(B_MOUSE_MOVED); - movemsg.AddInt64("when",evt.when); - movemsg.AddPoint("where",evt.where); - movemsg.AddInt32("buttons",evt.buttons); - - fMouseTarget->Window()->SendMessageToClient(&movemsg); fMouseTarget->Window()->Unlock(); break; @@ -1003,24 +991,11 @@ void RootLayer::MouseEventHandler(int32 code, BPortLink& msg) msg.Read(&evt.when); msg.Read(&evt.wheel_delta_x); msg.Read(&evt.wheel_delta_y); - - BMessage wheelmsg(B_MOUSE_WHEEL_CHANGED); - wheelmsg.AddInt64("when",evt.when); - wheelmsg.AddFloat("be:wheel_delta_x",evt.wheel_delta_x); - wheelmsg.AddFloat("be:wheel_delta_y",evt.wheel_delta_y); - - if(!fMouseTarget) - { - fMouseTarget = WinBorderAt(GetDisplayDriver()->GetCursorPosition()); - - // We do nothing because there ain't a window to receive the message - if(!fMouseTarget) - break; - } - - fMouseTarget->Window()->Lock(); - fMouseTarget->Window()->SendMessageToClient(&wheelmsg); - fMouseTarget->Window()->Unlock(); + + WinBorder *target; + BPoint cursorPos = GetDisplayDriver()->GetCursorPosition(); + if ((target = WinBorderAt(cursorPos))) + target->MouseWheel(evt, cursorPos); break; } diff --git a/src/servers/app/server/WinBorder.cpp b/src/servers/app/server/WinBorder.cpp index 3ffbf13a13..27635441b4 100644 --- a/src/servers/app/server/WinBorder.cpp +++ b/src/servers/app/server/WinBorder.cpp @@ -287,7 +287,17 @@ void WinBorder::MouseMoved(PointerEvent& evt) fDecorator->DrawMinimize(); } } - + + if (fTopLayer->fFullVisible.Contains(evt.where)) + { + BMessage movemsg(B_MOUSE_MOVED); + movemsg.AddInt64("when",evt.when); + movemsg.AddPoint("where",evt.where); + movemsg.AddInt32("buttons",evt.buttons); + + Window()->SendMessageToClient(&movemsg); + } + fLastMousePosition = evt.where; } @@ -349,6 +359,31 @@ void WinBorder::MouseUp(PointerEvent& evt) Window()->Minimize(true); return; } + + if (fTopLayer->fFullVisible.Contains(evt.where)) + { + BMessage upmsg(B_MOUSE_UP); + upmsg.AddInt64("when",evt.when); + upmsg.AddPoint("where",evt.where); + upmsg.AddInt32("modifiers",evt.modifiers); + + Window()->SendMessageToClient(&upmsg); + } +} + +void WinBorder::MouseWheel(PointerEvent& evt, BPoint& ptWhere) +{ + if (fTopLayer->fFullVisible.Contains(ptWhere)) + { + BMessage wheelmsg(B_MOUSE_WHEEL_CHANGED); + wheelmsg.AddInt64("when",evt.when); + wheelmsg.AddFloat("be:wheel_delta_x",evt.wheel_delta_x); + wheelmsg.AddFloat("be:wheel_delta_y",evt.wheel_delta_y); + + Window()->Lock(); + Window()->SendMessageToClient(&wheelmsg); + Window()->Unlock(); + } } //! Sets the decorator focus to active or inactive colors diff --git a/src/servers/app/server/WinBorder.h b/src/servers/app/server/WinBorder.h index 5c1c707ea2..f9aea1a92c 100644 --- a/src/servers/app/server/WinBorder.h +++ b/src/servers/app/server/WinBorder.h @@ -75,6 +75,7 @@ public: void MouseDown(PointerEvent& evt, bool sendMessage); void MouseMoved(PointerEvent& evt); void MouseUp(PointerEvent& evt); + void MouseWheel(PointerEvent& evt, BPoint& ptWhere); void UpdateColors(void); void UpdateDecorator(void);