vcl/osx/salframe.cxx    |   31 +++++++++++++++++++++++--------
 vcl/osx/salframeview.mm |   31 ++++++++++++-------------------
 vcl/osx/vclnsapp.mm     |   14 ++++++++++----
 3 files changed, 45 insertions(+), 31 deletions(-)

New commits:
commit 39f5af68e9cc7691f8f085af08ef6bf9f9172c6b
Author:     Patrick Luby <guibmac...@gmail.com>
AuthorDate: Sun Jul 14 09:42:47 2024 -0400
Commit:     Patrick Luby <guibomac...@gmail.com>
CommitDate: Mon Feb 10 16:24:32 2025 +0100

    tdf#128186 Enable native full screen mode on macOS
    
    Commit c1452e73091412ba0bb72306329e1912df2ba513 disabled native full
    screen mode on macOS so revert the minimal amount of pieces of that
    commit. In theory, this should reintroduce one or more of the various
    bugs identified in the above commit as well as in tdf#117872.
    
    This approach purposely excludes all of the code that kept the native
    and internal full screen modes in sync. This is because the fix for
    tdf#161623 made native and internal full screen modes exist
    independently of each other. Essentially, native full screen mode is
    sort of treated like a window decoration and the internal full
    screen mode is treated the same as it would if the native window was
    not in full screen mode.
    
    Change-Id: I45110d12648092cfb4d6a26d19dfcf956777f8ca
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170452
    Tested-by: Jenkins
    Reviewed-by: Patrick Luby <guibomac...@gmail.com>

diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index 3a9af563b135..6314c198e06a 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -685,7 +685,7 @@ void AquaSalFrame::SetWindowState(const vcl::WindowData* 
pState)
 
     // set normal state
     NSRect aStateRect = [mpNSWindow frame];
-    aStateRect = [NSWindow contentRectForFrameRect: aStateRect styleMask: 
[mpNSWindow styleMask]];
+    aStateRect = [mpNSWindow contentRectForFrameRect: aStateRect];
     CocoaToVCL(aStateRect);
     if (pState->mask() & vcl::WindowDataMask::X)
         aStateRect.origin.x = float(pState->x());
@@ -696,7 +696,15 @@ void AquaSalFrame::SetWindowState(const vcl::WindowData* 
pState)
     if (pState->mask() & vcl::WindowDataMask::Height)
         aStateRect.size.height = float(pState->height());
     VCLToCocoa(aStateRect);
-    aStateRect = [NSWindow frameRectForContentRect: aStateRect styleMask: 
[mpNSWindow styleMask]];
+
+    // Related: tdf#128186 don't change size of native full screen windows
+    if ([mpNSWindow styleMask] & NSWindowStyleMaskFullScreen)
+    {
+        maNativeFullScreenRestoreRect = aStateRect;
+        return;
+    }
+
+    aStateRect = [mpNSWindow frameRectForContentRect: aStateRect];
     [mpNSWindow setFrame: aStateRect display: NO];
 
     if (pState->state() == vcl::WindowState::Minimized)
@@ -755,7 +763,7 @@ bool AquaSalFrame::GetWindowState(vcl::WindowData* pState)
     pState->setMask(vcl::WindowDataMask::PosSizeState);
 
     NSRect aStateRect = [mpNSWindow frame];
-    aStateRect = [NSWindow contentRectForFrameRect: aStateRect styleMask: 
[mpNSWindow styleMask]];
+    aStateRect = [mpNSWindow contentRectForFrameRect: aStateRect];
     CocoaToVCL( aStateRect );
 
     if( mbInternalFullScreen && !NSIsEmptyRect( 
maInternalFullScreenRestoreRect ) )
@@ -786,7 +794,7 @@ bool AquaSalFrame::GetWindowState(vcl::WindowData* pState)
 
         pState->rMask() |= vcl::WindowDataMask::MaximizedX | 
vcl::WindowDataMask::MaximizedY | vcl::WindowDataMask::MaximizedWidth | 
vcl::WindowDataMask::MaximizedHeight;
 
