From: Stephan Witt Date: Sun, 30 Aug 2020 20:25:34 +0000 (+0200) Subject: #11756 Respect system preferences for tabbing on Mac X-Git-Tag: lyx-2.4.0dev-acb2ca7b~226 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=45e8ea4acc557dd54e062750f47ff569b5b98c43;p=features.git #11756 Respect system preferences for tabbing on Mac --- diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index eb5d0dcf83..323881d564 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -46,6 +46,10 @@ #include "support/TempFile.h" #include "support/userinfo.h" +#ifdef USE_MACOSX_PACKAGING +#include "support/AppleSupport.h" +#endif + #include #include #include @@ -286,6 +290,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) // format prior to 2.0 and introduction of format tag unsigned int rc_format = 0; +#ifdef USE_MACOSX_PACKAGING + open_buffers_in_tabs = appleUserTabbingPreferenceAlways(); +#endif + while (lexrc.isOK()) { // By using two switches we take advantage of the compiler // telling us if we have missed a LyXRCTags element in diff --git a/src/support/AppleSupport.h b/src/support/AppleSupport.h index ef055cb4f7..9f154c6155 100644 --- a/src/support/AppleSupport.h +++ b/src/support/AppleSupport.h @@ -17,6 +17,9 @@ extern "C" { #endif void appleCleanupEditMenu(); void appleCleanupViewMenu(); + + // query the system preferences for users tabbing preference + bool appleUserTabbingPreferenceAlways(); #ifdef __cplusplus } #endif diff --git a/src/support/AppleSupport.m b/src/support/AppleSupport.m index edbede487f..7657e9db97 100644 --- a/src/support/AppleSupport.m +++ b/src/support/AppleSupport.m @@ -24,12 +24,21 @@ void appleCleanupEditMenu() { void appleCleanupViewMenu() { -#ifdef AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER // Remove the "Show Tab Bar" menu item from the "View" menu, if supported + // See the Apple developer release notes: + // What should an application which already has support for tabbing do? + // - The application should explicitly opt-out of automatic window tabbing... + // It should respect the userTabbingPreference... see below + // https://developer.apple.com/library/archive/releasenotes/AppKit/RN-AppKitOlderNotes/index.html if ([NSWindow respondsToSelector:@selector(allowsAutomaticWindowTabbing)]) - NSWindow.allowsAutomaticWindowTabbing = NO; -#endif + [NSWindow setAllowsAutomaticWindowTabbing:NO]; // Remove the "Enter Full Screen" menu item from the "View" menu [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSFullScreenMenuItemEverywhere"]; } + + +bool appleUserTabbingPreferenceAlways() { + return [NSWindow respondsToSelector:@selector(userTabbingPreference)] && + [NSWindow userTabbingPreference] == NSWindowUserTabbingPreferenceAlways; +}