[vlc-commits] macosx: implement enable/disable window
Rémi Denis-Courmont
git at videolan.org
Sat Dec 8 15:50:35 CET 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Dec 2 20:40:26 2018 +0200| [1aaf297b19adf4562012de5e093b7ff99edbc42d] | committer: Rémi Denis-Courmont
macosx: implement enable/disable window
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1aaf297b19adf4562012de5e093b7ff99edbc42d
---
modules/gui/macosx/VLCVideoOutputProvider.m | 110 +++++++++++++---------------
1 file changed, 50 insertions(+), 60 deletions(-)
diff --git a/modules/gui/macosx/VLCVideoOutputProvider.m b/modules/gui/macosx/VLCVideoOutputProvider.m
index 66d7141575..02d0fc2203 100644
--- a/modules/gui/macosx/VLCVideoOutputProvider.m
+++ b/modules/gui/macosx/VLCVideoOutputProvider.m
@@ -39,15 +39,53 @@
#import "VLCPlaylist.h"
#import "NSScreen+VLCAdditions.h"
-static void WindowResize(vout_window_t *p_wnd,
- unsigned i_width, unsigned i_height)
+static int WindowEnable(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
{
@autoreleasepool {
+ msg_Dbg(p_wnd, "Opening video window");
+
+ NSRect proposedVideoViewPosition = NSMakeRect(cfg->x, cfg->y, cfg->width, cfg->height);
+
VLCVideoOutputProvider *voutProvider = [[VLCMain sharedInstance] voutProvider];
if (!voutProvider) {
- return;
+ return VLC_EGENERIC;
}
+ __block VLCVoutView *videoView = nil;
+
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ videoView = [voutProvider setupVoutForWindow:p_wnd
+ withProposedVideoViewPosition:proposedVideoViewPosition];
+ });
+
+ // this method is not supposed to fail
+ assert(videoView != nil);
+
+ msg_Dbg(getIntf(), "returning videoview with proposed position x=%i, y=%i, width=%i, height=%i", cfg->x, cfg->y, cfg->width, cfg->height);
+ p_wnd->handle.nsobject = (void *)CFBridgingRetain(videoView);
+ }
+ if (cfg->is_fullscreen)
+ vout_window_SetFullScreen(p_wnd, NULL);
+ return VLC_SUCCESS;
+}
+
+static void WindowDisable(vout_window_t *p_wnd)
+{
+ @autoreleasepool {
+ VLCVideoOutputProvider *voutProvider = [[VLCMain sharedInstance] voutProvider];
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [voutProvider removeVoutForDisplay:[NSValue valueWithPointer:p_wnd]];
+ });
+ }
+}
+
+static void WindowResize(vout_window_t *p_wnd,
+ unsigned i_width, unsigned i_height)
+{
+ @autoreleasepool {
+ VLCVideoOutputProvider *voutProvider = [[VLCMain sharedInstance] voutProvider];
+
dispatch_async(dispatch_get_main_queue(), ^{
[voutProvider setNativeVideoSize:NSMakeSize(i_width, i_height)
forWindow:p_wnd];
@@ -62,9 +100,6 @@ static void WindowSetState(vout_window_t *p_wnd, unsigned i_state)
@autoreleasepool {
VLCVideoOutputProvider *voutProvider = [[VLCMain sharedInstance] voutProvider];
- if (!voutProvider) {
- return;
- }
NSInteger i_cooca_level = NSNormalWindowLevel;
@@ -91,9 +126,6 @@ static void WindowSetFullscreen(vout_window_t *p_wnd, const char *psz_id)
@autoreleasepool {
VLCVideoOutputProvider *voutProvider = [[VLCMain sharedInstance] voutProvider];
- if (!voutProvider) {
- return;
- }
dispatch_async(dispatch_get_main_queue(), ^{
[voutProvider setFullscreen:i_full
@@ -110,13 +142,11 @@ static void WindowUnsetFullscreen(vout_window_t *wnd)
static atomic_bool b_intf_starting = ATOMIC_VAR_INIT(false);
-static void WindowClose(vout_window_t *);
-
static const struct vout_window_operations ops = {
- NULL,
- NULL,
+ WindowEnable,
+ WindowDisable,
WindowResize,
- WindowClose,
+ NULL,
WindowSetState,
WindowUnsetFullscreen,
WindowSetFullscreen,
@@ -124,54 +154,14 @@ static const struct vout_window_operations ops = {
int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
{
- @autoreleasepool {
- msg_Dbg(p_wnd, "Opening video window");
-
- if (!atomic_load(&b_intf_starting)) {
- msg_Err(p_wnd, "Cannot create vout as Mac OS X interface was not found");
- return VLC_EGENERIC;
- }
-
- NSRect proposedVideoViewPosition = NSMakeRect(cfg->x, cfg->y, cfg->width, cfg->height);
-
- VLCVideoOutputProvider *voutProvider = [[VLCMain sharedInstance] voutProvider];
- if (!voutProvider) {
- return VLC_EGENERIC;
- }
-
- __block VLCVoutView *videoView = nil;
-
- dispatch_sync(dispatch_get_main_queue(), ^{
- videoView = [voutProvider setupVoutForWindow:p_wnd
- withProposedVideoViewPosition:proposedVideoViewPosition];
- });
-
- // this method is not supposed to fail
- assert(videoView != nil);
-
- msg_Dbg(getIntf(), "returning videoview with proposed position x=%i, y=%i, width=%i, height=%i", cfg->x, cfg->y, cfg->width, cfg->height);
- p_wnd->handle.nsobject = (void *)CFBridgingRetain(videoView);
-
- p_wnd->type = VOUT_WINDOW_TYPE_NSOBJECT;
- p_wnd->ops = &ops;
+ if (!atomic_load(&b_intf_starting)) {
+ msg_Err(p_wnd, "Cannot create vout as Mac OS X interface was not found");
+ return VLC_EGENERIC;
}
- if (cfg->is_fullscreen)
- vout_window_SetFullScreen(p_wnd, NULL);
- return VLC_SUCCESS;
-}
-static void WindowClose(vout_window_t *p_wnd)
-{
- @autoreleasepool {
- VLCVideoOutputProvider *voutProvider = [[VLCMain sharedInstance] voutProvider];
- if (!voutProvider) {
- return;
- }
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [voutProvider removeVoutForDisplay:[NSValue valueWithPointer:p_wnd]];
- });
- }
+ p_wnd->type = VOUT_WINDOW_TYPE_NSOBJECT;
+ p_wnd->ops = &ops;
+ return VLC_SUCCESS;
}
@interface VLCVideoOutputProvider ()
More information about the vlc-commits
mailing list