commit 45e8ea4acc557dd54e062750f47ff569b5b98c43
Author: Stephan Witt <[email protected]>
Date:   Sun Aug 30 22:25:34 2020 +0200

    #11756 Respect system preferences for tabbing on Mac
---
 src/LyXRC.cpp              |    8 ++++++++
 src/support/AppleSupport.h |    3 +++
 src/support/AppleSupport.m |   15 ++++++++++++---
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index eb5d0dc..323881d 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 <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
diff --git a/src/support/AppleSupport.h b/src/support/AppleSupport.h
index ef055cb..9f154c6 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 edbede4..7657e9d 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;
+}
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to