tdf#155266 force flush after scrolling

This is the second attempt to force a flush after scrolling.
Commit 9c0803edd1f42b2d29115674795c7c674fea1a35 worked on
Mac Silicon but not Mac Intel.

So, instead of calling [NSApp currentEvent] to determine if
scrolling has occurred, mark the AquaSalFrame whenever a
scrollwheel or mouse drag event is dispatched so the frame
will be flushed in the next AquaSalFrame::Flush() call.

Change-Id: I2d0b99d2cd1167e92c7fd89bf53b2f30ab85a165
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159003
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
(cherry picked from commit 0c54c09aeb7e170512195c8f619ab2ded98c1ec5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159038
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/vcl/inc/osx/salframe.h b/vcl/inc/osx/salframe.h
index af8783b..b79d317 100644
--- a/vcl/inc/osx/salframe.h
+++ b/vcl/inc/osx/salframe.h
@@ -98,6 +98,9 @@ public:

    int                             mnBlinkCursorDelay;

    // tdf#155266 force flush after scrolling
    bool                            mbForceFlush;

public:
    /** Constructor

diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index d3d35de..88c9a9d 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -87,7 +87,8 @@ AquaSalFrame::AquaSalFrame( SalFrame* pParent, SalFrameStyleFlags salFrameStyle 
    mnTrackingRectTag( 0 ),
    mrClippingPath( nullptr ),
    mnICOptions( InputContextFlags::NONE ),
    mnBlinkCursorDelay ( nMinBlinkCursorDelay )
    mnBlinkCursorDelay( nMinBlinkCursorDelay ),
    mbForceFlush( false )
{
    mpParent = dynamic_cast<AquaSalFrame*>(pParent);

@@ -1015,8 +1016,9 @@ void AquaSalFrame::Flush()
    // outside of the application's event loop (e.g. IntroWindow)
    // nothing would trigger paint event handling
    // => fall back to synchronous painting
    if( ImplGetSVData()->maAppData.mnDispatchLevel <= 0 )
    if( mbForceFlush || ImplGetSVData()->maAppData.mnDispatchLevel <= 0 )
    {
        mbForceFlush = false;
        mpGraphics->Flush();
        [mpNSView display];
    }
@@ -1036,8 +1038,9 @@ void AquaSalFrame::Flush( const tools::Rectangle& rRect )
    // outside of the application's event loop (e.g. IntroWindow)
    // nothing would trigger paint event handling
    // => fall back to synchronous painting
    if( ImplGetSVData()->maAppData.mnDispatchLevel <= 0 )
    if( mbForceFlush || ImplGetSVData()->maAppData.mnDispatchLevel <= 0 )
    {
        mbForceFlush = false;
        mpGraphics->Flush( rRect );
        [mpNSView display];
    }
diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm
index 0882180..3892ef6 100644
--- a/vcl/osx/salframeview.mm
+++ b/vcl/osx/salframeview.mm
@@ -786,6 +786,10 @@ static AquaSalFrame* getMouseContainerFrame()
            aEvent.mnX = pDispatchFrame->maGeometry.width() - 1 - aEvent.mnX;

        pDispatchFrame->CallCallback( nEvent, &aEvent );

        // tdf#155266 force flush after scrolling
        if (nButton == MOUSE_LEFT && nEvent == SalEvent::MouseMove)
            mpFrame->mbForceFlush = true;
    }
}

@@ -1089,6 +1093,9 @@ static AquaSalFrame* getMouseContainerFrame()

            mpFrame->CallCallback( SalEvent::WheelMouse, &aEvent );
        }

        // tdf#155266 force flush after scrolling
        mpFrame->mbForceFlush = true;
    }
}