]> git.sesse.net Git - vlc/commitdiff
minimal_macosx: remove dependency on the Carbon framework by replacing SetSystemUIMod...
authorFelix Paul Kühne <fkuehne@videolan.org>
Wed, 19 Dec 2012 18:40:59 +0000 (19:40 +0100)
committerFelix Paul Kühne <fkuehne@videolan.org>
Wed, 19 Dec 2012 18:53:13 +0000 (19:53 +0100)
configure.ac
modules/gui/minimal_macosx/Modules.am
modules/gui/minimal_macosx/VLCMinimalVoutWindow.m
modules/gui/minimal_macosx/misc.h [new file with mode: 0644]
modules/gui/minimal_macosx/misc.m [new file with mode: 0644]

index c0fe42a0840a4170f3f40be6276d80639ebcd6cf..fbf21a123f2489a85885b5cfd54c60e07f82f551 100644 (file)
@@ -3655,7 +3655,7 @@ AC_ARG_ENABLE(minimal-macosx,
   [  --enable-minimal-macosx Minimal Mac OS X support (default disabled)])
 if test "${enable_minimal_macosx}" = "yes" -a "${SYS}" = "darwin"
 then
-  VLC_ADD_LIBS([minimal_macosx], [-Wl,-framework,Cocoa -Wl,-framework,OpenGL -Wl,-framework,Carbon -Wl,-framework,CoreServices -Wl,-framework,AGL])
+  VLC_ADD_LIBS([minimal_macosx], [-Wl,-framework,Cocoa])
   VLC_ADD_OBJCFLAGS([minimal_macosx], [-fobjc-exceptions] )
   VLC_ADD_PLUGIN([minimal_macosx])
 fi
index 1efdda28c22a7b63b5e0e0b582fc7204645dc332..4c507752513aab5216293186bd064975f385fd52 100644 (file)
@@ -1,6 +1,7 @@
 AM_LIBTOOLFLAGS=--tag=CC
 
 SOURCES_minimal_macosx = \
+       misc.m \
        intf.m \
        macosx.c \
        VLCMinimalVoutWindow.m \
@@ -8,4 +9,5 @@ SOURCES_minimal_macosx = \
 
 noinst_HEADERS = \
        intf.h \
+       misc.h \
        VLCMinimalVoutWindow.h
index cd48ed7e7aa5fc56fad4115131351ae1d30a4edd..d2ed12edd89e5e034479e5770168746e990cd649 100644 (file)
  *****************************************************************************/
 #import "intf.h"
 #import "VLCMinimalVoutWindow.h"
+#import "misc.h"
 
 #import <Cocoa/Cocoa.h>
 
-/* SetSystemUIMode, ... */
-#import <Carbon/Carbon.h>
-
 @implementation VLCMinimalVoutWindow
 - (id)initWithContentRect:(NSRect)contentRect
 {
         [self setHasShadow:YES];
         [self setMovableByWindowBackground: YES];
         [self center];
-        NSLog( @"window created" );
     }
     return self;
 }
 
 - (void)enterFullscreen
 {
+    NSScreen *screen = [self screen];
+
     initialFrame = [self frame];
-    SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar);
     [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
 {
-    SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar);
+    [NSApp setPresentationOptions: NSApplicationPresentationDefault];
     [self setFrame:initialFrame display:YES animate:YES];
 }
 
diff --git a/modules/gui/minimal_macosx/misc.h b/modules/gui/minimal_macosx/misc.h
new file mode 100644 (file)
index 0000000..607aa4f
--- /dev/null
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * misc.h: custom code
+ *****************************************************************************
+ * Copyright (C) 2012 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
+ *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
+ *          Pierre d'Herbemont <pdherbemont # videolan dot org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+@interface NSScreen (VLCAdditions)
+- (BOOL)hasMenuBar;
+- (BOOL)hasDock;
+- (CGDirectDisplayID)displayID;
+@end
diff --git a/modules/gui/minimal_macosx/misc.m b/modules/gui/minimal_macosx/misc.m
new file mode 100644 (file)
index 0000000..a0bfe67
--- /dev/null
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * misc.m: custom code
+ *****************************************************************************
+ * Copyright (C) 2012 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
+ *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
+ *          Pierre d'Herbemont <pdherbemont # videolan dot org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "misc.h"
+
+@implementation NSScreen (VLCAdditions)
+
+- (BOOL)hasMenuBar
+{
+    return ([self displayID] == [[[NSScreen screens] objectAtIndex:0] displayID]);
+}
+
+- (BOOL)hasDock
+{
+    NSRect screen_frame = [self frame];
+    NSRect screen_visible_frame = [self visibleFrame];
+    CGFloat f_menu_bar_thickness = [self hasMenuBar] ? [[NSStatusBar systemStatusBar] thickness] : 0.0;
+
+    BOOL b_found_dock = NO;
+    if (screen_visible_frame.size.width < screen_frame.size.width)
+        b_found_dock = YES;
+    else if (screen_visible_frame.size.height + f_menu_bar_thickness < screen_frame.size.height)
+        b_found_dock = YES;
+
+    return b_found_dock;
+}
+
+- (CGDirectDisplayID)displayID
+{
+    return (CGDirectDisplayID)[[[self deviceDescription] objectForKey: @"NSScreenNumber"] intValue];
+}
+
+@end