]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/vout.m
macosx: Save current fullscreen state.
[vlc] / modules / gui / macosx / vout.m
index 65822210e5c77aaa77d9a70035edd7589da397ce..bdda538bf230ee4b1903bda306fd3cafeae2b305 100644 (file)
@@ -274,35 +274,31 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     NSString * o_title = nil; 
     NSMutableString * o_mrl = nil;
     input_thread_t * p_input;
+    char * psz_title;
 
-    if( p_vout == NULL )
-    {
-        return;
-    }
+    if( !p_vout ) return;
 
     p_input = vlc_object_find( p_vout, VLC_OBJECT_INPUT, FIND_PARENT );
 
-    if( p_input == NULL )
-    {
-        return;
-    }
+    if( !p_input ) return;
+
+    input_item_t * p_item = input_GetItem( p_input );
+
+    psz_title = input_item_GetNowPlaying ( p_item );
+    if( !psz_title )
+        psz_title = input_item_GetName( p_item );
 
-    char *psz_nowPlaying = input_item_GetNowPlaying ( input_GetItem( p_input ) );
-    char *psz_name = input_item_GetName( input_GetItem( p_input ) );
-    char *psz_uri = input_item_GetURI( input_GetItem( p_input ) );
-    if( psz_nowPlaying != NULL )
-        o_title = [NSString stringWithUTF8String: psz_nowPlaying];
-    else if( psz_name != NULL )
-        o_title = [NSString stringWithUTF8String: psz_name];
+    if( psz_title )
+        o_title = [NSString stringWithUTF8String: psz_title];
 
-    if( psz_uri != NULL )
+    char *psz_uri = input_item_GetURI( p_item );
+    if( psz_uri )
         o_mrl = [NSMutableString stringWithUTF8String: psz_uri];
 
-    FREENULL( psz_nowPlaying );
-    FREENULL( psz_name );
-    FREENULL( psz_uri );
+    free( psz_title );
+    free( psz_uri );
 
-    if( o_title == nil )
+    if( !o_title )
         o_title = o_mrl;
 
     if( o_mrl != nil )
@@ -770,24 +766,18 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
 - (void)enterFullscreen
 {
-    if( var_GetBool( p_real_vout, "video-on-top" ) )
-    {
-        [o_window setLevel: NSNormalWindowLevel];
-    }
-
-    [[o_view class] performSelectorOnMainThread:@selector(resetVout:) withObject:[NSValue valueWithPointer:p_vout] waitUntilDone:YES];
-    [[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
+    /* Save the settings for next playing item */
+    playlist_t * p_playlist = pl_Yield( p_real_vout );
+    var_SetBool( p_playlist, "fullscreen", true );
+    pl_Release( p_real_vout );
 }
 
 - (void)leaveFullscreen
 {
-    if( var_GetBool( p_real_vout, "video-on-top" ) )
-    {
-        [o_window setLevel: NSStatusWindowLevel];
-    }
-
-    [[o_view class] performSelectorOnMainThread:@selector(resetVout:) withObject:[NSValue valueWithPointer:p_vout] waitUntilDone:YES];
-    [[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil];
+    /* Save the settings for next playing item */
+    playlist_t * p_playlist = pl_Yield( p_real_vout );
+    var_SetBool( p_playlist, "fullscreen", false );
+    pl_Release( p_real_vout );
 }
 
 @end
@@ -875,6 +865,33 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     }
 }
 
+
+- (void)enterFullscreen
+{
+    [super enterFullscreen];
+
+    if( var_GetBool( p_real_vout, "video-on-top" ) )
+    {
+        [o_window setLevel: NSNormalWindowLevel];
+    }
+
+    [[o_view class] performSelectorOnMainThread:@selector(resetVout:) withObject:[NSValue valueWithPointer:p_vout] waitUntilDone:YES];
+    [[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
+}
+
+- (void)leaveFullscreen
+{
+    [super leaveFullscreen];
+
+    if( var_GetBool( p_real_vout, "video-on-top" ) )
+    {
+        [o_window setLevel: NSStatusWindowLevel];
+    }
+
+    [[o_view class] performSelectorOnMainThread:@selector(resetVout:) withObject:[NSValue valueWithPointer:p_vout] waitUntilDone:YES];
+    [[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil];
+}
+
 @end
 
 /*****************************************************************************
@@ -900,7 +917,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 }
 
 - (BOOL)setVout: (vout_thread_t *) p_arg_vout subView: (NSView *) view
-                 frame: (NSRect *)s_arg_frame showWindow: (BOOL)b_show_window
+                 frame: (NSRect *)s_arg_frame
 {
     BOOL b_return;
 
@@ -910,8 +927,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     if( b_return )
     {
         o_window = [self window];
-        if (b_show_window)
-            [o_window makeKeyAndOrderFront: self];
+
         [o_window setAcceptsMouseMovedEvents: TRUE];
 
         if( var_GetBool( p_real_vout, "video-on-top" ) )
@@ -954,13 +970,6 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     return b_return;
 }
 
-- (BOOL)setVout: (vout_thread_t *) p_arg_vout subView: (NSView *) view
-                     frame: (NSRect *) s_arg_frame
-
-{
-    return [self setVout: p_arg_vout subView: view frame:s_arg_frame showWindow: YES];
-}
-
 - (void)setUsed: (BOOL)b_new_used
 {
     b_used = b_new_used;
@@ -973,25 +982,31 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
 - (void)closeVout
 {
+    [super closeVout];
+
     /* Don't close the window yet, wait a bit to see if a new input is poping up */
     /* FIXME: Probably fade the window In and Out */
     /* FIXME: fix core */
-    if(![self isFullscreen])
-        [o_window performSelector:@selector(orderOut:) withObject:nil afterDelay:1.5];
+    [o_embeddedwindow performSelector:@selector(orderOut:) withObject:nil afterDelay:1.5];
 
-    [super closeVout];
     [o_window setAcceptsMouseMovedEvents: NO];
     [[[VLCMain sharedInstance] getEmbeddedList] releaseEmbeddedVout: self];
 }
 
 - (void)enterFullscreen
 {
+    /* Save settings */
+    [super enterFullscreen];
+
     /* We are in a VLCEmbeddedWindow */
     [o_embeddedwindow performSelectorOnMainThread: @selector(enterFullscreen) withObject: NULL waitUntilDone: YES];
 }
 
 - (void)leaveFullscreen
 {
+    /* Save settings */
+    [super leaveFullscreen];
+
     /* We are in a VLCEmbeddedWindow */
     [o_embeddedwindow performSelectorOnMainThread: @selector(leaveFullscreen) withObject: NULL waitUntilDone: YES];
 }
@@ -1212,5 +1227,4 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     return NO;
 }
 
-
 @end