diff options
Diffstat (limited to 'intern/ghost')
-rw-r--r-- | intern/ghost/GHOST_C-api.h | 2 | ||||
-rw-r--r-- | intern/ghost/GHOST_ISystem.h | 2 | ||||
-rw-r--r-- | intern/ghost/GHOST_IWindow.h | 4 | ||||
-rw-r--r-- | intern/ghost/GHOST_Types.h | 1 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_C-api.cpp | 8 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_System.cpp | 7 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_System.h | 3 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCocoa.mm | 7 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_Window.cpp | 3 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_Window.h | 10 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowCocoa.h | 5 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowCocoa.mm | 20 |
12 files changed, 55 insertions, 17 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index ab5feb287d8..ffdee6c1550 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -860,7 +860,7 @@ extern int GHOST_UseNativePixels(void); /** * If window was opened using native pixel size, it returns scaling factor. */ -extern float GHOST_GetNativePixelSize(void); +extern float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle); #ifdef __cplusplus diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index dfe01521a29..1b3509c1ac3 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -297,10 +297,8 @@ public: /** * Native pixel size support (MacBook 'retina'). - * \return The pixel size in float. */ virtual bool useNativePixel(void) = 0; - virtual float getNativePixelSize(void) = 0; /*************************************************************************************** * Event management functionality diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h index 88f130aabe8..4cf0dbfb820 100644 --- a/intern/ghost/GHOST_IWindow.h +++ b/intern/ghost/GHOST_IWindow.h @@ -305,6 +305,10 @@ public: */ virtual GHOST_TSuccess setCursorGrab(GHOST_TGrabCursorMode mode, GHOST_Rect *bounds, GHOST_TInt32 mouse_ungrab_xy[2]) { return GHOST_kSuccess; } + + virtual float getNativePixelSize(void) = 0; + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IWindow") #endif diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 868d787b5f9..35dff73f4af 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -183,6 +183,7 @@ typedef enum { GHOST_kEventDraggingDropDone, GHOST_kEventOpenMainFile, // Needed for Cocoa to open double-clicked .blend file at startup + GHOST_kEventNativeResolutionChange, // Needed for Cocoa when window moves to other display GHOST_kEventTimer, diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index ba0a6eba36f..be64acf8c94 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -885,9 +885,11 @@ int GHOST_UseNativePixels(void) return system->useNativePixel(); } -float GHOST_GetNativePixelSize(void) +float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle) { - GHOST_ISystem *system = GHOST_ISystem::getSystem(); - return system->getNativePixelSize(); + GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; + if (window) + return window->getNativePixelSize(); + return 1.0f; } diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index 41beeac6b51..080619bc0ac 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -46,7 +46,6 @@ GHOST_System::GHOST_System() : m_nativePixel(false), - m_nativePixelSize(1), m_displayManager(0), m_timerManager(0), m_windowManager(0), @@ -382,9 +381,3 @@ bool GHOST_System::useNativePixel(void) return 1; } -float GHOST_System::getNativePixelSize(void) -{ - if (m_nativePixel) - return m_nativePixelSize; - return 1.0f; -} diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index 5060f22c509..928bbe6a31b 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -175,9 +175,6 @@ public: virtual bool useNativePixel(void); bool m_nativePixel; - virtual float getNativePixelSize(void); - float m_nativePixelSize; - /*************************************************************************************** * Event management functionality ***************************************************************************************/ diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index ac3e22368bc..f10050bfc54 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -1054,6 +1054,13 @@ GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent(GHOST_TEventType eventType, //m_ignoreWindowSizedMessages = true; } break; + case GHOST_kEventNativeResolutionChange: + + if (m_nativePixel) { + window->setNativePixelSize(); + pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventNativeResolutionChange, window) ); + } + default: return GHOST_kFailure; break; diff --git a/intern/ghost/intern/GHOST_Window.cpp b/intern/ghost/intern/GHOST_Window.cpp index fd3ff4f85f0..ca12abe7324 100644 --- a/intern/ghost/intern/GHOST_Window.cpp +++ b/intern/ghost/intern/GHOST_Window.cpp @@ -61,6 +61,8 @@ GHOST_Window::GHOST_Window( m_cursorGrabAccumPos[0] = 0; m_cursorGrabAccumPos[1] = 0; + + m_nativePixelSize = 1.0f; m_fullScreen = state == GHOST_kWindowStateFullScreen; if (m_fullScreen) { @@ -194,3 +196,4 @@ bool GHOST_Window::getModifiedState() { return m_isUnsavedChanges; } + diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h index fd870327fd4..f7c67bf7be6 100644 --- a/intern/ghost/intern/GHOST_Window.h +++ b/intern/ghost/intern/GHOST_Window.h @@ -257,6 +257,13 @@ public: { m_userData = userData; } + + virtual float getNativePixelSize(void) + { + if (m_nativePixelSize > 0.0f) + return m_nativePixelSize; + return 1.0f; + } protected: /** @@ -351,6 +358,9 @@ protected: GHOST_TUns32 m_fullScreenWidth; /** Full-screen height */ GHOST_TUns32 m_fullScreenHeight; + + /* OSX only, retina screens */ + float m_nativePixelSize; }; diff --git a/intern/ghost/intern/GHOST_WindowCocoa.h b/intern/ghost/intern/GHOST_WindowCocoa.h index 3e5c675d4a7..f1388c0b466 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.h +++ b/intern/ghost/intern/GHOST_WindowCocoa.h @@ -262,6 +262,11 @@ public: * Hides the progress bar icon */ virtual GHOST_TSuccess endProgressBar(); + + + virtual void setNativePixelSize(void); + + protected: /** * Tries to install a rendering context in this window. diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index e89dd1b41dc..772db85b190 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -74,8 +74,10 @@ extern "C" { - (void)windowDidMove:(NSNotification *)notification; - (void)windowWillMove:(NSNotification *)notification; - (BOOL)windowShouldClose:(id)sender; +- (void)windowDidChangeBackingProperties:(NSNotification *)notification; @end + @implementation CocoaWindowDelegate : NSObject - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa { @@ -128,6 +130,11 @@ extern "C" { }*/ } +- (void)windowDidChangeBackingProperties:(NSNotification *)notification +{ + systemCocoa->handleWindowEvent(GHOST_kEventNativeResolutionChange, associatedWindow); +} + - (BOOL)windowShouldClose:(id)sender; { //Let Blender close the window rather than closing immediately @@ -593,7 +600,7 @@ GHOST_WindowCocoa::GHOST_WindowCocoa( [m_openGLView setWantsBestResolutionOpenGLSurface:YES]; NSRect backingBounds = [m_openGLView convertRectToBacking:[m_openGLView bounds]]; - m_systemCocoa->m_nativePixelSize = (float)backingBounds.size.width / (float)rect.size.width; + m_nativePixelSize = (float)backingBounds.size.width / (float)rect.size.width; } } @@ -911,6 +918,17 @@ NSScreen* GHOST_WindowCocoa::getScreen() return [m_window screen]; } +/* called for event, when window leaves monitor to another */ +void GHOST_WindowCocoa::setNativePixelSize(void) +{ + NSRect backingBounds = [m_openGLView convertRectToBacking:[m_openGLView bounds]]; + + GHOST_Rect rect; + getClientBounds(rect); + + m_nativePixelSize = (float)backingBounds.size.width / (float)rect.getWidth(); + +} /** * \note Fullscreen switch is not actual fullscreen with display capture. |