diff --git a/src/modules/video_render/main/source/mac/video_render_nsopengl.h b/src/modules/video_render/main/source/mac/video_render_nsopengl.h index a11e0c11b..cdd3be74a 100644 --- a/src/modules/video_render/main/source/mac/video_render_nsopengl.h +++ b/src/modules/video_render/main/source/mac/video_render_nsopengl.h @@ -182,6 +182,8 @@ private: // variables std::multimap _zOrderToChannel; unsigned int _threadID; bool _renderingIsPaused; + NSView* _windowRefSuperView; + NSRect _windowRefSuperViewFrame; }; } //namespace webrtc diff --git a/src/modules/video_render/main/source/mac/video_render_nsopengl.mm b/src/modules/video_render/main/source/mac/video_render_nsopengl.mm index 645b52eb1..782c2cec1 100644 --- a/src/modules/video_render/main/source/mac/video_render_nsopengl.mm +++ b/src/modules/video_render/main/source/mac/video_render_nsopengl.mm @@ -387,7 +387,9 @@ _windowHeight( 0), _nsglChannels( ), _zOrderToChannel( ), _threadID (0), -_renderingIsPaused (FALSE) +_renderingIsPaused (FALSE), +_windowRefSuperView(NULL), +_windowRefSuperViewFrame(NSMakeRect(0,0,0,0)) { _screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc, this, kRealtimePriority); _screenUpdateEvent = EventWrapper::Create(); @@ -609,11 +611,17 @@ int VideoRenderNSOpenGL::setRenderTargetFullScreen() NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*) attribs]; + // Store original superview and frame for use when exiting full screens + _windowRefSuperViewFrame = [_windowRef frame]; + _windowRefSuperView = [_windowRef superview]; + + // create new fullscreen window NSRect screenRect = [[NSScreen mainScreen]frame]; [_windowRef setFrame:screenRect]; [_windowRef setBounds:screenRect]; + _fullScreenWindow = [[CocoaFullScreenWindow alloc]init]; [_fullScreenWindow grabFullScreen]; [[[_fullScreenWindow window] contentView] addSubview:_windowRef]; @@ -650,8 +658,18 @@ VideoRenderNSOpenGL::~VideoRenderNSOpenGL() { if(_fullScreenWindow) { + // Detach CocoaRenderView from full screen view back to + // it's original parent. + [_windowRef removeFromSuperview]; + if(_windowRefSuperView) + { + [_windowRefSuperView addSubview:_windowRef]; + [_windowRef setFrame:_windowRefSuperViewFrame]; + } + WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, 0, "%s:%d Attempting to release fullscreen window", __FUNCTION__, __LINE__); [_fullScreenWindow releaseFullScreen]; + } }