Mac-specific: Fix for retina display

This commit is contained in:
Abs62 2014-06-17 17:47:04 +04:00
parent 9cf51acc89
commit 62d380a1d9
3 changed files with 24 additions and 1 deletions

View file

@ -15,6 +15,9 @@ public:
* Adds fullscreen button to window for Lion. * Adds fullscreen button to window for Lion.
*/ */
static void addFullscreen(MainWindow *window); static void addFullscreen(MainWindow *window);
//Check for retina display
static bool isRetinaDisplay();
}; };
#endif // LIONSUPPORT_H #endif // LIONSUPPORT_H

View file

@ -1,4 +1,5 @@
#include <AppKit/NSWindow.h> #include <AppKit/NSWindow.h>
#include <AppKit/NSScreen.h>
#include "lionsupport.h" #include "lionsupport.h"
bool LionSupport::isLion() bool LionSupport::isLion()
@ -21,3 +22,13 @@ void LionSupport::addFullscreen(MainWindow *window)
#warning No fullscreen support will be included in this build #warning No fullscreen support will be included in this build
#endif #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
}

11
main.cc
View file

@ -33,6 +33,10 @@
#include "gddebug.hh" #include "gddebug.hh"
#ifdef Q_OS_MAC
#include "lionsupport.h"
#endif
void gdMessageHandler( QtMsgType type, const char *msg ) void gdMessageHandler( QtMsgType type, const char *msg )
{ {
QString message = QString::fromUtf8( msg ); QString message = QString::fromUtf8( msg );
@ -83,7 +87,12 @@ int main( int argc, char ** argv )
{ {
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
setenv("LANG", "en_US.UTF-8", 1); 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 #endif
// The following clause fixes a race in the MinGW runtime where throwing // The following clause fixes a race in the MinGW runtime where throwing