[vlc-commits] macosx: re-implemented a non-embedded video window

Felix Paul Kühne git at videolan.org
Sun Aug 14 22:59:45 CEST 2011


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sun Aug 14 20:08:04 2011 +0200| [734e6179eaf42652649248b2d5bdadec93355eac] | committer: Felix Paul Kühne

macosx: re-implemented a non-embedded video window

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=734e6179eaf42652649248b2d5bdadec93355eac
---

 modules/gui/macosx/MainWindow.h   |    3 +
 modules/gui/macosx/MainWindow.m   |   74 ++++++++++++++++++++++++++++++++----
 modules/gui/macosx/simple_prefs.m |    8 +++-
 modules/gui/macosx/vout.h         |    2 +-
 modules/video_output/macosx.m     |   17 +++++++-
 5 files changed, 91 insertions(+), 13 deletions(-)

diff --git a/modules/gui/macosx/MainWindow.h b/modules/gui/macosx/MainWindow.h
index b6653e5..4112d02 100644
--- a/modules/gui/macosx/MainWindow.h
+++ b/modules/gui/macosx/MainWindow.h
@@ -98,6 +98,9 @@
     BOOL just_triggered_previous;
     NSMutableArray *o_sidebaritems;
 
+    VLCWindow       * o_nonembedded_window;
+    BOOL              b_nonembedded;
+
     VLCWindow       * o_fullscreen_window;
     NSViewAnimation * o_fullscreen_anim1;
     NSViewAnimation * o_fullscreen_anim2;
diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index ab8d5d1..c361c23 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -409,14 +409,22 @@ static VLCMainWindow *_o_sharedInstance = nil;
 
 - (IBAction)togglePlaylist:(id)sender
 {
-    if ([o_video_view isHidden] && [o_playlist_btn isEnabled]) {
-        [o_playlist_table setHidden: YES];
-        [o_video_view setHidden: NO];
+    if (!b_nonembedded)
+    {
+        if ([o_video_view isHidden] && [o_playlist_btn isEnabled]) {
+            [o_playlist_table setHidden: YES];
+            [o_video_view setHidden: NO];
+        }
+        else
+        {
+            [o_video_view setHidden: YES];
+            [o_playlist_table setHidden: NO];
+        }
     }
     else
     {
-        [o_video_view setHidden: YES];
         [o_playlist_table setHidden: NO];
+        [o_video_view setHidden: NO];
     }
 }
 
@@ -788,12 +796,60 @@ static VLCMainWindow *_o_sharedInstance = nil;
 
 - (id)videoView
 {
+    vout_thread_t *p_vout = getVout();
+    if (config_GetInt( VLCIntf, "embedded-video" ))
+    {
+        if ([o_video_view window] != self)
+        {
+            [o_video_view removeFromSuperviewWithoutNeedingDisplay];
+            [o_video_view setFrame: [o_split_view frame]];
+            [[self contentView] addSubview: o_video_view];
+        }
+        b_nonembedded = NO;
+    }
+    else
+    {
+        [o_video_view removeFromSuperviewWithoutNeedingDisplay];
+        if (o_nonembedded_window)
+            [o_nonembedded_window release];
+
+        o_nonembedded_window = [[VLCWindow alloc] initWithContentRect:[o_video_view frame] styleMask: NSBorderlessWindowMask|NSResizableWindowMask backing:NSBackingStoreBuffered defer:YES];
+        [o_nonembedded_window setFrame:[o_video_view frame] display:NO];
+        [o_nonembedded_window setBackgroundColor: [NSColor blackColor]];
+        [o_nonembedded_window setMovableByWindowBackground: YES];
+        [o_nonembedded_window setCanBecomeKeyWindow: YES];
+        [o_nonembedded_window setHasShadow:YES];
+        [o_nonembedded_window setContentView: o_video_view];
+        [o_nonembedded_window setLevel:NSNormalWindowLevel];
+        [o_nonembedded_window useOptimizedDrawing: YES];
+        [o_nonembedded_window center];
+        [o_nonembedded_window makeKeyAndOrderFront:self];
+        [o_nonembedded_window orderFront:self animate:YES];
+        [o_nonembedded_window setReleasedWhenClosed:NO];
+        b_nonembedded = YES;
+    }
+
+    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 );
+    }
     return o_video_view;
 }
 
 - (void)setVideoplayEnabled
 {
-    [o_playlist_btn setEnabled: [[VLCMain sharedInstance] activeVideoPlayback]];
+    if (!b_nonembedded)
+        [o_playlist_btn setEnabled: [[VLCMain sharedInstance] activeVideoPlayback]];
+    else
+    {
+        [o_playlist_btn setEnabled: NO];
+        if (![[VLCMain sharedInstance] activeVideoPlayback])
+            [o_nonembedded_window orderOut: nil];
+    }
 }
 
 - (void)resizeWindow
