From 6ccde705af0d0f544b14c954984e82f94945099e Mon Sep 17 00:00:00 2001 From: Pierre d'Herbemont Date: Sat, 3 Mar 2007 02:57:34 +0000 Subject: [PATCH] Mac OS X gui: Rework VLCVoutWindow behaviour when macosx-black is set. (Pointed by hartman) --- modules/gui/macosx/misc.m | 11 +++++++++-- modules/gui/macosx/vout.m | 24 ++++++++++++++++-------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m index 9f313272bb..afd485a3ef 100644 --- a/modules/gui/macosx/misc.m +++ b/modules/gui/macosx/misc.m @@ -116,15 +116,22 @@ static NSMutableArray *blackoutWindows = NULL; for(i = 0; i < [[NSScreen screens] count]; i++) { - VLCWindow *blackoutWindow; NSScreen *screen = [[NSScreen screens] objectAtIndex: i]; + VLCWindow *blackoutWindow; + NSRect screen_rect; + if([self isScreen: screen]) continue; + + screen_rect = [screen frame]; + screen_rect.origin.x = screen_rect.origin.y = 0.0f; + /* blackoutWindow alloc strategy - The NSMutableArray blackoutWindows has the blackoutWindow references - blackoutOtherDisplays is responsible for alloc/releasing its Windows */ - blackoutWindow = [[VLCWindow alloc] initWithContentRect: [screen frame] styleMask: NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; + blackoutWindow = [[VLCWindow alloc] initWithContentRect: screen_rect styleMask: NSBorderlessWindowMask + backing: NSBackingStoreBuffered defer: NO screen: screen]; [blackoutWindow setBackgroundColor:[NSColor blackColor]]; [blackoutWindow setLevel: NSFloatingWindowLevel]; /* Disappear when Expose is triggered */ diff --git a/modules/gui/macosx/vout.m b/modules/gui/macosx/vout.m index 162e7b9a17..94d0437b9c 100644 --- a/modules/gui/macosx/vout.m +++ b/modules/gui/macosx/vout.m @@ -1003,7 +1003,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, p_real_vout = [VLCVoutView getRealVout: p_vout]; i_device = var_GetInteger( p_real_vout->p_libvlc, "video-device" ); - b_black = var_GetBool( p_vout, "macosx-black" ); + b_black = NO; b_embedded = var_GetBool( p_vout, "macosx-embedded" ); /* Find out on which screen to open the window */ @@ -1021,6 +1021,8 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, NSRect screen_rect = [o_screen frame]; screen_rect.origin.x = screen_rect.origin.y = 0; + b_black = var_GetBool( p_vout, "macosx-black" ); + /* move the FSPanel to front in case that it is currently shown * this won't and is not supposed to work when it's fading right now */ if( [[[[VLCMain sharedInstance] getControls] getFSPanel] isDisplayed] ) @@ -1035,9 +1037,6 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, backing: NSBackingStoreBuffered defer: YES screen: o_screen]; - if( b_black == VLC_TRUE ) - [o_screen blackoutOtherScreens]; - if( b_menubar_screen ) { SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar); @@ -1045,7 +1044,11 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, if( b_black == VLC_TRUE ) { CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token); - CGDisplayFade( token, 2 , kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, false ); + CGDisplayFade( token, 0.6 , kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES ); + + [o_screen blackoutOtherScreens]; + + CGDisplayFade( token, 0.3 , kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO ); CGReleaseDisplayFadeReservation( token); } } @@ -1117,22 +1120,27 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, { /* XXX waitUntilDone = NO to avoid a possible deadlock when hitting Command-Q */ - [self setContentView: NULL]; [self performSelectorOnMainThread: @selector(closeReal:) withObject: NULL waitUntilDone: NO]; } - (id)closeReal:(id)sender { - [NSScreen unblackoutScreens]; if( b_black == VLC_TRUE ) { CGDisplayFadeReservationToken token; CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token); - CGDisplayFade( token, 2, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, false ); + CGDisplayFade( token, 0.3 , kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES ); + + [self disableScreenUpdatesUntilFlush]; + [self orderOut: self]; + + CGDisplayFade( token, 0.6 , kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, YES ); CGReleaseDisplayFadeReservation( token); CGDisplayRestoreColorSyncSettings(); } + [NSScreen unblackoutScreens]; + SetSystemUIMode( kUIModeNormal, 0); [super close]; /* this does only work in embedded mode */ -- 2.39.2