]> git.sesse.net Git - vlc/commitdiff
macosx: improve handling of playlist view state in case of multiple vouts
authorDavid Fuhrmann <david.fuhrmann@googlemail.com>
Mon, 3 Mar 2014 21:22:09 +0000 (22:22 +0100)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Tue, 4 Mar 2014 17:16:24 +0000 (18:16 +0100)
close #10761

modules/gui/macosx/MainWindow.m
modules/gui/macosx/VLCVoutWindowController.m
modules/gui/macosx/intf.m

index f0030b15186e18f5e93625cc50e03f1924129ab3..8788f8c6c0d9e19b29594255ac255499d8ff84b7 100644 (file)
@@ -783,8 +783,9 @@ static VLCMainWindow *_o_sharedInstance = nil;
 
             // only resize back to minimum view of this is still desired final state
             float f_threshold_height = f_min_video_height + [o_controls_bar height];
-            if(frameBeforePlayback.size.height > f_threshold_height || b_minimized_view)
+            if(frameBeforePlayback.size.height > f_threshold_height || b_minimized_view) {
                 [[self animator] setFrame:frameBeforePlayback display:YES];
+            }
         }
 
         frameBeforePlayback = NSMakeRect(0, 0, 0, 0);
@@ -810,8 +811,6 @@ static VLCMainWindow *_o_sharedInstance = nil;
             [o_fspanel setNonActive: nil];
         }
     }
-
-    [self changePlaylistState: psVideoStartedOrStoppedEvent];
 }
 
 #pragma mark -
index 5be5048d2a90a4ad2e835dcb6c8cbd6f5964e8b9..67b67b1e34c950642d208f39619b1c76972a77a2 100644 (file)
@@ -68,7 +68,8 @@
     VLCVideoWindowCommon *o_new_video_window;
 
     // should be called before any window resizing occurs
-    [[VLCMainWindow sharedInstance] videoplayWillBeStarted];
+    if (!b_multiple_vout_windows)
+        [[VLCMainWindow sharedInstance] videoplayWillBeStarted];
 
     if (b_multiple_vout_windows && b_video_wallpaper)
         b_video_wallpaper = false;
             [o_new_video_window setContentMinSize: NSMakeSize(f_min_video_height, f_min_video_height)];
         }
 
-        [[VLCMainWindow sharedInstance] setNonembedded:YES];
         b_nonembedded = YES;
     } else {
         if ((var_InheritBool(VLCIntf, "embedded-video") && !b_mainwindow_has_video)) {
 
     [o_new_video_window setAlphaValue: config_GetFloat(VLCIntf, "macosx-opaqueness")];
 
-    if (!b_multiple_vout_windows)
-        [[VLCMainWindow sharedInstance] setNonembedded:b_nonembedded];
+
 
     [o_vout_view setVoutThread:(vout_thread_t *)p_wnd->p_parent];
     [o_new_video_window setHasActiveVideo: YES];
     [o_vout_dict setObject:[o_new_video_window autorelease] forKey:[NSValue valueWithPointer:p_wnd]];
 
+    [[VLCMainWindow sharedInstance] setNonembedded:!b_mainwindow_has_video];
+
+    // beware of order, setActiveVideoPlayback:, setHasActiveVideo: and setNonembedded: must be called before
+    if ([o_new_video_window class] == [VLCMainWindow class])
+        [[VLCMainWindow sharedInstance] changePlaylistState: psVideoStartedOrStoppedEvent];
+
     if (b_nonembedded) {
         // event occurs before window is created, so call again
         [[VLCMain sharedInstance] playlistUpdated];
         return;
     }
 
-    if ([o_window class] == [VLCMainWindow class])
-        b_mainwindow_has_video = NO;
-
     if ([o_window fullscreen] && ![[VLCMainWindow sharedInstance] nativeFullscreenMode])
         [o_window leaveFullscreen];
 
     // set active video to no BEFORE closing the window to avoid stopping playback
     // due to NSWindowWillCloseNotification
     [o_window setHasActiveVideo: NO];
+
     if ([o_window class] != [VLCMainWindow class]) {
         [o_window close];
         [o_window orderOut:self]; // for dark interface
     }
 
+    [o_window retain];
     [o_vout_dict removeObjectForKey:o_key];
-
     if ([o_vout_dict count] == 0) {
         [[VLCMain sharedInstance] setActiveVideoPlayback:NO];
         i_statusLevelWindowCounter = 0;
     }
+
+    if ([o_window class] == [VLCMainWindow class]) {
+        b_mainwindow_has_video = NO;
+
+        // video in main window might get stopped while another vout is open
+        if ([o_vout_dict count] > 0)
+            [[VLCMainWindow sharedInstance] setNonembedded:YES];
+
+        // beware of order, setActiveVideoPlayback:, setHasActiveVideo: and setNonembedded: must be called before
+        [[VLCMainWindow sharedInstance] changePlaylistState: psVideoStartedOrStoppedEvent];
+    }
+
+    [o_window release];
 }
 
 
index 636a7076cb96c19eb8dd621f993db55ac5b712cf..f5b804dd9ed3e350d7ed7f826df9905233b8e56d 100644 (file)
@@ -135,6 +135,8 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
         return VLC_EGENERIC;
     }
 
+    [[VLCMain sharedInstance] setActiveVideoPlayback: YES];
+
     SEL sel = @selector(setupVoutForWindow:withProposedVideoViewPosition:);
     NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[o_vout_controller methodSignatureForSelector:sel]];
     [inv setTarget:o_vout_controller];
@@ -148,19 +150,14 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
     VLCVoutView *videoView = nil;
     [inv getReturnValue:&videoView];
 
-    if (!videoView) {
-        msg_Err(p_wnd, "got no video view from the interface");
-        [o_vout_provider_lock unlock];
-        [o_pool release];
-        return VLC_EGENERIC;
-    }
+    // this method is not supposed to fail
+    assert(videoView != nil);
 
     msg_Dbg(VLCIntf, "returning videoview with proposed position x=%i, y=%i, width=%i, height=%i", cfg->x, cfg->y, cfg->width, cfg->height);
     p_wnd->handle.nsobject = videoView;
 
     [o_vout_provider_lock unlock];
 
-    [[VLCMain sharedInstance] setActiveVideoPlayback: YES];
     p_wnd->control = WindowControl;
 
     [o_pool release];