Ghost Context Refactor
https://developer.blender.org/D643 Separates graphics context creation from window code in Ghost so that they can vary separately.
This commit is contained in:
@@ -36,6 +36,11 @@ set(SRC
|
||||
boost_locale_wrapper.h
|
||||
)
|
||||
|
||||
if(APPLE)
|
||||
# Cocoa code to read the locale on OSX
|
||||
list(APPEND SRC osx_user_locale.mm)
|
||||
endif()
|
||||
|
||||
if(WITH_HEADLESS)
|
||||
add_definitions(-DWITH_HEADLESS)
|
||||
endif()
|
||||
|
@@ -29,6 +29,10 @@ Import('env')
|
||||
|
||||
sources = env.Glob('*.cpp')
|
||||
|
||||
if env['OURPLATFORM'] in ['darwin']:
|
||||
# Cocoa code to read user locale on OSX
|
||||
sources.append('osx_user_locale.mm')
|
||||
|
||||
incs = '.'
|
||||
defs = []
|
||||
|
||||
|
@@ -65,8 +65,7 @@ void bl_locale_set(const char *locale)
|
||||
}
|
||||
else {
|
||||
#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL)
|
||||
extern char GHOST_user_locale[128]; // pulled from Ghost_SystemCocoa
|
||||
std::string locale_osx = GHOST_user_locale + std::string(".UTF-8");
|
||||
std::string locale_osx = osx_user_locale() + std::string(".UTF-8");
|
||||
_locale = gen(locale_osx.c_str());
|
||||
#else
|
||||
_locale = gen("");
|
||||
|
@@ -42,7 +42,11 @@ void bl_locale_init(const char *messages_path, const char *default_domain);
|
||||
void bl_locale_set(const char *locale);
|
||||
const char *bl_locale_get(void);
|
||||
const char *bl_locale_pgettext(const char *msgctxt, const char *msgid);
|
||||
|
||||
|
||||
#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL)
|
||||
const char* osx_user_locale(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
22
intern/locale/osx_user_locale.mm
Normal file
22
intern/locale/osx_user_locale.mm
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "boost_locale_wrapper.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
static char* user_locale = NULL;
|
||||
|
||||
// get current locale
|
||||
const char* osx_user_locale()
|
||||
{
|
||||
::free(user_locale);
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
CFLocaleRef myCFLocale = CFLocaleCopyCurrent();
|
||||
NSLocale * myNSLocale = (NSLocale *) myCFLocale;
|
||||
[myNSLocale autorelease];
|
||||
NSString *nsIdentifier = [myNSLocale localeIdentifier];
|
||||
user_locale = ::strdup([nsIdentifier UTF8String]);
|
||||
[pool drain];
|
||||
|
||||
return user_locale;
|
||||
}
|
Reference in New Issue
Block a user