Commit 9288133f authored by David Fuhrmann's avatar David Fuhrmann

macosx: re-implement macosx-background

refs #5174
parent 9bd356e5
......@@ -58,6 +58,7 @@ Mac OS X Interface:
* added an option to hide the shuffle and repeat buttons
* added optional playlist columns for track number, genre, album, description,
date and language.
* add an option to play videos as a desktop background
Removed modules:
* portaudio audio output
......
......@@ -141,6 +141,8 @@
VLCColorView * o_color_backdrop;
NSInteger i_originalLevel;
NSRect previousSavedFrame;
VLCWindow *o_extra_video_window;
}
+ (VLCMainWindow *)sharedInstance;
......
......@@ -148,6 +148,10 @@ static VLCMainWindow *_o_sharedInstance = nil;
[[NSNotificationCenter defaultCenter] removeObserver: self];
[o_sidebaritems release];
if( o_extra_video_window )
[o_extra_video_window release];
[super dealloc];
}
......@@ -1018,7 +1022,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_playlist_table setHidden: NO];
[o_video_view setHidden: !b_activeVideo];
if( b_activeVideo && [[o_video_view subviews] count] > 0 )
[o_detached_video_window makeFirstResponder: [[o_video_view subviews] objectAtIndex:0]];
[[o_video_view window] makeFirstResponder: [[o_video_view subviews] objectAtIndex:0]];
}
}
}
......@@ -1744,52 +1748,88 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (id)setupVideoView
{
vout_thread_t *p_vout = getVout();
if ((config_GetInt( VLCIntf, "embedded-video" ) || b_nativeFullscreenMode) && b_video_deco)
if( config_GetInt( VLCIntf, "macosx-background" ) )
{
if ([o_video_view window] != self)
{
msg_Dbg( VLCIntf, "Creating background window" );
NSScreen *screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)config_GetInt( VLCIntf, "macosx-vdev" )];
if( !screen )
screen = [self screen];
NSRect screen_rect = [screen frame];
if( o_extra_video_window )
[o_extra_video_window release];
o_extra_video_window = [[VLCWindow alloc] initWithContentRect:screen_rect styleMask: NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
[o_extra_video_window setLevel: CGWindowLevelForKey(kCGDesktopWindowLevelKey) + 1];
[o_extra_video_window setBackgroundColor: [NSColor blackColor]];
[o_extra_video_window setCanBecomeKeyWindow: NO];
[o_extra_video_window setCanBecomeMainWindow: NO];
[o_extra_video_window useOptimizedDrawing: YES];
[o_extra_video_window setMovableByWindowBackground: NO];
[o_video_view retain];
if ([o_video_view superview] != NULL)
[o_video_view removeFromSuperviewWithoutNeedingDisplay];
[o_video_view setFrame: [o_split_view frame]];
[[self contentView] addSubview:o_video_view positioned:NSWindowAbove relativeTo:nil];
}
b_nonembedded = NO;
screen_rect.origin.x = screen_rect.origin.y = 0;
[o_video_view setFrame: screen_rect];
[[o_extra_video_window contentView] addSubview: o_video_view positioned:NSWindowAbove relativeTo:nil];
[o_video_view release];
[o_extra_video_window orderBack:nil];
b_nonembedded = YES;
}
else
{
if ([o_video_view superview] != NULL)
[o_video_view removeFromSuperviewWithoutNeedingDisplay];
NSRect frame = [o_detached_video_window frame];
NSRect videoFrame = [o_video_view frame];
frame.size.width = videoFrame.size.width;
if (b_video_deco)
frame.size.height = videoFrame.size.height + [o_detached_bottombar_view frame].size.height + [o_titlebar_view frame].size.height;
if ((config_GetInt( VLCIntf, "embedded-video" ) || b_nativeFullscreenMode) && b_video_deco)
{
if ([o_video_view window] != self)
{
[o_video_view removeFromSuperviewWithoutNeedingDisplay];
[o_video_view setFrame: [o_split_view frame]];
[[self contentView] addSubview:o_video_view positioned:NSWindowAbove relativeTo:nil];
}
b_nonembedded = NO;
}
else
{
frame.size.height = videoFrame.size.height;
videoFrame.origin.y = .0;
videoFrame.origin.x = .0;
[o_video_view setFrame: videoFrame];
if ([o_video_view superview] != NULL)
[o_video_view removeFromSuperviewWithoutNeedingDisplay];
NSRect frame = [o_detached_video_window frame];
NSRect videoFrame = [o_video_view frame];
frame.size.width = videoFrame.size.width;
if (b_video_deco)
frame.size.height = videoFrame.size.height + [o_detached_bottombar_view frame].size.height + [o_titlebar_view frame].size.height;
else
{
frame.size.height = videoFrame.size.height;
videoFrame.origin.y = .0;
videoFrame.origin.x = .0;
[o_video_view setFrame: videoFrame];
}
[o_detached_video_window setFrame: frame display: NO];
[[o_detached_video_window contentView] addSubview: o_video_view positioned:NSWindowAbove relativeTo:nil];
[o_detached_video_window setLevel:NSNormalWindowLevel];
[o_detached_video_window useOptimizedDrawing: YES];
[o_detached_video_window center];
b_nonembedded = YES;
}
[[o_video_view window] makeKeyAndOrderFront: self];
vout_thread_t *p_vout = getVout();
if (p_vout)
{
if( var_GetBool( p_vout, "video-on-top" ) )
[[o_video_view window] setLevel: NSStatusWindowLevel];
else
[[o_video_view window] setLevel: NSNormalWindowLevel];
vlc_object_release( p_vout );
}
[o_detached_video_window setFrame: frame display: NO];
[[o_detached_video_window contentView] addSubview: o_video_view positioned:NSWindowAbove relativeTo:nil];
[o_detached_video_window setLevel:NSNormalWindowLevel];
[o_detached_video_window useOptimizedDrawing: YES];
[o_detached_video_window center];
b_nonembedded = YES;
}
[[o_video_view window] makeKeyAndOrderFront: self];
[[o_video_view window] setAlphaValue: config_GetFloat( VLCIntf, "macosx-opaqueness" )];
if (p_vout)
{
if( var_GetBool( p_vout, "video-on-top" ) )
[[o_video_view window] setLevel: NSStatusWindowLevel];
else
[[o_video_view window] setLevel: NSNormalWindowLevel];
vlc_object_release( p_vout );
}
[[o_video_view window] setAlphaValue: config_GetFloat( VLCIntf, "macosx-opaqueness" )];
return o_video_view;
}
......@@ -1806,6 +1846,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
{
[self makeFirstResponder: nil];
[o_detached_video_window orderOut: nil];
if( o_extra_video_window )
[o_extra_video_window orderOut: nil];
if( [self level] != NSNormalWindowLevel )
[self setLevel: NSNormalWindowLevel];
......@@ -1885,7 +1927,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
{
nativeVideoSize = size;
if( config_GetInt( VLCIntf, "macosx-video-autoresize" ) && !b_fullscreen )
if( config_GetInt( VLCIntf, "macosx-video-autoresize" ) && !b_fullscreen && !config_GetInt( VLCIntf, "macosx-background" ) )
[self performSelectorOnMainThread:@selector(resizeWindow) withObject:nil waitUntilDone:NO];
}
......
......@@ -1655,6 +1655,9 @@ unsigned int CocoaKeyToVLC( unichar i_key )
- (void)setWindowLevel:(NSNumber*)state
{
if( config_GetInt( p_intf, "macosx-background" ) )
return;
if ([state unsignedIntValue] & VOUT_WINDOW_STATE_ABOVE)
[[[[VLCMainWindow sharedInstance] videoView] window] setLevel: NSStatusWindowLevel];
else
......
......@@ -113,6 +113,9 @@ void WindowClose ( vout_window_t * );
#define PLAYMODEBUTTONS_TEXT N_( "Show play mode control buttons" )
#define PLAYMODEBUTTONS_LONGTEXT N_( "Shows the shuffle and repeat buttons in the main window" )
#define BACKGROUND_TEXT N_( "Use as desktop background" )
#define BACKGROUND_LONGTEXT N_( "Use the video as the desktop background." )
vlc_module_begin ()
set_description( N_("Mac OS X interface") )
set_capability( "interface", 200 )
......@@ -129,7 +132,6 @@ vlc_module_begin ()
add_bool( "macosx-interfacestyle", false, INTERFACE_STYLE_TEXT, INTERFACE_STYLE_LONGTEXT, false )
add_bool( "macosx-nativefullscreenmode", false, NATIVE_FULLSCREEN_MODE_ON_LION_TEXT, NATIVE_FULLSCREEN_MODE_ON_LION_LONGTEXT, false )
add_obsolete_bool( "macosx-stretch" ) /* since 2.0.0 */
add_obsolete_bool( "macosx-background" ) /* since 2.0.0 */
add_obsolete_bool( "macosx-eq-keep" ) /* since 2.0.0 */
add_obsolete_bool( "macosx-autosave-volume" ) /* since 2.1.0 */
add_bool( "macosx-video-autoresize", true, KEEPSIZE_TEXT, KEEPSIZE_LONGTEXT, false )
......@@ -138,6 +140,7 @@ vlc_module_begin ()
add_bool( "macosx-icon-change", true, ICONCHANGE_TEXT, ICONCHANGE_LONGTEXT, true )
add_bool( "macosx-show-playback-buttons", false, JUMPBUTTONS_TEXT, JUMPBUTTONS_LONGTEXT, false )
add_bool( "macosx-show-playmode-buttons", true, PLAYMODEBUTTONS_TEXT, PLAYMODEBUTTONS_LONGTEXT, false )
add_bool( "macosx-background", false, BACKGROUND_TEXT, BACKGROUND_LONGTEXT, false )
add_submodule ()
set_description( "Mac OS X Video Output Provider" )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment