diff --git a/CMakeLists.txt b/CMakeLists.txt index 62d88945..fb27596f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,9 +97,6 @@ IF(APPLE) ELSEIF(EXISTS /sw/bin) SET(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};/sw/bin") ENDIF() - - # and compile as Objective-C++ for ObjectiveC #ifdefs - SET(CMAKE_CXX_COMPILE_OBJECT " -x objective-c++ -o -c ") ENDIF(APPLE) # We do not support amd64 asm yet diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt index 2065c5f6..916359e2 100644 --- a/src/wx/CMakeLists.txt +++ b/src/wx/CMakeLists.txt @@ -153,6 +153,10 @@ SET( SRC_WX xrc/vbam.xpm ) +IF(APPLE) + SET(SRC_WX ${SRC_WX} macsupport.mm) +ENDIF(APPLE) + SET( HDR_WX wxvbam.h drawing.h diff --git a/src/wx/macsupport.mm b/src/wx/macsupport.mm new file mode 100644 index 00000000..76f2088c --- /dev/null +++ b/src/wx/macsupport.mm @@ -0,0 +1,29 @@ +#import +#import + +#include "wxvbam.h" + +double HiDPIAware::HiDPIScaleFactor() +{ + if (hidpi_scale_factor == 0) { + NSWindow* window = [(NSView*)GetWindow()->GetHandle() window]; + + if ([window respondsToSelector:@selector(backingScaleFactor)]) { + hidpi_scale_factor = [window backingScaleFactor]; + } + else { + hidpi_scale_factor = 1.0; + } + } + + return hidpi_scale_factor; +} + +void HiDPIAware::RequestHighResolutionOpenGLSurface() +{ + NSView* view = (NSView*)(GetWindow()->GetHandle()); + + if ([view respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) { + [view setWantsBestResolutionOpenGLSurface:YES]; + } +} diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index bb6ff65d..d0fe34fd 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -1,10 +1,5 @@ #include -#ifdef __WXMAC__ -#import -#import -#endif - #include "../../version.h" #include "../common/ConfigManager.h" #include "../common/Patch.h" @@ -18,26 +13,6 @@ int emulating; -double HiDPIAware::HiDPIScaleFactor() -{ - if (hidpi_scale_factor == 0) { -#ifdef __WXMAC__ - NSWindow* window = [(NSView*)GetWindow()->GetHandle() window]; - - if ([window respondsToSelector:@selector(backingScaleFactor)]) { - hidpi_scale_factor = [window backingScaleFactor]; - } - else { - hidpi_scale_factor = 1.0; - } -#else - hidpi_scale_factor = 1.0; -#endif - } - - return hidpi_scale_factor; -} - IMPLEMENT_DYNAMIC_CLASS(GameArea, wxPanel) GameArea::GameArea() @@ -2023,13 +1998,7 @@ GLDrawingPanel::GLDrawingPanel(wxWindow* parent, int _width, int _height) wxFULL_REPAINT_ON_RESIZE | wxWANTS_CHARS) , DrawingPanel(_width, _height) { -#ifdef __WXMAC__ - NSView* view = (NSView*)GetHandle(); - - if ([view respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) { - [view setWantsBestResolutionOpenGLSurface:YES]; - } -#endif + RequestHighResolutionOpenGLSurface(); #if wxCHECK_VERSION(2, 9, 0) ctx = new wxGLContext(this); SetCurrent(*ctx); @@ -2479,3 +2448,19 @@ void GameArea::HidePointer() panel->GetWindow()->SetCursor(wxCursor(wxCURSOR_BLANK)); } } + +// stub HiDPI methods, see macsupport.mm for the Mac support +#ifndef __WXMAC__ +double HiDPIAware::HiDPIScaleFactor() +{ + if (hidpi_scale_factor == 0) { + hidpi_scale_factor = 1.0; + } + + return hidpi_scale_factor; +} + +void HiDPIAware::RequestHighResolutionOpenGLSurface() +{ +} +#endif // HiDPI stubs diff --git a/src/wx/wxvbam.h b/src/wx/wxvbam.h index 50f96669..2ae5a174 100644 --- a/src/wx/wxvbam.h +++ b/src/wx/wxvbam.h @@ -345,7 +345,8 @@ private: // helper class to add HiDPI awareness (mostly for Mac OS X) class HiDPIAware { public: - double HiDPIScaleFactor(); + virtual double HiDPIScaleFactor(); + virtual void RequestHighResolutionOpenGLSurface(); virtual wxWindow* GetWindow() = 0; private: double hidpi_scale_factor = 0;