diff --git a/modules/gui/macosx/MainWindow.h b/modules/gui/macosx/MainWindow.h index 261180e5513fc418f4f129e83aeb1c086a45de4b..dfc1fbbd2ebb07df77993c33922fd035b0de9041 100644 --- a/modules/gui/macosx/MainWindow.h +++ b/modules/gui/macosx/MainWindow.h @@ -101,6 +101,7 @@ + (VLCMainWindow *)sharedInstance; @property (readwrite) BOOL fullscreen; @property (readonly) BOOL nativeFullscreenMode; +@property (readwrite) BOOL nonembedded; @property (readonly) VLCFSPanel* fsPanel; @@ -130,7 +131,6 @@ - (void)showFullscreenController; -- (VLCVoutView *)setupVout:(vout_window_t *)p_wnd; - (void)setVideoplayEnabled; - (void)hideMouseCursor:(NSTimer *)timer; diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m index 6075f0a6147b365d57b08ab1ce573ff38d11120b..94dd5cf0387f8004828fc1b05dcea06247648c00 100644 --- a/modules/gui/macosx/MainWindow.m +++ b/modules/gui/macosx/MainWindow.m @@ -59,6 +59,7 @@ @synthesize fullscreen=b_fullscreen; @synthesize nativeFullscreenMode=b_nativeFullscreenMode; +@synthesize nonembedded=b_nonembedded; @synthesize fsPanel=o_fspanel; static VLCMainWindow *_o_sharedInstance = nil; @@ -708,104 +709,6 @@ static VLCMainWindow *_o_sharedInstance = nil; #pragma mark - #pragma mark Video Output handling -- (VLCVoutView *)setupVout:(vout_window_t *)p_wnd -{ - BOOL b_video_deco = var_InheritBool(VLCIntf, "video-deco"); - BOOL b_video_wallpaper = var_InheritBool(VLCIntf, "video-wallpaper"); - VLCVoutView *o_vout_view; - VLCVideoWindowCommon *o_new_video_window; - - // TODO: make lion fullscreen compatible with video-wallpaper and !embedded-video - if ((b_video_wallpaper || !b_video_deco) && !b_nativeFullscreenMode) { - // b_video_wallpaper is priorized over !b_video_deco - - msg_Dbg(VLCIntf, "Creating background / blank window"); - NSScreen *screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger(VLCIntf, "macosx-vdev")]; - if (!screen) - screen = [self screen]; - - NSRect window_rect; - if (b_video_wallpaper) - window_rect = [screen frame]; - else - window_rect = [self frame]; - - NSUInteger mask = NSBorderlessWindowMask; - if (!OSX_SNOW_LEOPARD && !b_video_deco) - mask |= NSResizableWindowMask; - - BOOL b_no_video_deco_only = !b_video_wallpaper; - o_new_video_window = [[VLCVideoWindowCommon alloc] initWithContentRect:window_rect styleMask:mask backing:NSBackingStoreBuffered defer:YES]; - [o_new_video_window setDelegate:o_new_video_window]; - - if (b_video_wallpaper) - [o_new_video_window setLevel:CGWindowLevelForKey(kCGDesktopWindowLevelKey) + 1]; - - [o_new_video_window setBackgroundColor: [NSColor blackColor]]; - [o_new_video_window setCanBecomeKeyWindow: !b_video_wallpaper]; - [o_new_video_window setCanBecomeMainWindow: !b_video_wallpaper]; - [o_new_video_window setAcceptsMouseMovedEvents: !b_video_wallpaper]; - [o_new_video_window setMovableByWindowBackground: !b_video_wallpaper]; - [o_new_video_window useOptimizedDrawing: YES]; - - o_vout_view = [[VLCVoutView alloc] initWithFrame:[[o_new_video_window contentView] bounds]]; - [o_vout_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; - [[o_new_video_window contentView] addSubview:o_vout_view positioned:NSWindowAbove relativeTo:nil]; - [o_new_video_window setVideoView:o_vout_view]; - - - if (b_video_wallpaper) - [o_new_video_window orderBack:nil]; - else { - [o_new_video_window center]; - [o_new_video_window setFrameAutosaveName:@"extra-videowindow"]; - [o_new_video_window setContentMinSize: NSMakeSize(f_min_video_height, f_min_video_height)]; - } - - b_nonembedded = YES; - } else { - if (var_InheritBool(VLCIntf, "embedded-video") || b_nativeFullscreenMode) { - o_vout_view = [o_video_view retain]; - o_new_video_window = [self retain]; - b_nonembedded = NO; - } else { - NSWindowController *o_controller = [[NSWindowController alloc] initWithWindowNibName:@"DetachedVideoWindow"]; - [o_controller loadWindow]; - o_new_video_window = [(VLCDetachedVideoWindow *)[o_controller window] retain]; - [o_controller release]; - - [o_new_video_window setDelegate: o_new_video_window]; - [o_new_video_window setLevel:NSNormalWindowLevel]; - [o_new_video_window useOptimizedDrawing: YES]; - o_vout_view = [[o_new_video_window videoView] retain]; - b_nonembedded = YES; - } - } - - if (!b_video_wallpaper) { - [o_new_video_window makeKeyAndOrderFront: self]; - - vout_thread_t *p_vout = getVout(); - if (p_vout) { - if (var_GetBool(p_vout, "video-on-top")) - [o_new_video_window setLevel: NSStatusWindowLevel]; - else - [o_new_video_window setLevel: NSNormalWindowLevel]; - vlc_object_release(p_vout); - } - } - - [o_new_video_window setAlphaValue: config_GetFloat(VLCIntf, "macosx-opaqueness")]; - [[[VLCMain sharedInstance] voutController] addVout:[o_new_video_window autorelease] forDisplay:p_wnd]; - - if(b_nonembedded) { - // event occurs before window is created, so call again - [[VLCMain sharedInstance] playbackStatusUpdated]; - } - - return [o_vout_view autorelease]; -} - - (void)setVideoplayEnabled { BOOL b_videoPlayback = [[VLCMain sharedInstance] activeVideoPlayback]; diff --git a/modules/gui/macosx/VLCVoutWindowController.h b/modules/gui/macosx/VLCVoutWindowController.h index 1f3ceb2a0188408f9dbdb8c793a9b6d17fe56255..150e6b35bdd822bf69a8e415365a4d2b5dafc59f 100644 --- a/modules/gui/macosx/VLCVoutWindowController.h +++ b/modules/gui/macosx/VLCVoutWindowController.h @@ -28,13 +28,14 @@ #import <vlc_vout_window.h> @class VLCVideoWindowCommon; +@class VLCVoutView; @interface VLCVoutWindowController : NSObject { NSMutableDictionary *o_vout_dict; } -- (void)addVout:(VLCVideoWindowCommon *)o_window forDisplay:(vout_window_t *)p_wnd; +- (VLCVoutView *)setupVout:(vout_window_t *)p_wnd; - (void)removeVoutforDisplay:(NSValue *)o_key; - (void)updateWindowsControlsBarWithSelector:(SEL)aSel; diff --git a/modules/gui/macosx/VLCVoutWindowController.m b/modules/gui/macosx/VLCVoutWindowController.m index 93a064bfe6ddd9294ec90c850ca0adcc92e89fbe..327f1c3d1c244b7baf9fa56086a8e78731b85f43 100644 --- a/modules/gui/macosx/VLCVoutWindowController.m +++ b/modules/gui/macosx/VLCVoutWindowController.m @@ -24,7 +24,7 @@ #import "VLCVoutWindowController.h" #import "intf.h" -#import "Windows.h" +#import "MainWindow.h" #import "VideoView.h" @implementation VLCVoutWindowController @@ -46,11 +46,108 @@ [super dealloc]; } -- (void)addVout:(VLCVideoWindowCommon *)o_window forDisplay:(vout_window_t *)p_wnd + +- (VLCVoutView *)setupVout:(vout_window_t *)p_wnd { - [[o_window videoView] setVoutThread:(vout_thread_t *)p_wnd->p_parent]; + BOOL b_nonembedded = NO; + BOOL b_nativeFullscreenMode = [[VLCMain sharedInstance] nativeFullscreenMode]; + BOOL b_video_deco = var_InheritBool(VLCIntf, "video-deco"); + BOOL b_video_wallpaper = var_InheritBool(VLCIntf, "video-wallpaper"); + VLCVoutView *o_vout_view; + VLCVideoWindowCommon *o_new_video_window; + + // TODO: make lion fullscreen compatible with video-wallpaper and !embedded-video + if ((b_video_wallpaper || !b_video_deco) && !b_nativeFullscreenMode) { + // b_video_wallpaper is priorized over !b_video_deco + + msg_Dbg(VLCIntf, "Creating background / blank window"); + NSScreen *screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger(VLCIntf, "macosx-vdev")]; + if (!screen) + screen = [[VLCMainWindow sharedInstance] screen]; + + NSRect window_rect; + if (b_video_wallpaper) + window_rect = [screen frame]; + else + window_rect = [[VLCMainWindow sharedInstance] frame]; + + NSUInteger mask = NSBorderlessWindowMask; + if (!OSX_SNOW_LEOPARD && !b_video_deco) + mask |= NSResizableWindowMask; + + BOOL b_no_video_deco_only = !b_video_wallpaper; + o_new_video_window = [[VLCVideoWindowCommon alloc] initWithContentRect:window_rect styleMask:mask backing:NSBackingStoreBuffered defer:YES]; + [o_new_video_window setDelegate:o_new_video_window]; + + if (b_video_wallpaper) + [o_new_video_window setLevel:CGWindowLevelForKey(kCGDesktopWindowLevelKey) + 1]; + + [o_new_video_window setBackgroundColor: [NSColor blackColor]]; + [o_new_video_window setCanBecomeKeyWindow: !b_video_wallpaper]; + [o_new_video_window setCanBecomeMainWindow: !b_video_wallpaper]; + [o_new_video_window setAcceptsMouseMovedEvents: !b_video_wallpaper]; + [o_new_video_window setMovableByWindowBackground: !b_video_wallpaper]; + [o_new_video_window useOptimizedDrawing: YES]; + + o_vout_view = [[VLCVoutView alloc] initWithFrame:[[o_new_video_window contentView] bounds]]; + [o_vout_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; + [[o_new_video_window contentView] addSubview:o_vout_view positioned:NSWindowAbove relativeTo:nil]; + [o_new_video_window setVideoView:o_vout_view]; + + + if (b_video_wallpaper) + [o_new_video_window orderBack:nil]; + else { + [o_new_video_window center]; + [o_new_video_window setFrameAutosaveName:@"extra-videowindow"]; + [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_nativeFullscreenMode) { + o_vout_view = [[[VLCMainWindow sharedInstance] videoView] retain]; + o_new_video_window = [[VLCMainWindow sharedInstance] retain]; + b_nonembedded = NO; + } else { + NSWindowController *o_controller = [[NSWindowController alloc] initWithWindowNibName:@"DetachedVideoWindow"]; + [o_controller loadWindow]; + o_new_video_window = [(VLCDetachedVideoWindow *)[o_controller window] retain]; + [o_controller release]; + + [o_new_video_window setDelegate: o_new_video_window]; + [o_new_video_window setLevel:NSNormalWindowLevel]; + [o_new_video_window useOptimizedDrawing: YES]; + o_vout_view = [[o_new_video_window videoView] retain]; + b_nonembedded = YES; + } + } + + if (!b_video_wallpaper) { + [o_new_video_window makeKeyAndOrderFront: self]; + + vout_thread_t *p_vout = getVout(); + if (p_vout) { + if (var_GetBool(p_vout, "video-on-top")) + [o_new_video_window setLevel: NSStatusWindowLevel]; + else + [o_new_video_window setLevel: NSNormalWindowLevel]; + vlc_object_release(p_vout); + } + } + [o_new_video_window setAlphaValue: config_GetFloat(VLCIntf, "macosx-opaqueness")]; + + if(b_nonembedded) { + // event occurs before window is created, so call again + [[VLCMain sharedInstance] playbackStatusUpdated]; + } + + [[VLCMainWindow sharedInstance] setNonembedded:b_nonembedded]; + [o_vout_view setVoutThread:(vout_thread_t *)p_wnd->p_parent]; + [o_vout_dict setObject:[o_new_video_window autorelease] forKey:[NSValue valueWithPointer:p_wnd]]; - [o_vout_dict setObject:o_window forKey:[NSValue valueWithPointer:p_wnd]]; + return [o_vout_view autorelease]; } - (void)removeVoutforDisplay:(NSValue *)o_key diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h index d8d80d24e6026a93b8df48d49dd217794c582daa..897b0bd45ee2d100f562d2b151e69f7f032e9ef2 100644 --- a/modules/gui/macosx/intf.h +++ b/modules/gui/macosx/intf.h @@ -149,6 +149,7 @@ struct intf_sys_t } @property (readonly) VLCVoutWindowController* voutController; +@property (readonly) BOOL nativeFullscreenMode; + (VLCMain *)sharedInstance; diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index 52e230ffb2fcbadf2d0e39664c7c933fe25ebd03..213896845c9dbd0b21bc70c40d7acf080a57eca2 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -553,6 +553,7 @@ audio_output_t *getAout(void) @implementation VLCMain @synthesize voutController=o_vout_controller; +@synthesize nativeFullscreenMode=b_nativeFullscreenMode; #pragma mark - #pragma mark Initialization @@ -1556,8 +1557,8 @@ static VLCMain *_o_sharedMainInstance = nil; - (id)getVideoViewAtPositionX: (int *)pi_x Y: (int *)pi_y withWidth: (unsigned int*)pi_width andHeight: (unsigned int*)pi_height forWindow:(vout_window_t *)p_wnd { SEL sel = @selector(setupVout:); - NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[o_mainwindow methodSignatureForSelector:sel]]; - [inv setTarget:o_mainwindow]; + NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[o_vout_controller methodSignatureForSelector:sel]]; + [inv setTarget:o_vout_controller]; [inv setSelector:sel]; [inv setArgument:&p_wnd atIndex:2]; // starting at 2!