[vlc-commits] windowed mac plugin: use a saner pproach to enter/leave fullscreen mode. this isn't 2006 anymore, after all.

Felix Paul Kühne git at videolan.org
Wed Jan 16 15:44:46 CET 2013


npapi-vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Wed Jan 16 15:44:40 2013 +0100| [6b214e39e6490645c7b45be5db3233153e5ce5e2] | committer: Felix Paul Kühne

windowed mac plugin: use a saner pproach to enter/leave fullscreen mode. this isn't 2006 anymore, after all.

> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=6b214e39e6490645c7b45be5db3233153e5ce5e2
---

 npapi/vlcplugin_mac.mm |   43 +++++++++----------------------------------
 1 file changed, 9 insertions(+), 34 deletions(-)

diff --git a/npapi/vlcplugin_mac.mm b/npapi/vlcplugin_mac.mm
index b1ea9fb..d27eda6 100644
--- a/npapi/vlcplugin_mac.mm
+++ b/npapi/vlcplugin_mac.mm
@@ -102,9 +102,6 @@
 
 - (id)initWithContentRect:(NSRect)contentRect;
 
-- (void)enterFullscreen;
-- (void)leaveFullscreen;
-
 @end
 
 @interface NSScreen (VLCAdditions)
@@ -215,6 +212,8 @@ void VlcPluginMac::toggle_fullscreen()
 
     if (get_fullscreen() == 0) {
         if (!fullscreenWindow) {
+            /* this window is kind of useless. however, we need to support 10.5, since enterFullScreenMode depends on the 
+             * existance of a parent window. This is solved in 10.6 and we should remove the window once we require it. */
             fullscreenWindow = [[VLCFullscreenWindow alloc] initWithContentRect: NSMakeRect(npwindow.x, npwindow.y, npwindow.width, npwindow.height)];
             [fullscreenWindow setLevel: CGShieldingWindowLevel()];
             fullscreenView = [fullscreenWindow customContentView];
@@ -233,15 +232,11 @@ void VlcPluginMac::toggle_fullscreen()
         [[fullscreenView layer] addSublayer: noMediaLayer];
         [[fullscreenView layer] addSublayer: playbackLayer];
         [[fullscreenView layer] addSublayer: controllerLayer];
-
         [[fullscreenView layer] setNeedsDisplay];
 
-        [fullscreenWindow makeKeyAndOrderFront:nil];
-        [fullscreenWindow enterFullscreen];
-        [fullscreenWindow orderFrontRegardless];
-        [fullscreenWindow makeKeyWindow];
+        [[fullscreenWindow contentView] enterFullScreenMode: [NSScreen mainScreen] withOptions: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt: 0], NSFullScreenModeAllScreens, nil]];
     } else {
-        [fullscreenWindow leaveFullscreen];
+        [[fullscreenWindow contentView] exitFullScreenModeWithOptions: nil];
         [fullscreenWindow orderOut: nil];
         [noMediaLayer removeFromSuperlayer];
         [playbackLayer removeFromSuperlayer];
@@ -867,10 +862,7 @@ static CGImageRef createImageNamed(NSString *name)
     if( self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) {
         _initialFrame = contentRect;
         [self setBackgroundColor:[NSColor blackColor]];
-        [self setHasShadow:YES];
-        [self setMovableByWindowBackground: YES];
         [self setAcceptsMouseMovedEvents: YES];
-        [self center];
 
         _customContentView = [[VLCFullscreenContentView alloc] initWithFrame:_initialFrame];
         [_customContentView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
@@ -886,28 +878,6 @@ static CGImageRef createImageNamed(NSString *name)
     [super dealloc];
 }
 
-- (void)enterFullscreen
-{
-    NSScreen *screen = [self screen];
-
-    _initialFrame = [self frame];
-    [self setFrame:[[self screen] frame] display:YES animate:YES];
-
-    NSApplicationPresentationOptions presentationOpts = [NSApp presentationOptions];
-    if ([screen hasMenuBar])
-        presentationOpts |= NSApplicationPresentationAutoHideMenuBar;
-
-    if ([screen hasMenuBar] || [screen hasDock])
-        presentationOpts |= NSApplicationPresentationAutoHideDock;
-    [NSApp setPresentationOptions:presentationOpts];
-}
-
-- (void)leaveFullscreen
-{
-    [NSApp setPresentationOptions: NSApplicationPresentationDefault];
-    [self setFrame:_initialFrame display:YES animate:YES];
-}
-
 - (BOOL)canBecomeKeyWindow
 {
     return YES;
@@ -928,6 +898,11 @@ static CGImageRef createImageNamed(NSString *name)
     return YES;
 }
 
+- (BOOL)canBecomeKeyView
+{
+    return YES;
+}
+
 - (void)keyDown:(NSEvent *)theEvent
 {
     NSString * characters = [theEvent charactersIgnoringModifiers];



More information about the vlc-commits mailing list