]> git.sesse.net Git - vlc/commitdiff
macosx: re-implement macosx-background
authorDavid Fuhrmann <david.fuhrmann@googlemail.com>
Mon, 23 Jul 2012 11:00:43 +0000 (13:00 +0200)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Mon, 23 Jul 2012 12:16:34 +0000 (14:16 +0200)
refs #5174

NEWS
modules/gui/macosx/MainWindow.h
modules/gui/macosx/MainWindow.m
modules/gui/macosx/intf.m
modules/gui/macosx/macosx.m

diff --git a/NEWS b/NEWS
index 60a5d4e2e53391ae3bf5be8e698a63ba08beec31..0e4d46489757a09ea6beb422dc8ecc13ec433edf 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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
index 5146829480f35d42cd40828e4ea813c6cb1cee22..89330ace880b7f77af30719319b7f09318552cff 100644 (file)
     VLCColorView * o_color_backdrop;
     NSInteger i_originalLevel;
     NSRect previousSavedFrame;
+
+    VLCWindow *o_extra_video_window;
 }
 + (VLCMainWindow *)sharedInstance;
 
index 4bbb801a49dabf12667f12ddc8c6d0ec51458a1a..72bb57da9d5274d85939a86394deb4fbac9a04a9 100644 (file)
@@ -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];
 }
 
index f8f529545bc666f69b2a8a7222030ed947437714..0bcc263e038cad7109c946752a7d37480d580d71 100644 (file)
@@ -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
index 317e033f9f4125224133aaf8a955989a84560024..799a35ebab52686d5340a1b38635bc9a23055806 100644 (file)
@@ -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" )