[vlc-commits] minimal_macosx: remove dependency on the Carbon framework by replacing SetSystemUIMode calls by their Cocoa counterparts
Felix Paul Kühne
git at videolan.org
Wed Dec 19 19:53:16 CET 2012
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Wed Dec 19 19:40:59 2012 +0100| [b6c7c010b9740ed364d5f051b5b0971aec7ace13] | committer: Felix Paul Kühne
minimal_macosx: remove dependency on the Carbon framework by replacing SetSystemUIMode calls by their Cocoa counterparts
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b6c7c010b9740ed364d5f051b5b0971aec7ace13
---
configure.ac | 2 +-
modules/gui/minimal_macosx/Modules.am | 2 +
modules/gui/minimal_macosx/VLCMinimalVoutWindow.m | 17 ++++---
modules/gui/minimal_macosx/misc.h | 32 ++++++++++++
modules/gui/minimal_macosx/misc.m | 55 +++++++++++++++++++++
5 files changed, 101 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index c0fe42a..fbf21a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/modules/gui/minimal_macosx/Modules.am b/modules/gui/minimal_macosx/Modules.am
index 1efdda2..4c50775 100644
--- a/modules/gui/minimal_macosx/Modules.am
+++ b/modules/gui/minimal_macosx/Modules.am
@@ -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
diff --git a/modules/gui/minimal_macosx/VLCMinimalVoutWindow.m b/modules/gui/minimal_macosx/VLCMinimalVoutWindow.m
index cd48ed7..d2ed12e 100644
--- a/modules/gui/minimal_macosx/VLCMinimalVoutWindow.m
+++ b/modules/gui/minimal_macosx/VLCMinimalVoutWindow.m
@@ -26,12 +26,10 @@
*****************************************************************************/
#import "intf.h"
#import "VLCMinimalVoutWindow.h"
+#import "misc.h"
#import <Cocoa/Cocoa.h>
-/* SetSystemUIMode, ... */
-#import <Carbon/Carbon.h>
-
@implementation VLCMinimalVoutWindow
- (id)initWithContentRect:(NSRect)contentRect
{
@@ -42,21 +40,28 @@
[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
index 0000000..607aa4f
--- /dev/null
+++ b/modules/gui/minimal_macosx/misc.h
@@ -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>
+
+ at interface NSScreen (VLCAdditions)
+- (BOOL)hasMenuBar;
+- (BOOL)hasDock;
+- (CGDirectDisplayID)displayID;
+ at end
diff --git a/modules/gui/minimal_macosx/misc.m b/modules/gui/minimal_macosx/misc.m
new file mode 100644
index 0000000..a0bfe67
--- /dev/null
+++ b/modules/gui/minimal_macosx/misc.m
@@ -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"
+
+ at 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];
+}
+
+ at end
More information about the vlc-commits
mailing list