]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/embeddedwindow.m
macosx: Fix a dead lock.
[vlc] / modules / gui / macosx / embeddedwindow.m
index d7cd72cc26c29de2c4ec2e237ff8b2954ee9f12c..5fceaa999635c2d6a392bd86ae895a08ac656000 100644 (file)
     [o_btn_fullscreen setState: NO];
     b_fullscreen = NO;
 
+    [self setMovableByWindowBackground:YES];
+
+    [self setDelegate:self];
+
     /* Make sure setVisible: returns NO */
     [self orderOut:self];
+    b_window_is_invisible = YES;
+    videoRatio = NSMakeSize( 0., 0. );
 }
 
 - (void)controlTintChanged
         return o_view;
 }
 
+- (void)setVideoRatio:(NSSize)ratio
+{
+    videoRatio = ratio;
+}
+
+- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
+{
+    if( videoRatio.height == 0. || videoRatio.width == 0. )
+        return proposedFrameSize;
+
+    NSRect viewRect = [o_view convertRect:[o_view bounds] toView: nil];
+    NSRect contentRect = [self contentRectForFrameRect:[self frame]];
+    float marginy = viewRect.origin.y + [self frame].size.height - contentRect.size.height;
+    float marginx = contentRect.size.width - viewRect.size.width;
+    proposedFrameSize.height = (proposedFrameSize.width - marginx) * videoRatio.height / videoRatio.width + marginy;
+
+    return proposedFrameSize;
+}
+
 /*****************************************************************************
  * Fullscreen support
  */
         /* Will release the lock */
         [self hasEndedFullscreen];
 
+        /* Our window is hidden, and might be faded. We need to workaround that, so note it
+         * here */
+        b_window_is_invisible = YES;
+
         CGDisplayFade( token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
         CGReleaseDisplayFadeReservation( token);
         return;
      * having a window that is faded. We can't have it fade in unless we
      * animate again. */
 
+    if(!b_window_is_invisible)
+    {
+        /* Make sure we don't do it too much */
+        [super makeKeyAndOrderFront: sender];
+        return;
+    }
+
     [super setAlphaValue:0.0f];
     [super makeKeyAndOrderFront: sender];
 
     [anim setFrameRate: 30];
 
     [anim startAnimation];
+    b_window_is_invisible = NO;
+
     /* fullscreenAnimation will be unlocked when animation ends */
 }