]> git.lyx.org Git - features.git/commitdiff
#11756 Respect system preferences for tabbing on Mac
authorStephan Witt <switt@lyx.org>
Sun, 30 Aug 2020 20:25:34 +0000 (22:25 +0200)
committerStephan Witt <switt@lyx.org>
Fri, 4 Sep 2020 21:28:27 +0000 (23:28 +0200)
src/LyXRC.cpp
src/support/AppleSupport.h
src/support/AppleSupport.m

index eb5d0dcf835eedf5fb0f11ce757a38eaa9118636..323881d5649fe00781410fd51afd1b908ca08d73 100644 (file)
 #include "support/TempFile.h"
 #include "support/userinfo.h"
 
+#ifdef USE_MACOSX_PACKAGING
+#include "support/AppleSupport.h"
+#endif
+
 #include <fstream>
 #include <iostream>
 #include <algorithm>
@@ -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
index ef055cb4f79aa37dd09679a8cfdf39fb17b38b04..9f154c6155854aeb06a3fc98453a257aff023efd 100644 (file)
@@ -17,6 +17,9 @@ extern "C" {
 #endif
        void appleCleanupEditMenu();
        void appleCleanupViewMenu();
+
+       // query the system preferences for users tabbing preference
+       bool appleUserTabbingPreferenceAlways();
 #ifdef __cplusplus
 }
 #endif
index edbede487f253c3edc3d2c6b8a8171d795c21205..7657e9db974e722e2d042eafc795571d190b2c3c 100644 (file)
@@ -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;
+}