File diff r25018:67412c730caa → r25019:7bd7e70574c6
src/video/cocoa/cocoa_v.mm
Show inline comments
 
@@ -34,24 +34,25 @@
 
#include "../../blitter/factory.hpp"
 
#include "../../framerate_type.h"
 
#include "../../gfx_func.h"
 
#include "../../thread.h"
 
#include "../../core/random_func.hpp"
 
#include "../../progress.h"
 
#include "../../settings_type.h"
 
#include "../../window_func.h"
 
#include "../../window_gui.h"
 

	
 
#import <sys/param.h> /* for MAXPATHLEN */
 
#import <sys/time.h> /* gettimeofday */
 
#include <array>
 

	
 
/**
 
 * Important notice regarding all modifications!!!!!!!
 
 * There are certain limitations because the file is objective C++.
 
 * gdb has limitations.
 
 * C++ and objective C code can't be joined in all cases (classes stuff).
 
 * Read http://developer.apple.com/releasenotes/Cocoa/Objective-C++.html for more information.
 
 */
 

	
 
/* On some old versions of MAC OS this may not be defined.
 
 * Those versions generally only produce code for PPC. So it should be safe to
 
 * set this to 0. */
 
@@ -220,24 +221,48 @@ bool VideoDriver_Cocoa::AfterBlitterChan
 

	
 
/**
 
 * An edit box lost the input focus. Abort character compositing if necessary.
 
 */
 
void VideoDriver_Cocoa::EditBoxLostFocus()
 
{
 
	[ [ this->cocoaview inputContext ] discardMarkedText ];
 
	/* Clear any marked string from the current edit box. */
 
	HandleTextInput(nullptr, true);
 
}
 

	
 
/**
 
 * Get refresh rates of all connected monitors.
 
 */
 
std::vector<int> VideoDriver_Cocoa::GetListOfMonitorRefreshRates()
 
{
 
	std::vector<int> rates{};
 

	
 
	if (MacOSVersionIsAtLeast(10, 6, 0)) {
 
		std::array<CGDirectDisplayID, 16> displays;
 

	
 
		uint32_t count = 0;
 
		CGGetActiveDisplayList(displays.size(), displays.data(), &count);
 

	
 
		for (uint32_t i = 0; i < count; i++) {
 
			CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displays[i]);
 
			int rate = (int)CGDisplayModeGetRefreshRate(mode);
 
			if (rate > 0) rates.push_back(rate);
 
			CGDisplayModeRelease(mode);
 
		}
 
	}
 

	
 
	return rates;
 
}
 

	
 
/**
 
 * Get the resolution of the main screen.
 
 */
 
Dimension VideoDriver_Cocoa::GetScreenSize() const
 
{
 
	NSRect frame = [ [ NSScreen mainScreen ] frame ];
 
	return { static_cast<uint>(NSWidth(frame)), static_cast<uint>(NSHeight(frame)) };
 
}
 

	
 
/** Get DPI scale of our window. */
 
float VideoDriver_Cocoa::GetDPIScale()
 
{
 
	return this->cocoaview != nil ? [ this->cocoaview getContentsScale ] : 1.0f;