vcl/osx/salframe.cxx |   17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

New commits:
commit b4eb737f07d85fcc583dffefb0d5489d859690ae
Author:     Patrick Luby <guibmac...@gmail.com>
AuthorDate: Sun Apr 27 17:02:18 2025 -0400
Commit:     Patrick Luby <guibomac...@gmail.com>
CommitDate: Mon Apr 28 03:25:59 2025 +0200

    Related: tdf#165448 move parent window to front after closing window
    
    When a floating window such as the dropdown list in the
    font combobox is open when selecting any of the menu items
    inserted by macOS in the windows menu, the parent window
    will be hidden. So if there is a key window, force the key
    window back to the front.
    
    Previously, delaying closing of the window was used to avoid
    this bug, but that caused Skia/Metal to crash when the
    window was released before the delayed close occurred. This
    crash was found when rapidly dragging the border between two
    column headings side to side in a Calc document.
    
    Change-Id: I8511fe73e59c49f57d9179f5308e4b7a393809b8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184690
    Tested-by: Jenkins
    Reviewed-by: Patrick Luby <guibomac...@gmail.com>

diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index 08517cb837e7..69c31ede4715 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -555,13 +555,22 @@ void AquaSalFrame::Show(bool bVisible, bool bNoActivate)
         // Ordering out a native full screen window would leave the
         // application in a state where there is no Desktop and both
         // the menubar and the Dock are hidden.
-        // Related: tdf#165448 delay closing the window
+        [mpNSWindow close];
+
+        // Related: tdf#165448 move parent window to front after closing window
         // When a floating window such as the dropdown list in the
         // font combobox is open when selecting any of the menu items
         // inserted by macOS in the windows menu, the parent window
-        // will be hidden. So delay closing the window until the next
-        // pass through the native event loop.
-        [mpNSWindow performSelector: @selector(close) withObject: nil 
afterDelay: 0.01f];
+        // will be hidden. So if there is a key window, force the key
+        // window back to the front.
+        // Previously, delaying closing of the window was used to avoid
+        // this bug, but that caused Skia/Metal to crash when the
+        // window was released before the delayed close occurred. This
+        // crash was found when rapidly dragging the border between two
+        // column headings side to side in a Calc document.
+        NSWindow *pKeyWin = [NSApp keyWindow];
+        if( pKeyWin )
+            [pKeyWin orderFront: NSApp];
     }
 }
 

Reply via email to