23 #include "precompiled.h"
32 #include <ApplicationServices/ApplicationServices.h>
33 #include <AvailabilityMacros.h>
34 #include <CoreFoundation/CoreFoundation.h>
35 #include <mach-o/dyld.h>
58 size_t len = wcslen(wstr.c_str());
59 ret = (
wchar_t*)malloc((len+1)*
sizeof(
wchar_t));
60 std::copy(wstr.c_str(), wstr.c_str()+len, ret);
78 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
79 CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(kCGDirectMainDisplay);
81 CFDictionaryRef currentMode = CGDisplayCurrentMode(kCGDirectMainDisplay);
85 *xres = (int)CGDisplayPixelsWide(kCGDirectMainDisplay);
88 *yres = (int)CGDisplayPixelsHigh(kCGDirectMainDisplay);
92 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
94 CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding(currentMode);
95 if (CFStringCompare(pixelEncoding, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
97 else if (CFStringCompare(pixelEncoding, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
99 else if (CFStringCompare(pixelEncoding, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
105 CFRelease(pixelEncoding);
107 CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(currentMode, kCGDisplayBitsPerPixel);
108 CFNumberGetValue(num, kCFNumberIntType, bpp);
114 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
115 *freq = (int)CGDisplayModeGetRefreshRate(currentMode);
117 CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(currentMode, kCGDisplayRefreshRate);
118 CFNumberGetValue(num, kCFNumberIntType, freq);
122 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
124 CGDisplayModeRelease(currentMode);
154 if (_NSGetExecutablePath(temp, &size) == 0)
157 realpath(temp, name);
C++ interface to Cocoa implementation for pasteboards.
Status sys_clipboard_set(const wchar_t *text)
bool osx_IsAppBundleValid()
Check if app is running in a valid bundle.
std::string utf8_from_wstring(const std::wstring &src, Status *err)
opposite of wstring_from_utf8
LIB_API Status GetVideoMode(int *xres, int *yres, int *bpp, int *freq)
(useful for choosing a new video mode)
Status sys_clipboard_free(wchar_t *copy)
C++ interface to Cocoa implementation for getting bundle information.
const Status NOT_SUPPORTED
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
bool osx_GetStringFromPasteboard(std::string &out)
Get a string from the pasteboard.
i64 Status
Error handling system.
LIB_API Status GetMonitorSize(int &width_mm, int &height_mm)
(useful for determining aspect ratio)
wchar_t * sys_clipboard_get()
std::wstring wstring_from_utf8(const std::string &src, Status *err)
convert UTF-8 to a wide string (UTF-16 or UCS-4, depending on the platform's wchar_t).
OsPath sys_ExecutablePathname()
bool osx_SendStringToPasteboard(const std::string &string)
Store a string on the pasteboard.
std::string osx_GetBundlePath()
Get the system path to the bundle itself.