]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/vout.m
macosx: Close embedded if fullscreen ended.
[vlc] / modules / gui / macosx / vout.m
index a59b6f68b07821fb3d02b1e8e432f426f1d346ef..aca5b877862e6543f32e949fa2d988e048807b14 100644 (file)
@@ -819,7 +819,6 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         [o_window setLevel: NSStatusWindowLevel];
     }
 
-
     [o_window setAcceptsMouseMovedEvents: TRUE];
     return b_return;
 }
@@ -884,11 +883,19 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
 @implementation VLCEmbeddedVoutView
 
+- (void)awakeFromNib
+{
+    o_embeddedwindow = [self window];
+}
+
 - (id)initWithFrame: (NSRect)frameRect
 {
-    [super initWithFrame: frameRect];
-    b_used = NO;
-    [[[VLCMain sharedInstance] getEmbeddedList] addEmbeddedVout: self];
+    if(self = [super initWithFrame: frameRect])
+    {
+        b_used = NO;
+        [[[VLCMain sharedInstance] getEmbeddedList] addEmbeddedVout: self];
+        o_embeddedwindow = nil; /* Filled later on in -awakeFromNib */
+    }
     return self;
 }
 
@@ -896,6 +903,9 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
                  frame: (NSRect *)s_arg_frame showWindow: (BOOL)b_show_window
 {
     BOOL b_return;
+
+    [NSObject cancelPreviousPerformRequestsWithTarget:o_window];
+
     b_return = [super setVout: p_arg_vout subView: view frame: s_arg_frame];
     if( b_return )
     {
@@ -911,46 +921,6 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
         [view setFrameSize: [self frame].size];
     }
-    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;
-}
-
-- (BOOL)isUsed
-{
-    return b_used;
-}
-
-- (void)closeVout
-{
-    [super closeVout];
-    [o_window setAcceptsMouseMovedEvents: NO];
-    [[[VLCMain sharedInstance] getEmbeddedList] releaseEmbeddedVout: self];
-}
-
-
-@end
-
-@implementation VLCDetachedEmbeddedVoutView
-- (void)awakeFromNib
-{
-    o_embeddedwindow = [self window];
-}
-
-- (BOOL)setVout: (vout_thread_t *) p_arg_vout subView: (NSView *) view
-                     frame: (NSRect *) s_arg_frame
-{
-    BOOL b_return = [super setVout: p_arg_vout subView: view frame: s_arg_frame showWindow: NO];
 
     /* o_window needs to point to our o_embeddedwindow, super might have set it
      * to the fullscreen window that o_embeddedwindow setups during fullscreen */
@@ -964,6 +934,8 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
         [self updateTitle];
 
+        [NSObject cancelPreviousPerformRequestsWithTarget:o_window];
+
         /* Make the window the front and key window before animating */
         if ([o_window isVisible] && (![o_window isFullscreen]))
             [o_window makeKeyAndOrderFront: self];
@@ -978,24 +950,37 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         [o_window unlockFullscreenAnimation];
 
     }
+
     return b_return;
 }
 
-- (void)closeVout
+- (BOOL)setVout: (vout_thread_t *) p_arg_vout subView: (NSView *) view
+                     frame: (NSRect *) s_arg_frame
+
 {
-    playlist_t * p_playlist = pl_Yield( VLCIntf );
-    PL_LOCK;
-    bool stopped = playlist_IsStopped( p_playlist );
-    PL_UNLOCK;
+    return [self setVout: p_arg_vout subView: view frame:s_arg_frame showWindow: YES];
+}
 
-    if(stopped)
-        [o_window performSelectorOnMainThread: @selector(orderOut:) withObject: self waitUntilDone: YES];
-    else
-        msg_Dbg( VLCIntf, "we are not closing the window, playlist is playing" );
+- (void)setUsed: (BOOL)b_new_used
+{
+    b_used = b_new_used;
+}
 
-    vlc_object_release( p_playlist );
+- (BOOL)isUsed
+{
+    return b_used;
+}
+
+- (void)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 */
+    [o_embeddedwindow performSelector:@selector(orderOut:) withObject:nil afterDelay:1.5];
 
     [super closeVout];
+    [o_window setAcceptsMouseMovedEvents: NO];
+    [[[VLCMain sharedInstance] getEmbeddedList] releaseEmbeddedVout: self];
 }
 
 - (void)enterFullscreen
@@ -1023,7 +1008,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     o_view  = view;
     s_frame = frame;
 
-    [self performSelectorOnMainThread: @selector(initReal:)
+    [self performSelectorOnMainThread: @selector(initMainThread:)
         withObject: NULL waitUntilDone: YES];
 
     if( !b_init_ok )
@@ -1034,7 +1019,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     return self;
 }
 
-- (id)initReal: (id) sender
+- (id)initMainThread: (id) sender
 {
     NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
     NSArray *o_screens = [NSScreen screens];
@@ -1163,11 +1148,11 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 {
     /* XXX waitUntilDone = NO to avoid a possible deadlock when hitting
        Command-Q */
-    [self performSelectorOnMainThread: @selector(closeReal:)
+    [self performSelectorOnMainThread: @selector(closeMainThread:)
         withObject: NULL waitUntilDone: NO];
 }
 
-- (id)closeReal:(id)sender
+- (id)closeMainThread:(id)sender
 {
     if( b_black == true )
     {