From 8892026ec7c662f7afe4074a15d50312c25cab3d Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 16 Aug 2017 17:59:24 +0100 Subject: [PATCH] Android: Fixed a bug where getCurrentRawMousePosition() would incorrectly return the mouse position local to the peer that had the last touch event --- .../native/juce_android_Windowing.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/modules/juce_gui_basics/native/juce_android_Windowing.cpp index 9fbe590209..599ec8c3a2 100644 --- a/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -265,20 +265,20 @@ public: setFullScreen (true); } - Point getScreenPosition() const + Point getScreenPosition() const { - return Point (view.callIntMethod (ComponentPeerView.getLeft), - view.callIntMethod (ComponentPeerView.getTop)) / scale; + return Point (view.callIntMethod (ComponentPeerView.getLeft), + view.callIntMethod (ComponentPeerView.getTop)) / scale; } Point localToGlobal (Point relativePosition) override { - return relativePosition + getScreenPosition().toFloat(); + return relativePosition + getScreenPosition(); } Point globalToLocal (Point screenPosition) override { - return screenPosition - getScreenPosition().toFloat(); + return screenPosition - getScreenPosition(); } void setMinimised (bool /*shouldBeMinimised*/) override @@ -407,7 +407,7 @@ public: void handleMouseDownCallback (int index, Point sysPos, int64 time) { Point pos = sysPos / scale; - lastMousePos = pos; + lastMousePos = localToGlobal (pos); // this forces a mouse-enter/up event, in case for some reason we didn't get a mouse-up before. handleMouseEvent (MouseInputSource::InputSourceType::touch, pos, currentModifiers.withoutMouseButtons(), @@ -420,7 +420,7 @@ public: void handleMouseDragCallback (int index, Point pos, int64 time) { pos /= scale; - lastMousePos = pos; + lastMousePos = localToGlobal (pos); jassert (index < 64); touchesDown = (touchesDown | (1 << (index & 63))); @@ -432,7 +432,7 @@ public: void handleMouseUpCallback (int index, Point pos, int64 time) { pos /= scale; - lastMousePos = pos; + lastMousePos = localToGlobal (pos); jassert (index < 64); touchesDown = (touchesDown & ~(1 << (index & 63)));