@@ -1048,12 +1104,12 @@ static VLCMainWindow *_o_sharedInstance = nil;
     if (p_vout)
     {
         if( var_GetBool( p_vout, "video-on-top" ) )
-            [self setLevel: NSStatusWindowLevel];
+            [[o_video_view window] setLevel: NSStatusWindowLevel];
         else
-            [self setLevel: NSNormalWindowLevel];
+            [[o_video_view window] setLevel: NSNormalWindowLevel];
         vlc_object_release( p_vout );
     }
-    [self makeKeyAndOrderFront: nil];
+    [[o_video_view window] makeKeyAndOrderFront: nil];
 
     /* Don't do anything if o_fullscreen_window is already closed */
     if (!o_fullscreen_window)
@@ -1094,7 +1150,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
     }
 
     [self setAlphaValue: 0.0];
-    [self orderFront: self];
+    [[o_video_view window] orderFront: self];
 
     [o_fspanel setNonActive: nil];
     SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar);
diff --git a/modules/gui/macosx/simple_prefs.m b/modules/gui/macosx/simple_prefs.m
index 8c75896..b5aced4 100644
--- a/modules/gui/macosx/simple_prefs.m
+++ b/modules/gui/macosx/simple_prefs.m
@@ -225,7 +225,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
     [o_intf_style_dark_bcell setTitle: _NS("Dark")];
     [o_intf_style_bright_bcell setTitle: _NS("Bright")];
     [o_intf_art_txt setStringValue: _NS("Album art download policy")];
-    [o_intf_embedded_ckb setTitle: _NS("Add controls to the video window")];
+    [o_intf_embedded_ckb setTitle: _NS("Show video within the main window")];
     [o_intf_fspanel_ckb setTitle: _NS("Show Fullscreen Controller")];
     [o_intf_lang_txt setStringValue: _NS("Language")];
     [o_intf_network_box setTitle: _NS("Privacy / Network Interaction")];
@@ -436,9 +436,15 @@ static inline char * __config_GetLabel( vlc_object_t *p_this, const char *psz_na
     else
         [o_intf_enableGrowl_ckb setState: NSOffState];
     if (config_GetInt( p_intf, "macosx-interfacestyle" ))
+    {
         [o_intf_style_dark_bcell setState: YES];
+        [o_intf_style_bright_bcell setState: NO];
+    }
     else
+    {
         [o_intf_style_dark_bcell setState: NO];
+        [o_intf_style_bright_bcell setState: YES];
+    }
 
     /******************
      * audio settings *
diff --git a/modules/gui/macosx/vout.h b/modules/gui/macosx/vout.h
index bad426c..a2694ed 100644
--- a/modules/gui/macosx/vout.h
+++ b/modules/gui/macosx/vout.h
@@ -34,4 +34,4 @@
 
     id              o_window;
 }
- at end
\ No newline at end of file
+ at end
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index 608ddaa..553890e 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -314,7 +314,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
         }
         case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
         {
-            [[sys->glView window] performZoom: nil];
+            [[sys->glView window] performSelectorOnMainThread:@selector(performZoom:) withObject: nil waitUntilDone:NO];
             return VLC_SUCCESS;
         }
         case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
@@ -328,6 +328,8 @@ static int Control (vout_display_t *vd, int query, va_list ap)
             const vout_display_cfg_t *cfg;
 
             id o_window = [sys->glView window];
+            if (!o_window)
+                return VLC_SUCCESS; // this is okay, since the event will occur again when we have a window
             NSRect windowFrame = [o_window frame];
             NSRect glViewFrame = [sys->glView frame];
             NSSize windowMinSize = [o_window minSize];
@@ -353,7 +355,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
                 new_frame.origin.x = topleftscreen.x;
                 new_frame.origin.y = topleftscreen.y - new_frame.size.height;
 
-                [o_window setFrame:new_frame display:YES animate:YES];
+                [sys->glView performSelectorOnMainThread:@selector(setWindowFrameWithValue:) withObject:[NSValue valueWithRect:new_frame] waitUntilDone:NO];
             }
             return VLC_SUCCESS;
         }
@@ -471,6 +473,17 @@ static void OpenglSwap(vlc_gl_t *gl)
 }
 
 /**
+ * Gets called by Control() to make sure that we're performing on the main thread
+ */
+- (void)setWindowFrameWithValue:(NSValue *)value
+{
+    NSRect frame = [value rectValue];
+    if (frame.origin.x <= 0.0 && frame.origin.y <= 0.0)
+        [[self window] center];
+    [[self window] setFrame:frame display:YES animate: YES];
+}
+
+/**
  * Gets called by the Close and Open methods.
  * (Non main thread).
  */



More information about the vlc-commits mailing list