vcl/osx/salinst.cxx |   34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

New commits:
commit 09749f3b3887eaf7ef108c9cb38238b31224b6a6
Author:     Patrick Luby <[email protected]>
AuthorDate: Wed Mar 4 11:56:25 2026 -0500
Commit:     Dan Williams <[email protected]>
CommitDate: Mon Mar 9 14:48:57 2026 +0100

    tdf#170740 only repost the same left mouse up event once
    
    Dragging a window's titlebar with the Option key pressed
    may trigger live resizing. Unlike normal live resizing,
    live resizing while Option-dragging a window needs
    left mouse up events to be dispatched to end live
    resizing. So if we keep reposting the same left mouse up
    event, LibreOffice will go into an infinite loop waiting
    for live resizing to end.
    
    Reposting last mouse up events is still needed to
    prevent tdf#155092 during normal live resizing so allow
    last mouse up events to be reposted but only once.
    
    The purpose of reposting is to skip native event
    dispatching during this pass and only let native timers
    run. This lets pending LibreOffice resizing and
    repainting timers run before the left mouse up event is
    dispatched.
    
    Change-Id: Ide2ec9988a8258cd1acf9852a61cfc4d4c1abdef
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200957
    Reviewed-by: Dan Williams <[email protected]>
    Tested-by: Jenkins
    Reviewed-by: Patrick Luby <[email protected]>
    (cherry picked from commit 7575bbe54a6afec3b289985593977579835cce3f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201195
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>
    (cherry picked from commit d655a441b66aac6e20776b41d05178593c6c991b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201220

diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index e3c654ff558a..082bc2508d61 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -605,8 +605,40 @@ bool AquaSalInstance::DoYield(bool bWait, bool 
bHandleAllCurrentEvents)
                 // the front of the event queue so no more events will be
                 // dispatched until live resizing ends. Surprisingly, live
                 // resizing appears to end in the next mouse down event.
-                if ( ImplGetSVData()->mpWinData->mbIsLiveResize && [pEvent 
type] == NSEventTypeLeftMouseUp )
+                bool bRepostEvent = false;
+                if ( ImplGetSVData()->mpWinData->mbIsLiveResize )
+                    bRepostEvent = ( [pEvent type] == NSEventTypeLeftMouseUp );
+
+                // tdf#170740 only repost the same left mouse up event once
+                // Dragging a window's titlebar with the Option key pressed
+                // may trigger live resizing. Unlike normal live resizing,
+                // live resizing while Option-dragging a window needs
+                // left mouse up events to be dispatched to end live
+                // resizing. So if we keep reposting the same left mouse up
+                // event, LibreOffice will go into an infinite loop waiting
+                // for live resizing to end.
+                // Reposting last mouse up events is still needed to
+                // prevent tdf#155092 during normal live resizing so allow
+                // last mouse up events to be reposted but only once.
+                // The purpose of reposting is to skip native event
+                // dispatching during this pass and only let native timers
+                // run. This lets pending LibreOffice resizing and
+                // repainting timers run before the left mouse up event is
+                // dispatched.
+                static NSEvent *pLastRepostedEvent = nil;
+                if ( pLastRepostedEvent )
                 {
+                    [pLastRepostedEvent release];
+                    pLastRepostedEvent = nil;
+                }
+                // Only repost event if pLastRepostedEvent was already nil.
+                // Reposting an event while waiting to dispatch a previously
+                // reposted event can cause incorrect ordering of native events
+                // in the native queue. So, to be safe, resume normal event
+                // dispatching.
+                else if ( bRepostEvent )
+                {
+                    pLastRepostedEvent = [pEvent retain];
                     [NSApp postEvent: pEvent atStart: YES];
                     return false;
                 }

Reply via email to