From 62d380a1d9c8ba23ce3a05a09375fdc75a1cfc32 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Tue, 17 Jun 2014 17:47:04 +0400 Subject: [PATCH] Mac-specific: Fix for retina display --- lionsupport.h | 3 +++ lionsupport.mm | 11 +++++++++++ main.cc | 11 ++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lionsupport.h b/lionsupport.h index 02d3f0e2..2fd1d897 100644 --- a/lionsupport.h +++ b/lionsupport.h @@ -15,6 +15,9 @@ public: * Adds fullscreen button to window for Lion. */ static void addFullscreen(MainWindow *window); + + //Check for retina display + static bool isRetinaDisplay(); }; #endif // LIONSUPPORT_H diff --git a/lionsupport.mm b/lionsupport.mm index df16ea1a..1917b8f9 100644 --- a/lionsupport.mm +++ b/lionsupport.mm @@ -1,4 +1,5 @@ #include +#include #include "lionsupport.h" bool LionSupport::isLion() @@ -21,3 +22,13 @@ void LionSupport::addFullscreen(MainWindow *window) #warning No fullscreen support will be included in this build #endif } + +bool LionSupport::isRetinaDisplay() +{ +#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + return( [ [ NSScreen mainScreen ] respondsToSelector:@selector( backingScaleFactor ) ] + && [ [ NSScreen mainScreen ] backingScaleFactor ] > 1.5 ); +#else + return false; +#endif +} diff --git a/main.cc b/main.cc index 68f17eb2..ed7cfbac 100644 --- a/main.cc +++ b/main.cc @@ -33,6 +33,10 @@ #include "gddebug.hh" +#ifdef Q_OS_MAC +#include "lionsupport.h" +#endif + void gdMessageHandler( QtMsgType type, const char *msg ) { QString message = QString::fromUtf8( msg ); @@ -83,7 +87,12 @@ int main( int argc, char ** argv ) { #ifdef Q_OS_MAC setenv("LANG", "en_US.UTF-8", 1); - setenv("QT_GRAPHICSSYSTEM", "raster", 1); + + // Check for retina display + if( LionSupport::isRetinaDisplay() ) + QApplication::setGraphicsSystem( "native" ); + else + QApplication::setGraphicsSystem( "raster" ); #endif // The following clause fixes a race in the MinGW runtime where throwing