Merge branch 'master' into jgrpp

# Conflicts:
#	src/os/macosx/macos.mm
#	src/video/cocoa/cocoa_v.mm
#	src/video/cocoa/fullscreen.mm
#	src/video/cocoa/wnd_quartz.mm
#	src/video/cocoa/wnd_quickdraw.mm
This commit is contained in:
Jonathan G Rennison
2020-04-30 23:59:06 +01:00
22 changed files with 218 additions and 2157 deletions

View File

@@ -129,10 +129,12 @@ class CrashLogOSX : public CrashLog {
" Name: Mac OS X\n"
" Release: %d.%d.%d\n"
" Machine: %s\n"
" Min Ver: %d\n",
" Min Ver: %d\n"
" Max Ver: %d\n",
ver_maj, ver_min, ver_bug,
arch != nullptr ? arch->description : "unknown",
MAC_OS_X_VERSION_MIN_REQUIRED
MAC_OS_X_VERSION_MIN_REQUIRED,
MAC_OS_X_VERSION_MAX_ALLOWED
);
}

View File

@@ -161,19 +161,8 @@ const char *GetCurrentLocale(const char *)
NSString *preferredLang = [ languages objectAtIndex:0 ];
/* preferredLang is either 2 or 5 characters long ("xx" or "xx_YY"). */
/* Since Apple introduced encoding to CString in OSX 10.4 we have to make a few conditions
* to get the right code for the used version of OSX. */
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
if (MacOSVersionIsAtLeast(10, 4, 0)) {
[ preferredLang getCString:retbuf maxLength:32 encoding:NSASCIIStringEncoding ];
} else
#endif
{
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4)
/* maxLength does not include the \0 char in contrast to the call above. */
[ preferredLang getCString:retbuf maxLength:31 ];
#endif
}
[ preferredLang getCString:retbuf maxLength:32 encoding:NSASCIIStringEncoding ];
return retbuf;
}
@@ -213,7 +202,7 @@ bool IsMonospaceFont(CFStringRef name)
{
NSFont *font = [ NSFont fontWithName:(__bridge NSString *)name size:0.0f ];
return font != nullptr ? [ font isFixedPitch ] : false;
return font != nil ? [ font isFixedPitch ] : false;
}
/**
@@ -222,14 +211,12 @@ bool IsMonospaceFont(CFStringRef name)
*/
void MacOSSetThreadName(const char *name)
{
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
if (MacOSVersionIsAtLeast(10, 6, 0)) {
pthread_setname_np(name);
}
#endif
NSThread *cur = [ NSThread currentThread ];
if (cur != nullptr && [ cur respondsToSelector:@selector(setName:) ]) {
if (cur != nil && [ cur respondsToSelector:@selector(setName:) ]) {
[ cur performSelector:@selector(setName:) withObject:[ NSString stringWithUTF8String:name ] ];
}
}

View File

@@ -19,6 +19,10 @@
#define HAVE_OSX_107_SDK
#endif
#ifdef MAC_OS_X_VERSION_10_9
#define HAVE_OSX_109_SDK
#endif
#ifdef MAC_OS_X_VERSION_10_11
#define HAVE_OSX_1011_SDK
#endif

View File

@@ -19,7 +19,34 @@
#include <CoreFoundation/CoreFoundation.h>
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
/* CTRunDelegateCreate is supported since MacOS X 10.5, but was only included in the SDKs starting with the 10.9 SDK. */
#ifndef HAVE_OSX_109_SDK
extern "C" {
typedef const struct __CTRunDelegate * CTRunDelegateRef;
typedef void (*CTRunDelegateDeallocateCallback) (void* refCon);
typedef CGFloat (*CTRunDelegateGetAscentCallback) (void* refCon);
typedef CGFloat (*CTRunDelegateGetDescentCallback) (void* refCon);
typedef CGFloat (*CTRunDelegateGetWidthCallback) (void* refCon);
typedef struct {
CFIndex version;
CTRunDelegateDeallocateCallback dealloc;
CTRunDelegateGetAscentCallback getAscent;
CTRunDelegateGetDescentCallback getDescent;
CTRunDelegateGetWidthCallback getWidth;
} CTRunDelegateCallbacks;
enum {
kCTRunDelegateVersion1 = 1,
kCTRunDelegateCurrentVersion = kCTRunDelegateVersion1
};
extern const CFStringRef kCTRunDelegateAttributeName AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
CTRunDelegateRef CTRunDelegateCreate(const CTRunDelegateCallbacks* callbacks, void* refCon) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
}
#endif /* HAVE_OSX_109_SDK */
/** Cached current locale. */
static CFAutoRelease<CFLocaleRef> _osx_locale;
/** CoreText cache for font information, cleared when OTTD changes fonts. */
@@ -409,23 +436,3 @@ int MacOSStringCompare(const char *s1, const char *s2)
return new OSXStringIterator();
}
#else
void MacOSResetScriptCache(FontSize size) {}
void MacOSSetCurrentLocaleName(const char *iso_code) {}
int MacOSStringCompare(const char *s1, const char *s2)
{
return 0;
}
/* static */ StringIterator *OSXStringIterator::Create()
{
return nullptr;
}
/* static */ ParagraphLayouter *CoreTextParagraphLayoutFactory::GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping)
{
return nullptr;
}
#endif /* (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) */