officecfg/registry/schema/org/openoffice/Office/Common.xcs | 8 ++++++ vcl/osx/salframeview.mm | 15 +++++++++---- vcl/osx/salmenu.cxx | 13 +++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-)
New commits: commit e8f8af2b9872ff8ce646a0278f142cdb5c4005f7 Author: Patrick Luby <guibmac...@gmail.com> AuthorDate: Sat Mar 22 19:41:58 2025 -0400 Commit: Patrick Luby <guibomac...@gmail.com> CommitDate: Sun Mar 23 19:34:16 2025 +0100 Related: tdf#128186 force key window to a native full screen window AquaSalMenu::setDefaultMenu() is generally called when the key window has been closed. When not in native full screen mode, macOS appears to automatically set the key window. However, closing a native full screen window sometimes causes the application to drop out of full screen mode even if there are still native full screen windows open. So, if the application is active, activate all windows to force macOS to set the key to a window rather than leaving the application in a state where the key window is nil. Also, add a EnableNativeFullScreenWindows expert preference so that users can disable native full screen mode and make the green button in the titlebar zoom instead of switching to a full screen window. Change-Id: I3d9c538d784d7abcd5e75975ea00582768851ec7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183229 Tested-by: Jenkins Reviewed-by: Patrick Luby <guibomac...@gmail.com> diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 969df405cc10..75d1caf3a627 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -702,6 +702,14 @@ <value>15</value> </prop> <group oor:name="macOS"> + <prop oor:name="EnableNativeFullScreenWindows" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Specifies if clicking the green button in a window's + titlebar causes the window to switch to native full screen + mode.</desc> + </info> + <value>true</value> + </prop> <prop oor:name="IgnoreKeysWhenScrollingWithTrackpadOrMagicMouse" oor:type="xs:boolean" oor:nillable="false"> <info> <desc>Specifies if the Command, Option, Control, and Shift keys diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm index 74da526f6ba4..939f230ee8ef 100644 --- a/vcl/osx/salframeview.mm +++ b/vcl/osx/salframeview.mm @@ -320,12 +320,19 @@ static void updateMenuBarVisibility( const AquaSalFrame *pFrame ) defer: Application::IsHeadlessModeEnabled()]; // 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); + 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]; + } [pNSWindow setReleasedWhenClosed: NO]; - [pNSWindow setCollectionBehavior: (bAllowFullScreen ? NSWindowCollectionBehaviorFullScreenPrimary : NSWindowCollectionBehaviorFullScreenAuxiliary)]; // Disable window restoration until we support it directly [pNSWindow setRestorable: NO]; diff --git a/vcl/osx/salmenu.cxx b/vcl/osx/salmenu.cxx index a14f1874c83e..8200af5663a9 100644 --- a/vcl/osx/salmenu.cxx +++ b/vcl/osx/salmenu.cxx @@ -400,6 +400,19 @@ void AquaSalMenu::setDefaultMenu() if( [pItem menu] == nil ) [pMenu insertItem: pItem atIndex: i+1]; } + + // Related: tdf#128186 force key window to a native full screen window + // AquaSalMenu::setDefaultMenu() is generally called when the key + // window has been closed. When not in native full screen mode, + // macOS appears to automatically set the key window. + // However, closing a native full screen window sometimes causes + // the application to drop out of full screen mode even if there + // are still native full screen windows open. So, if the application + // is active, activate all windows to force macOS to set the key + // to a window rather than leaving the application in a state where + // the key window is nil. + if( [NSApp isActive] ) + [[NSRunningApplication currentApplication] activateWithOptions: NSApplicationActivateAllWindows]; } void AquaSalMenu::enableMainMenu( bool bEnable )