[vlc-commits] macosx: move show controller callbacks away from the main singleton
Felix Paul Kühne
git at videolan.org
Tue Jun 11 12:24:56 CEST 2019
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Tue Jun 11 12:08:45 2019 +0200| [883c17dd20d2865fa8c45a4b621109ef104e0902] | committer: Felix Paul Kühne
macosx: move show controller callbacks away from the main singleton
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=883c17dd20d2865fa8c45a4b621109ef104e0902
---
modules/gui/macosx/library/VLCLibraryWindow.m | 46 +++++++++++++++++++++-
modules/gui/macosx/main/VLCMain.m | 32 ---------------
.../macosx/windows/video/VLCVideoWindowCommon.h | 1 +
.../macosx/windows/video/VLCVideoWindowCommon.m | 1 +
4 files changed, 47 insertions(+), 33 deletions(-)
diff --git a/modules/gui/macosx/library/VLCLibraryWindow.m b/modules/gui/macosx/library/VLCLibraryWindow.m
index 1b9409d179..f714ed9eb4 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.m
+++ b/modules/gui/macosx/library/VLCLibraryWindow.m
@@ -52,6 +52,7 @@
#import "windows/VLCOpenWindowController.h"
#import "windows/VLCOpenInputMetadata.h"
+#import <vlc_common.h>
#import <vlc_url.h>
const CGFloat VLCLibraryWindowMinimalWidth = 604.;
@@ -81,6 +82,32 @@ const CGFloat VLCLibraryWindowDefaultPlaylistWidth = 340.;
}
@end
+static int ShowFullscreenController(vlc_object_t *p_this, const char *psz_variable,
+ vlc_value_t old_val, vlc_value_t new_val, void *param)
+{
+ @autoreleasepool {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [[NSNotificationCenter defaultCenter] postNotificationName:VLCVideoWindowShouldShowFullscreenController
+ object:nil];
+ });
+
+ return VLC_SUCCESS;
+ }
+}
+
+static int ShowController(vlc_object_t *p_this, const char *psz_variable,
+ vlc_value_t old_val, vlc_value_t new_val, void *param)
+{
+ @autoreleasepool {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [[NSNotificationCenter defaultCenter] postNotificationName:VLCWindowShouldShowController
+ object:nil];
+ });
+
+ return VLC_SUCCESS;
+ }
+}
+
@implementation VLCLibraryWindow
- (void)awakeFromNib
@@ -88,6 +115,10 @@ const CGFloat VLCLibraryWindowDefaultPlaylistWidth = 340.;
VLCMain *mainInstance = [VLCMain sharedInstance];
_playlistController = [mainInstance playlistController];
+ libvlc_int_t *libvlc = vlc_object_instance(getIntf());
+ var_AddCallback(libvlc, "intf-toggle-fscontrol", ShowFullscreenController, (__bridge void *)self);
+ var_AddCallback(libvlc, "intf-show", ShowController, (__bridge void *)self);
+
self.videoView = [[VLCVoutView alloc] initWithFrame:self.mainSplitView.frame];
self.videoView.hidden = YES;
self.videoView.translatesAutoresizingMaskIntoConstraints = NO;
@@ -103,6 +134,10 @@ const CGFloat VLCLibraryWindowDefaultPlaylistWidth = 340.;
name:VLCVideoWindowShouldShowFullscreenController
object:nil];
[notificationCenter addObserver:self
+ selector:@selector(shouldShowController:)
+ name:VLCWindowShouldShowController
+ object:nil];
+ [notificationCenter addObserver:self
selector:@selector(updateLibraryRepresentation:)
name:VLCLibraryModelAudioMediaListUpdated
object:nil];
@@ -229,6 +264,10 @@ const CGFloat VLCLibraryWindowDefaultPlaylistWidth = 340.;
if (@available(macOS 10_14, *)) {
[[NSApplication sharedApplication] removeObserver:self forKeyPath:@"effectiveAppearance"];
}
+
+ libvlc_int_t *libvlc = vlc_object_instance(getIntf());
+ var_DelCallback(libvlc, "intf-toggle-fscontrol", ShowFullscreenController, (__bridge void *)self);
+ var_DelCallback(libvlc, "intf-show", ShowController, (__bridge void *)self);
}
#pragma mark - appearance setters
@@ -572,7 +611,12 @@ const CGFloat VLCLibraryWindowDefaultPlaylistWidth = 340.;
}
#pragma mark -
-#pragma mark Fullscreen support
+#pragma mark respond to core events
+
+- (void)shouldShowController:(NSNotification *)aNotification
+{
+ [self makeKeyAndOrderFront:nil];
+}
- (void)shouldShowFullscreenController:(NSNotification *)aNotification
{
diff --git a/modules/gui/macosx/main/VLCMain.m b/modules/gui/macosx/main/VLCMain.m
index 3aa0808a86..d33e8ea0e6 100644
--- a/modules/gui/macosx/main/VLCMain.m
+++ b/modules/gui/macosx/main/VLCMain.m
@@ -177,34 +177,6 @@ void CloseIntf (vlc_object_t *p_this)
#pragma mark -
#pragma mark Variables Callback
-/*****************************************************************************
- * ShowController: Callback triggered by the show-intf playlist variable
- * through the ShowIntf-control-intf, to let us show the controller-win;
- * usually when in fullscreen-mode
- *****************************************************************************/
-static int ShowController(vlc_object_t *p_this, const char *psz_variable,
- vlc_value_t old_val, vlc_value_t new_val, void *param)
-{
- @autoreleasepool {
- dispatch_async(dispatch_get_main_queue(), ^{
-
- intf_thread_t *p_intf = getIntf();
- if (p_intf) {
- VLCMain *mainInstance = [VLCMain sharedInstance];
- if ([[[mainInstance playlistController] playerController] fullscreen]) {
- [[NSNotificationCenter defaultCenter] postNotificationName:VLCVideoWindowShouldShowFullscreenController
- object:mainInstance];
- } else if (!strcmp(psz_variable, "intf-show")) {
- [[mainInstance libraryWindow] makeKeyAndOrderFront:nil];
- }
- }
-
- });
-
- return VLC_SUCCESS;
- }
-}
-
static int BossCallback(vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param)
{
@@ -268,8 +240,6 @@ static VLCMain *sharedInstance = nil;
_libraryWindowController = [[VLCLibraryWindowController alloc] initWithLibraryWindow];
libvlc_int_t *libvlc = vlc_object_instance(p_intf);
- var_AddCallback(libvlc, "intf-toggle-fscontrol", ShowController, (__bridge void *)self);
- var_AddCallback(libvlc, "intf-show", ShowController, (__bridge void *)self);
var_AddCallback(libvlc, "intf-boss", BossCallback, (__bridge void *)self);
// Load them here already to apply stored profiles
@@ -353,8 +323,6 @@ static VLCMain *sharedInstance = nil;
[[self audioEffectsPanel] saveCurrentProfileAtTerminate];
libvlc_int_t *libvlc = vlc_object_instance(p_intf);
- var_DelCallback(libvlc, "intf-toggle-fscontrol", ShowController, (__bridge void *)self);
- var_DelCallback(libvlc, "intf-show", ShowController, (__bridge void *)self);
var_DelCallback(libvlc, "intf-boss", BossCallback, (__bridge void *)self);
[[NSNotificationCenter defaultCenter] removeObserver: self];
diff --git a/modules/gui/macosx/windows/video/VLCVideoWindowCommon.h b/modules/gui/macosx/windows/video/VLCVideoWindowCommon.h
index dd3e073d25..b6e48e362a 100644
--- a/modules/gui/macosx/windows/video/VLCVideoWindowCommon.h
+++ b/modules/gui/macosx/windows/video/VLCVideoWindowCommon.h
@@ -27,6 +27,7 @@
extern NSString *VLCVideoWindowShouldShowFullscreenController;
extern NSString *VLCVideoWindowDidEnterFullscreen;
+extern NSString *VLCWindowShouldShowController;
extern const CGFloat VLCVideoWindowCommonMinimalHeight;
@class VLCVoutView;
diff --git a/modules/gui/macosx/windows/video/VLCVideoWindowCommon.m b/modules/gui/macosx/windows/video/VLCVideoWindowCommon.m
index cdd7713630..00975761e4 100644
--- a/modules/gui/macosx/windows/video/VLCVideoWindowCommon.m
+++ b/modules/gui/macosx/windows/video/VLCVideoWindowCommon.m
@@ -39,6 +39,7 @@
const CGFloat VLCVideoWindowCommonMinimalHeight = 70.;
NSString *VLCVideoWindowShouldShowFullscreenController = @"VLCVideoWindowShouldShowFullscreenController";
NSString *VLCVideoWindowDidEnterFullscreen = @"VLCVideoWindowDidEnterFullscreen";
+NSString *VLCWindowShouldShowController = @"VLCWindowShouldShowController";
/*****************************************************************************
* VLCVideoWindowCommon
More information about the vlc-commits
mailing list