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: ...@@ -58,6 +58,7 @@ Mac OS X Interface:
* added an option to hide the shuffle and repeat buttons * added an option to hide the shuffle and repeat buttons
* added optional playlist columns for track number, genre, album, description, * added optional playlist columns for track number, genre, album, description,
date and language. date and language.
* add an option to play videos as a desktop background
Removed modules: Removed modules:
* portaudio audio output * portaudio audio output
......
...@@ -141,6 +141,8 @@ ...@@ -141,6 +141,8 @@
VLCColorView * o_color_backdrop; VLCColorView * o_color_backdrop;
NSInteger i_originalLevel; NSInteger i_originalLevel;
NSRect previousSavedFrame; NSRect previousSavedFrame;
VLCWindow *o_extra_video_window;
} }
+ (VLCMainWindow *)sharedInstance; + (VLCMainWindow *)sharedInstance;
......
...@@ -148,6 +148,10 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -148,6 +148,10 @@ static VLCMainWindow *_o_sharedInstance = nil;
[[NSNotificationCenter defaultCenter] removeObserver: self]; [[NSNotificationCenter defaultCenter] removeObserver: self];
[o_sidebaritems release]; [o_sidebaritems release];
if( o_extra_video_window )
[o_extra_video_window release];
[super dealloc]; [super dealloc];
} }
...@@ -1018,7 +1022,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1018,7 +1022,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_playlist_table setHidden: NO]; [o_playlist_table setHidden: NO];
[o_video_view setHidden: !b_activeVideo]; [o_video_view setHidden: !b_activeVideo];
if( b_activeVideo && [[o_video_view subviews] count] > 0 ) 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,7 +1748,39 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1744,7 +1748,39 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (id)setupVideoView - (id)setupVideoView
{ {
vout_thread_t *p_vout = getVout(); if( config_GetInt( VLCIntf, "macosx-background" ) )
{
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];
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 ((config_GetInt( VLCIntf, "embedded-video" ) || b_nativeFullscreenMode) && b_video_deco) if ((config_GetInt( VLCIntf, "embedded-video" ) || b_nativeFullscreenMode) && b_video_deco)
{ {
if ([o_video_view window] != self) if ([o_video_view window] != self)
...@@ -1779,9 +1815,10 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1779,9 +1815,10 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_detached_video_window center]; [o_detached_video_window center];
b_nonembedded = YES; b_nonembedded = YES;
} }
[[o_video_view window] makeKeyAndOrderFront: self]; [[o_video_view window] makeKeyAndOrderFront: self];
[[o_video_view window] setAlphaValue: config_GetFloat( VLCIntf, "macosx-opaqueness" )];
vout_thread_t *p_vout = getVout();
if (p_vout) if (p_vout)
{ {
if( var_GetBool( p_vout, "video-on-top" ) ) if( var_GetBool( p_vout, "video-on-top" ) )
...@@ -1790,6 +1827,9 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1790,6 +1827,9 @@ static VLCMainWindow *_o_sharedInstance = nil;
[[o_video_view window] setLevel: NSNormalWindowLevel]; [[o_video_view window] setLevel: NSNormalWindowLevel];
vlc_object_release( p_vout ); vlc_object_release( p_vout );
} }
}
[[o_video_view window] setAlphaValue: config_GetFloat( VLCIntf, "macosx-opaqueness" )];
return o_video_view; return o_video_view;
} }
...@@ -1806,6 +1846,8 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1806,6 +1846,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
{ {
[self makeFirstResponder: nil]; [self makeFirstResponder: nil];
[o_detached_video_window orderOut: nil]; [o_detached_video_window orderOut: nil];
if( o_extra_video_window )
[o_extra_video_window orderOut: nil];
if( [self level] != NSNormalWindowLevel ) if( [self level] != NSNormalWindowLevel )
[self setLevel: NSNormalWindowLevel]; [self setLevel: NSNormalWindowLevel];
...@@ -1885,7 +1927,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1885,7 +1927,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
{ {
nativeVideoSize = size; 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]; [self performSelectorOnMainThread:@selector(resizeWindow) withObject:nil waitUntilDone:NO];
} }
......
...@@ -1655,6 +1655,9 @@ unsigned int CocoaKeyToVLC( unichar i_key ) ...@@ -1655,6 +1655,9 @@ unsigned int CocoaKeyToVLC( unichar i_key )
- (void)setWindowLevel:(NSNumber*)state - (void)setWindowLevel:(NSNumber*)state
{ {
if( config_GetInt( p_intf, "macosx-background" ) )
return;
if ([state unsignedIntValue] & VOUT_WINDOW_STATE_ABOVE) if ([state unsignedIntValue] & VOUT_WINDOW_STATE_ABOVE)
[[[[VLCMainWindow sharedInstance] videoView] window] setLevel: NSStatusWindowLevel]; [[[[VLCMainWindow sharedInstance] videoView] window] setLevel: NSStatusWindowLevel];
else else
......
...@@ -113,6 +113,9 @@ void WindowClose ( vout_window_t * ); ...@@ -113,6 +113,9 @@ void WindowClose ( vout_window_t * );
#define PLAYMODEBUTTONS_TEXT N_( "Show play mode control buttons" ) #define PLAYMODEBUTTONS_TEXT N_( "Show play mode control buttons" )
#define PLAYMODEBUTTONS_LONGTEXT N_( "Shows the shuffle and repeat buttons in the main window" ) #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 () vlc_module_begin ()
set_description( N_("Mac OS X interface") ) set_description( N_("Mac OS X interface") )
set_capability( "interface", 200 ) set_capability( "interface", 200 )
...@@ -129,7 +132,6 @@ vlc_module_begin () ...@@ -129,7 +132,6 @@ vlc_module_begin ()
add_bool( "macosx-interfacestyle", false, INTERFACE_STYLE_TEXT, INTERFACE_STYLE_LONGTEXT, false ) 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_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-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-eq-keep" ) /* since 2.0.0 */
add_obsolete_bool( "macosx-autosave-volume" ) /* since 2.1.0 */ add_obsolete_bool( "macosx-autosave-volume" ) /* since 2.1.0 */
add_bool( "macosx-video-autoresize", true, KEEPSIZE_TEXT, KEEPSIZE_LONGTEXT, false ) add_bool( "macosx-video-autoresize", true, KEEPSIZE_TEXT, KEEPSIZE_LONGTEXT, false )
...@@ -138,6 +140,7 @@ vlc_module_begin () ...@@ -138,6 +140,7 @@ vlc_module_begin ()
add_bool( "macosx-icon-change", true, ICONCHANGE_TEXT, ICONCHANGE_LONGTEXT, true ) 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-playback-buttons", false, JUMPBUTTONS_TEXT, JUMPBUTTONS_LONGTEXT, false )
add_bool( "macosx-show-playmode-buttons", true, PLAYMODEBUTTONS_TEXT, PLAYMODEBUTTONS_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 () add_submodule ()
set_description( "Mac OS X Video Output Provider" ) 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