From 0f35f0e41d10ffb2e6298d474bd415a402bde1f4 Mon Sep 17 00:00:00 2001 From: gecko_reverse Date: Sun, 21 Sep 2008 05:02:35 +0000 Subject: [PATCH] VideoOutputView registers for window resize notification it's in so it can update it's drawable object --- desmume/src/cocoa/video_output_view.m | 34 +++++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/desmume/src/cocoa/video_output_view.m b/desmume/src/cocoa/video_output_view.m index 0a006dd8e..dfe16231b 100644 --- a/desmume/src/cocoa/video_output_view.m +++ b/desmume/src/cocoa/video_output_view.m @@ -48,7 +48,7 @@ messageDialog(NSLocalizedString(@"Error", nil), @"Couldn't create a view for video output"); return nil; } - + screen_buffer = nil; //Initialize image view if for displaying the screen ---------------------------------------- @@ -57,7 +57,7 @@ [self setImageScaling:NSScaleToFit]; [self setEditable:NO]; [self setEnabled:NO]; - + //Initialize the OpenGL context for displaying the screen ----------------------------------- #else //Create the pixel format for our video output view @@ -160,15 +160,22 @@ #ifdef HAVE_OPENGL - (void)viewDidMoveToWindow -{ - //the setView message doesnt work if the view - //isn't in a window, which is the case in the init func - //so we use this callback to bind the context to the window +{//if the view moves to another window we need to update the drawable object + + if(!context)return; + + //withdraw from recieving updates on previously window, if any + [[NSNotificationCenter defaultCenter] removeObserver:context]; if([self window] != nil) + { [context setView:self]; - else - [context clearDrawable]; + + //udpate drawable if the window changed + [[NSNotificationCenter defaultCenter] addObserver:context selector:@selector(update) name:@"NSWindowDidResizeNotification" object:[self window]]; + + } else [context clearDrawable]; + } #endif @@ -198,14 +205,14 @@ { [super setFrame:rect]; - [context update]; [context makeCurrentContext]; + [context update]; //set the viewport (so the raster pos will be correct) glViewport(0, 0, rect.size.width, rect.size.height); float angle = [self boundsRotation]; - + if(angle == 0) { glRasterPos2f(-1, 1); @@ -242,9 +249,9 @@ - (void)setBoundsRotation:(CGFloat)angle { float old_angle = [self boundsRotation]; - + [super setBoundsRotation:angle]; - + [context makeCurrentContext]; NSSize size = [self frame].size; @@ -272,9 +279,10 @@ [screen_buffer rotateTo90]; if(VERTICAL(angle) && HORIZONTAL(old_angle)) - [screen_buffer rotateTo0]; + [screen_buffer rotateTo0]; } #endif + @end #ifdef HAVE_OPENGL