When entering fullscreen mode, the CocoaRenderView is attached as a subview to a new full screen window.

When the class is torn down, the view was not being attached back to it's original NSView. I added a 
new class variable to remember the original superview and then reattach it at the appropriate time.
Review URL: http://webrtc-codereview.appspot.com/290009

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1070 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
zakkhoyt@webrtc.org 2011-11-30 22:30:50 +00:00
parent b9db43e1b6
commit a7e70b43e2
2 changed files with 21 additions and 1 deletions

View File

@ -182,6 +182,8 @@ private: // variables
std::multimap<int, int> _zOrderToChannel;
unsigned int _threadID;
bool _renderingIsPaused;
NSView* _windowRefSuperView;
NSRect _windowRefSuperViewFrame;
};
} //namespace webrtc

View File

@ -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];
}
}