-        pState->setState(vcl::WindowState::FullScreen);
+        pState->setState(vcl::WindowState::Maximized);
     }
     else
     {
@@ -1775,7 +1783,7 @@ void AquaSalFrame::SetPosSize(
         [mpNSWindow deminiaturize: NSApp]; // expand the window
 
     NSRect aFrameRect = [mpNSWindow frame];
-    NSRect aContentRect = [NSWindow contentRectForFrameRect: aFrameRect 
styleMask: [mpNSWindow styleMask]];
+    NSRect aContentRect = [mpNSWindow contentRectForFrameRect: aFrameRect];
 
     // position is always relative to parent frame
     NSRect aParentContentRect;
@@ -1790,7 +1798,7 @@ void AquaSalFrame::SetPosSize(
                 nX = static_cast<tools::Long>(mpParent->maGeometry.width()) - 
aContentRect.size.width - 1 - nX;
         }
         NSRect aParentFrameRect = [mpParent->mpNSWindow frame];
-        aParentContentRect = [NSWindow contentRectForFrameRect: 
aParentFrameRect styleMask: [mpParent->mpNSWindow styleMask]];
+        aParentContentRect = [mpParent->mpNSWindow contentRectForFrameRect: 
aParentFrameRect];
     }
     else
         aParentContentRect = maScreenRect; // use screen if no parent
@@ -1798,6 +1806,13 @@ void AquaSalFrame::SetPosSize(
     CocoaToVCL( aContentRect );
     CocoaToVCL( aParentContentRect );
 
+    // Related: tdf#128186 don't change size of native full screen windows
+    if ([mpNSWindow styleMask] & NSWindowStyleMaskFullScreen)
+    {
+        maNativeFullScreenRestoreRect = aContentRect;
+        return;
+    }
+
     bool bPaint = false;
     if( (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT)) != 0 )
     {
@@ -1821,7 +1836,7 @@ void AquaSalFrame::SetPosSize(
 
     // do not display yet, we need to update our backbuffer
     {
-        [mpNSWindow setFrame: [NSWindow frameRectForContentRect: aContentRect 
styleMask: [mpNSWindow styleMask]] display: NO];
+        [mpNSWindow setFrame: [mpNSWindow frameRectForContentRect: 
aContentRect] display: NO];
     }
 
     UpdateFrameGeometry();
@@ -2066,7 +2081,7 @@ void AquaSalFrame::UpdateFrameGeometry()
     }
 
     NSRect aFrameRect = [mpNSWindow frame];
-    NSRect aContentRect = [NSWindow contentRectForFrameRect: aFrameRect 
styleMask: [mpNSWindow styleMask]];
+    NSRect aContentRect = [mpNSWindow contentRectForFrameRect: aFrameRect];
 
     NSRect aTrackRect = { NSZeroPoint, aContentRect.size };
 
diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm
index 19c4234600c7..60d544fb8fe1 100644
--- a/vcl/osx/salframeview.mm
+++ b/vcl/osx/salframeview.mm
@@ -302,26 +302,13 @@ static void updateMenuBarVisibility( const AquaSalFrame 
*pFrame )
                                  backing: NSBackingStoreBuffered
                                  defer: Application::IsHeadlessModeEnabled()];
 
-    // Disallow full-screen mode on macOS >= 10.11 where it is enabled by 
default. We don't want it
-    // for now as it will just be confused with LibreOffice's home-grown 
full-screen concept, with
-    // which it has nothing to do, and one can get into all kinds of weird 
states by using them
-    // intermixedly.
-
-    // Ideally we should use the system full-screen mode and adapt the code 
for the home-grown thing
-    // to be in sync with that instead. (And we would then not need the button 
to get out of
-    // full-screen mode, as the normal way to get out of it is to either click 
on the green bubble
-    // again, or invoke the keyboard command again.)
-
-    // (Confusingly, at the moment the home-grown full-screen mode is bound to 
Cmd+Shift+F, which is
-    // the keyboard command normally used in apps to get in and out of the 
system full-screen mode.)
-
-    // Disabling system full-screen mode makes the green button on the title 
bar (on macOS >= 10.11)
-    // show a plus sign instead, and clicking it becomes identical to 
double-clicking the title bar,
-    // i.e. it maximizes / unmaximises the window. Sure, that state can also 
be confused with LO's
-    // home-grown full-screen mode. Oh well.
+    // Enable fullscreen options if available and useful
+    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 setReleasedWhenClosed: NO];
-    [pNSWindow setCollectionBehavior: 
NSWindowCollectionBehaviorFullScreenNone];
+    [pNSWindow setCollectionBehavior: (bAllowFullScreen ? 
NSWindowCollectionBehaviorFullScreenPrimary : 
NSWindowCollectionBehaviorFullScreenAuxiliary)];
 
     // Disable window restoration until we support it directly
     [pNSWindow setRestorable: NO];
@@ -566,7 +553,13 @@ static void updateMenuBarVisibility( const AquaSalFrame 
*pFrame )
             // events and firing any pending timers.
             freezeWindowSizeAndReschedule( self );
 
-            if ( ImplGetSVData()->mpWinData->mbIsLiveResize )
+            // Related: tdf128186 Always run timer in full screen mode windows
+            // When opening new windows by pressing and holding Command-N
+            // in a full screen window, some of the new windows will have
+            // content that does not fill the new window. So still run the
+            // timer on full screen windows even if live resizing ended
+            // during the call to freezeWindowSizeAndReschedule().
+            if ( ImplGetSVData()->mpWinData->mbIsLiveResize || [self 
styleMask] & NSWindowStyleMaskFullScreen )
             {
                 // tdf#152703 Force repaint after live resizing ends
                 // Repost this notification so that this selector will be 
called
diff --git a/vcl/osx/vclnsapp.mm b/vcl/osx/vclnsapp.mm
index 19c90cbb323e..56cd63258faf 100644
--- a/vcl/osx/vclnsapp.mm
+++ b/vcl/osx/vclnsapp.mm
@@ -76,10 +76,16 @@
     assert( pEvent );
     [NSApp postEvent: pEvent atStart: NO];
 
-    if( [NSWindow respondsToSelector:@selector(allowsAutomaticWindowTabbing)] )
-    {
-        [NSWindow setAllowsAutomaticWindowTabbing:NO];
-    }
+    // Disable native tabbed windows. Before native tabbed windows can be
+    // enabled the following known issues need to be fixed:
+    // - Live resizing a non-full screen window with multiple tabs open
+    //   causes the window height to increase far offscreen
+    // - The status bar is pushed off the bottom of the screen in a
+    //   non-full screen window with multiple tabs open
+    // - After closing all tabs in a non-full screen window with multiple
+    //   tabs, the last window leaves an empty space below the status bar
+    //   equal in height to the hidden tab bar
+    [NSWindow setAllowsAutomaticWindowTabbing: NO];
 
     // listen to dark mode change
     [NSApp addObserver:self forKeyPath:@"effectiveAppearance" options: 0 
context: nil];

Reply via email to