#11756 Respect system preferences for tabbing on Mac

This commit is contained in:
Stephan Witt 2020-08-30 22:25:34 +02:00
parent ace9fbb6a0
commit 45e8ea4acc
3 changed files with 23 additions and 3 deletions

View File

@ -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

View 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

View 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;
}