]> git.sesse.net Git - vlc/commitdiff
Add --macosx-black switch to black non video screens (fix #301)
authorJérome Decoodt <djc@videolan.org>
Tue, 14 Feb 2006 01:40:59 +0000 (01:40 +0000)
committerJérome Decoodt <djc@videolan.org>
Tue, 14 Feb 2006 01:40:59 +0000 (01:40 +0000)
If someone has a better code to maintain a black screen, change
CGSetDisplayTransferByFormula which seems to be a big kludge.

modules/gui/macosx/macosx.m
modules/gui/macosx/vout.h
modules/gui/macosx/vout.m

index 756cfa6bbbe9d8c0b00c74b79652d0d6db280473..19b2b9debe87e7c13865fa5dbe9313b8a87e35ff 100644 (file)
@@ -70,7 +70,10 @@ void E_(CloseVideoGL) ( vlc_object_t * );
 #define FILL_LONGTEXT N_("In fullscreen mode, crop the picture if " \
         "necessary in order to fill the screen without black " \
         "borders (OpenGL only)." )
-        
+
+#define BLACK_TEXT N_("Black screens in fullscreen")
+#define BLACK_LONGTEXT N_("In fullscreen mode, black non-video screens." )
+
 #define BACKGROUND_TEXT N_("Use as Desktop Background")
 #define BACKGROUND_LONGTEXT N_("Use the video as the Desktop Background " \
         "of the Finder. Desktop icons cannot be interacted with in this mode." )
@@ -104,6 +107,8 @@ vlc_module_begin();
                      VLC_FALSE );
         add_float_with_range( "macosx-opaqueness", 1, 0, 1, NULL,
                 OPAQUENESS_TEXT, OPAQUENESS_LONGTEXT, VLC_TRUE );
+        add_bool( "macosx-black", 0, NULL, BLACK_TEXT, BLACK_LONGTEXT,
+                  VLC_TRUE );
         add_bool( "macosx-fill", 0, NULL, FILL_TEXT, FILL_LONGTEXT,
                   VLC_TRUE );
         add_bool( "macosx-background", 0, NULL, BACKGROUND_TEXT, BACKGROUND_LONGTEXT,
index 13f691abbeeb5c31d2aa6a8c3e508d50e2b73633..2d5ae67ad35697d59bf9582ef6e074d393e1d6e8 100644 (file)
 
     vout_thread_t * p_real_vout;
     Ptr             p_fullscreen_state;
+    vlc_bool_t      b_fullscreen;
     vlc_bool_t      b_init_ok;
 }
 
index 4b12e94e9485d8278102daa7fea78c87bb4c605c..c009513102e206fd2799b839adb8609906ac2ad0 100644 (file)
@@ -699,6 +699,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     var_Create( p_vout, "macosx-stretch", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "macosx-opaqueness", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "macosx-background", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+    var_Create( p_vout, "macosx-black", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "macosx-embedded", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
 
 
@@ -934,7 +935,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     b_init_ok = VLC_FALSE;
 
     p_fullscreen_state = NULL;
-
+    b_fullscreen = VLC_FALSE;
     p_real_vout = [VLCVoutView getRealVout: p_vout];
     i_device = var_GetInteger( p_real_vout->p_vlc, "video-device" );
 
@@ -943,6 +944,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     {
          /* No preference specified. Use the main screen */
         o_screen = [NSScreen mainScreen];
+        i_device = [o_screens indexOfObject: o_screen];
         if( o_screen == [o_screens objectAtIndex: 0] )
             b_menubar_screen = VLC_TRUE;
     }
@@ -955,6 +957,8 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
     if( p_vout->b_fullscreen )
     {
+        CGDisplayFadeReservationToken token;
+        b_fullscreen = VLC_TRUE;
         NSRect screen_rect = [o_screen frame];
         screen_rect.origin.x = screen_rect.origin.y = 0;
 
@@ -964,11 +968,54 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
               backing: NSBackingStoreBuffered
               defer: YES screen: o_screen];
 
+        if( var_GetBool( p_vout, "macosx-black" ) )
+        {
+            CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
+            CGDisplayFade( token, 0.5, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, true );
+            CGReleaseDisplayFadeReservation( token );
+            int i;
+            for( i = 0 ; i < [o_screens count]; i++)
+            {
+                struct
+                {
+                    CGDirectDisplayID displayID;
+                    CGGammaValue redMin, redMax, redGamma,
+                                 greenMin, greenMax, greenGamma,
+                                 blueMin, blueMax, blueGamma;
+                } dispSettings;
+                CGDisplayCount dspyCnt;
+                CGPoint gPoint;
+
+                if( i == i_device ) continue;
+
+                screen_rect = [[o_screens objectAtIndex: i] frame];
+
+                gPoint.x = screen_rect.origin.x;
+                gPoint.y = screen_rect.origin.y;
+                CGGetDisplaysWithPoint( gPoint, 1, &(dispSettings.displayID), &dspyCnt);
+                CGGetDisplayTransferByFormula(
+                    dispSettings.displayID,
+                    &dispSettings.redMin, &dispSettings.redMax, &dispSettings.redGamma,
+                    &dispSettings.greenMin, &dispSettings.greenMax, &dispSettings.greenGamma,
+                    &dispSettings.blueMin, &dispSettings.blueMax, &dispSettings.blueGamma );
+                CGSetDisplayTransferByFormula(
+                    dispSettings.displayID,
+                    dispSettings.redMin,   0, dispSettings.redGamma,
+                    dispSettings.greenMin, 0, dispSettings.greenGamma,
+                    dispSettings.blueMin,  0, dispSettings.blueGamma );
+            }
+        }
         if( b_menubar_screen )
         {
             BeginFullScreen( &p_fullscreen_state, NULL, 0, 0,
                              NULL, NULL, fullScreenAllowEvents );
         }
+        if( var_GetBool( p_vout, "macosx-black" ) )
+        {
+            CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
+            CGDisplayFade( token, 2, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, false );
+            CGReleaseDisplayFadeReservation( token);
+        }
     }
     else if( var_GetBool( p_real_vout, "macosx-background" ) )
     {
@@ -1050,11 +1097,20 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
 - (id) closeReal: (id) sender
 {
-    [super close];
-    if( p_fullscreen_state )
+    if( b_fullscreen == VLC_TRUE )
     {
-        EndFullScreen( p_fullscreen_state, 0 );
+        if( p_vout->b_fullscreen )
+            EndFullScreen( p_fullscreen_state, 0 );
+        if( var_GetBool( p_vout, "macosx-black" ) )
+        {
+            CGDisplayFadeReservationToken token;
+            CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
+            CGDisplayFade( token, 2, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, false );
+            CGReleaseDisplayFadeReservation( token);
+            CGDisplayRestoreColorSyncSettings();
+        }
     }
+    [super close];
     return NULL;
 }