diff --git a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp index 7ca6f099a6..3717e06678 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp @@ -84,13 +84,17 @@ public: return nullptr; } - Point getScreenPosition() const + Point getScreenPosition() const noexcept { // This needs to return the live position if possible, but it mustn't update the lastScreenPos // value, because that can cause continuity problems. - return ScalingHelpers::unscaledScreenPosToScaled - (unboundedMouseOffset + (inputType != MouseInputSource::InputSourceType::touch ? MouseInputSource::getCurrentRawMousePosition() - : lastScreenPos)); + return ScalingHelpers::unscaledScreenPosToScaled (getRawScreenPosition()); + } + + Point getRawScreenPosition() const noexcept + { + return unboundedMouseOffset + (inputType != MouseInputSource::InputSourceType::touch ? MouseInputSource::getCurrentRawMousePosition() + : lastScreenPos); } void setScreenPosition (Point p) @@ -578,6 +582,7 @@ bool MouseInputSource::hasMouseWheel() const noexcept int MouseInputSource::getIndex() const noexcept { return pimpl->index; } bool MouseInputSource::isDragging() const noexcept { return pimpl->isDragging(); } Point MouseInputSource::getScreenPosition() const noexcept { return pimpl->getScreenPosition(); } +Point MouseInputSource::getRawScreenPosition() const noexcept { return pimpl->getRawScreenPosition(); } ModifierKeys MouseInputSource::getCurrentModifiers() const noexcept { return pimpl->getCurrentModifiers(); } float MouseInputSource::getCurrentPressure() const noexcept { return pimpl->pressure; } bool MouseInputSource::isPressureValid() const noexcept { return pimpl->isPressureValid(); } @@ -730,7 +735,7 @@ struct MouseInputSource::SourceList : public Timer // because on some OSes the queue can get overloaded with messages so that mouse-events don't get through.. if (s->isDragging() && ModifierKeys::getCurrentModifiersRealtime().isAnyMouseButtonDown()) { - s->lastScreenPos = s->getScreenPosition(); + s->lastScreenPos = s->getRawScreenPosition(); s->triggerFakeMove(); anyDragging = true; } diff --git a/modules/juce_gui_basics/mouse/juce_MouseInputSource.h b/modules/juce_gui_basics/mouse/juce_MouseInputSource.h index e99c4565c1..3a8d51ad2b 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInputSource.h +++ b/modules/juce_gui_basics/mouse/juce_MouseInputSource.h @@ -105,6 +105,9 @@ public: /** Returns the last-known screen position of this source. */ Point getScreenPosition() const noexcept; + /** Returns the last-known screen position of this source without any scaling applied. */ + Point getRawScreenPosition() const noexcept; + /** Returns a set of modifiers that indicate which buttons are currently held down on this device. */