vcl/osx/salframe.cxx    |    6 +++++-
 vcl/osx/salframeview.mm |   46 +++++++++++++++++++++++++++++++++-------------
 2 files changed, 38 insertions(+), 14 deletions(-)

New commits:
commit eba768cb5588c8b3b30a530028b8ee0a67177b18
Author:     Patrick Luby <guibmac...@gmail.com>
AuthorDate: Mon Mar 24 12:01:45 2025 -0400
Commit:     Patrick Luby <guibomac...@gmail.com>
CommitDate: Mon Mar 24 21:45:08 2025 +0100

    Related: tdf128186 update native collection behavior when window becomes key
    
    The user can enable or disable native full screen mode at any time
    by changing the EnableNativeFullScreenWindows export preference.
    So when an NSWindow becomes the key window, update its native collection
    behavior to match that preference's current value.
    
    Also, AquaSalFrame stores both the maNativeFullScreenRestoreRect and
    maInternalFullScreenRestoreRect in VCL coordinates so convert to
    Cocoa coordinates when setting an NSWindow's frame to one of those
    member variables.
    
    Change-Id: Id0f6559b8272120f745f83129c16d160adadb378
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183278
    Reviewed-by: Patrick Luby <guibomac...@gmail.com>
    Tested-by: Jenkins

diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index df9d2b28d3fd..d0bdd2b85ac7 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -993,7 +993,11 @@ void AquaSalFrame::doShowFullScreen( bool bFullScreen, 
sal_Int32 nDisplay )
         if( !NSIsEmptyRect( maInternalFullScreenRestoreRect ) )
         {
             if( !mbNativeFullScreen || NSIsEmptyRect( 
maNativeFullScreenRestoreRect ) )
-                [mpNSWindow setFrame: maInternalFullScreenRestoreRect display: 
mbShown ? YES : NO];
+            {
+                NSRect aFrame = maInternalFullScreenRestoreRect;
+                VCLToCocoa( aFrame );
+                [mpNSWindow setFrame: aFrame display: mbShown ? YES : NO];
+            }
 
             maInternalFullScreenRestoreRect = NSZeroRect;
         }
diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm
index 939f230ee8ef..a2b80ce97349 100644
--- a/vcl/osx/salframeview.mm
+++ b/vcl/osx/salframeview.mm
@@ -298,6 +298,31 @@ static void updateMenuBarVisibility( const AquaSalFrame 
*pFrame )
     }
 }
 
+static void updateWindowCollectionBehavior( const AquaSalFrame *pFrame )
+{
+    if( !pFrame )
+        return;
+
+    // Enable fullscreen options if available and useful
+    NSWindowCollectionBehavior bOldCollectionBehavor = [pFrame->mpNSWindow 
collectionBehavior];
+    NSWindowCollectionBehavior bCollectionBehavor = 
NSWindowCollectionBehaviorFullScreenNone;
+    if ( 
officecfg::Office::Common::VCL::macOS::EnableNativeFullScreenWindows::get() )
+    {
+        bool bAllowFullScreen = (SalFrameStyleFlags::NONE == (pFrame->mnStyle 
& (SalFrameStyleFlags::DIALOG | SalFrameStyleFlags::TOOLTIP | 
SalFrameStyleFlags::SYSTEMCHILD | SalFrameStyleFlags::FLOAT | 
SalFrameStyleFlags::TOOLWINDOW | SalFrameStyleFlags::INTRO)));
+        bAllowFullScreen &= (SalFrameStyleFlags::NONE == (~pFrame->mnStyle & 
SalFrameStyleFlags::SIZEABLE));
+        bAllowFullScreen &= (pFrame->mpParent == nullptr);
+
+        bCollectionBehavor = bAllowFullScreen ? 
NSWindowCollectionBehaviorFullScreenPrimary : 
NSWindowCollectionBehaviorFullScreenAuxiliary;
+    }
+    else
+    {
+        bCollectionBehavor = NSWindowCollectionBehaviorFullScreenNone;
+    }
+
+    if ( bCollectionBehavor != bOldCollectionBehavor )
+        [pFrame->mpNSWindow setCollectionBehavior: bCollectionBehavor];
+}
+
 @interface NSResponder (SalFrameWindow)
 -(BOOL)accessibilityIsIgnored;
 @end
@@ -319,18 +344,7 @@ static void updateMenuBarVisibility( const AquaSalFrame 
*pFrame )
                                  backing: NSBackingStoreBuffered
                                  defer: Application::IsHeadlessModeEnabled()];
 
-    // Enable fullscreen options if available and useful
-    if ( 
officecfg::Office::Common::VCL::macOS::EnableNativeFullScreenWindows::get() )
-    {
-        bool bAllowFullScreen = (SalFrameStyleFlags::NONE == (mpFrame->mnStyle 
& (SalFrameStyleFlags::DIALOG | SalFrameStyleFlags::TOOLTIP | 
SalFrameStyleFlags::SYSTEMCHILD | SalFrameStyleFlags::FLOAT | 
SalFrameStyleFlags::TOOLWINDOW | SalFrameStyleFlags::INTRO)));
-        bAllowFullScreen &= (SalFrameStyleFlags::NONE == (~mpFrame->mnStyle & 
SalFrameStyleFlags::SIZEABLE));
-        bAllowFullScreen &= (mpFrame->mpParent == nullptr);
-        [pNSWindow setCollectionBehavior: (bAllowFullScreen ? 
NSWindowCollectionBehaviorFullScreenPrimary : 
NSWindowCollectionBehaviorFullScreenAuxiliary)];
-    }
-    else
-    {
-        [pNSWindow setCollectionBehavior: 
NSWindowCollectionBehaviorFullScreenNone];
-    }
+    updateWindowCollectionBehavior( mpFrame );
 
     [pNSWindow setReleasedWhenClosed: NO];
 
@@ -417,6 +431,8 @@ static void updateMenuBarVisibility( const AquaSalFrame 
*pFrame )
 
     if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
     {
+        updateWindowCollectionBehavior( mpFrame );
+
         static const SalFrameStyleFlags nGuessDocument = 
SalFrameStyleFlags::MOVEABLE|
                                             SalFrameStyleFlags::SIZEABLE|
                                             SalFrameStyleFlags::CLOSEABLE;
@@ -719,7 +735,11 @@ static void updateMenuBarVisibility( const AquaSalFrame 
*pFrame )
         if( !NSIsEmptyRect( mpFrame->maNativeFullScreenRestoreRect ) )
         {
             if ( !mpFrame->mbInternalFullScreen || NSIsEmptyRect( 
mpFrame->maInternalFullScreenRestoreRect ) )
-                [mpFrame->getNSWindow() setFrame: 
mpFrame->maNativeFullScreenRestoreRect display: mpFrame->mbShown ? YES : NO];
+            {
+                NSRect aFrame = mpFrame->maNativeFullScreenRestoreRect;
+                mpFrame->VCLToCocoa( aFrame );
+                [mpFrame->getNSWindow() setFrame: aFrame display: 
mpFrame->mbShown ? YES : NO];
+            }
 
             mpFrame->maNativeFullScreenRestoreRect = NSZeroRect;
         }

Reply via email to