Bug: mouse events are incorrect after compound AffineTransform

I have an AffineTransformed Component (blue) inside an AffineTransformed Component (red). Each one is zoomed in on the last, so the effect is what I’m calling a “compound zoom”. In the screenshot, the blue “inner” Component is 111.795 times ( = 31.67 * 3.53) larger than its original position.

MouseEvents are correctly identified for the first layer, but not for the second. Ie., if you click in the red Component but close to the inner blue Component, it incorrectly registers as a click on the inner blue Component.

I’m guessing that the problem is a float being rounded to an int somewhere.

Is there any chance that someone from the JUCE team could take a look that this? I’ve heard before that AffineTransformations aren’t fully supported with all Component methods, but mouse clicks are a breaking feature, and it’s going to be extremely difficult to work around this from the user’s end.

Sample code is below:

class Base : public Component
    void paint(Graphics& g) override
        float myCompoundZoom = getCompoundZoom();
        g.setFont(12.0f / myCompoundZoom);
        g.drawText(getName() + " zoom: " + String(myCompoundZoom), getLocalBounds(), Justification::topLeft);

    void mouseDown(const MouseEvent& m) override
        DBG(getName());     // Watch the output console

    Colour m_col;
    Base* const m_parent;

    Base(const Colour& col, StringRef name, Base* const comp) : m_col(col), m_parent(comp)
        // This is just a quick way of calculating the absolute zoom, so that it can be displayed.
    float getCompoundZoom() const
        if (m_parent)
            return m_parent->getCompoundZoom() * getTransform().getScaleFactor();
            return getTransform().getScaleFactor();

class MainContentComponent  : public Component
    Base outer, middle, inner;

    MainContentComponent() : outer(Colours::wheat, "outer", nullptr),
                             middle(Colours::red, "middle", &outer),
                             inner(Colours::dodgerblue, "inner", &middle)

        setBounds(0, 0, 600, 600);

        middle.setBounds(Rectangle<int>(2, 2, 7, 8));
        inner.setBounds(Rectangle<int>(0, 0, 1, 1));

                   // I've picked nasty transform numbers here to amplify the rounding error.
        middle.setTransform(AffineTransform::scale(31.67f).translated(5.6f, 6.2f));
        inner. setTransform(AffineTransform::scale(3.53f).translated(0.6f, 0.7f));