[vlc-devel] [PATCH] macosx: Make fscontroller compatible with <10.10

Marvin Scholz epirat07 at gmail.com
Tue Oct 11 10:19:19 CEST 2016


This will add a fallback mechanism that uses a
normal layer-backed NSView with a dark but still
slightly transparent background on macOS versions
that do not support NSVisualEffectView.

Additionally it will allow compilation with older
SDK's that have no NSVisualEffectView defined.
If compiled with such an SDK, support for
NSVisualEffectView is disabled completely, so
even when running the compiled VLC version
on 10.10 or higher it will use the old fallback
view, as the SDK it was compiled with had not the
necessary definitions.
---
 modules/gui/macosx/CompatibilityFixes.h   |  2 ++
 modules/gui/macosx/VLCFSPanelController.m | 15 +++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/modules/gui/macosx/CompatibilityFixes.h b/modules/gui/macosx/CompatibilityFixes.h
index 4a35c1c..2c7a297 100644
--- a/modules/gui/macosx/CompatibilityFixes.h
+++ b/modules/gui/macosx/CompatibilityFixes.h
@@ -32,6 +32,8 @@
 #define OSX_EL_CAPITAN (NSAppKitVersionNumber >= 1404 && NSAppKitVersionNumber < 1485)
 #define OSX_SIERRA (NSAppKitVersionNumber >= 1485)
 
+#define OSX_MAVERICKS_OR_LOWER (NSAppKitVersionNumber < 1334)
+
 // Sierra only APIs
 #ifndef MAC_OS_X_VERSION_10_12
 
diff --git a/modules/gui/macosx/VLCFSPanelController.m b/modules/gui/macosx/VLCFSPanelController.m
index c74247b..83c60d6 100644
--- a/modules/gui/macosx/VLCFSPanelController.m
+++ b/modules/gui/macosx/VLCFSPanelController.m
@@ -26,6 +26,7 @@
 
 #import "VLCFSPanelController.h"
 #import "VLCCoreInteraction.h"
+#import "CompatibilityFixes.h"
 #import "VLCMain.h"
 
 @interface VLCFSPanelController () {
@@ -58,9 +59,17 @@ - (void)windowDidLoad
     [self.window setStyleMask:self.window.styleMask | NSResizableWindowMask];
     [self.window setBackgroundColor:[NSColor clearColor]];
 
+#ifdef MAC_OS_X_VERSION_10_10
     /* Inject correct background view depending on OS support */
-    [self injectVisualEffectView];
-    //[self injectBackgroundView];
+    if (OSX_MAVERICKS_OR_LOWER) {
+        [self injectBackgroundView];
+    } else {
+        [self injectVisualEffectView];
+    }
+#else
+    /* Compiled with old SDK, always use legacy style */
+    [self injectBackgroundView];
+#endif
 
     [(NSButtonCell*)[_playPauseButton cell] setHighlightsBy:NSPushInCellMask];
     [(NSButtonCell*)[_playPauseButton cell] setShowsStateBy:NSContentsCellMask];
@@ -321,6 +330,7 @@ - (void)autohideCallback:(NSTimer *)timer
 #pragma mark -
 #pragma mark Helpers
 
+#ifdef MAC_OS_X_VERSION_10_10
 /**
  Create an image mask for the NSVisualEffectView
  with rounded corners in the given rect
@@ -371,6 +381,7 @@ - (void)injectVisualEffectView
     [_controllsView setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]];
     [self.window.contentView addSubview:_controllsView];
 }
+#endif
 
 /**
  Injects the standard background view in the Windows view hierarchy
-- 
2.8.4 (Apple Git-73)



More information about the vlc-devel mailing list