From 8d7e530f40ef0dfa7de448f786da40c066db9278 Mon Sep 17 00:00:00 2001 From: Pierre d'Herbemont <pdherbemont@videolan.org> Date: Thu, 30 Aug 2007 13:12:47 +0000 Subject: [PATCH] minimal_macosx: Fix the minimal window. --- .../gui/minimal_macosx/VLCMinimalVoutWindow.h | 5 +++- .../gui/minimal_macosx/VLCMinimalVoutWindow.m | 15 ++++++++--- .../gui/minimal_macosx/VLCOpenGLVoutView.m | 21 +++++++++++++--- modules/gui/minimal_macosx/intf.h | 2 +- modules/gui/minimal_macosx/intf.m | 25 +++++++++++++++---- modules/gui/minimal_macosx/macosx.c | 5 ++-- 6 files changed, 57 insertions(+), 16 deletions(-) diff --git a/modules/gui/minimal_macosx/VLCMinimalVoutWindow.h b/modules/gui/minimal_macosx/VLCMinimalVoutWindow.h index 4d889d28794c..1ce8e273907c 100644 --- a/modules/gui/minimal_macosx/VLCMinimalVoutWindow.h +++ b/modules/gui/minimal_macosx/VLCMinimalVoutWindow.h @@ -27,7 +27,10 @@ @interface VLCMinimalVoutWindow : NSWindow { - NSRect rect; + NSRect initialFrame; + NSPoint initialLocation, initialLocationOnScreen; + BOOL fullscreen; + BOOL mouseDraggedShouldResize; } - (id)initWithContentRect:(NSRect)contentRect; diff --git a/modules/gui/minimal_macosx/VLCMinimalVoutWindow.m b/modules/gui/minimal_macosx/VLCMinimalVoutWindow.m index 8a69fdc298ef..5025b36e6df7 100644 --- a/modules/gui/minimal_macosx/VLCMinimalVoutWindow.m +++ b/modules/gui/minimal_macosx/VLCMinimalVoutWindow.m @@ -39,14 +39,20 @@ { if( self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) { - rect = contentRect; + initialFrame = contentRect; + fullscreen = NO; [self setBackgroundColor:[NSColor blackColor]]; + [self setHasShadow:YES]; [self setMovableByWindowBackground: YES]; + [self center]; } return self; } + +/* @protocol VLCOpenGLVoutEmbedding */ - (void)addVoutSubview:(NSView *)view { + [view setAutoresizingMask:NSViewHeightSizable|NSViewWidthSizable]; [[self contentView] addSubview:view]; [view setFrame:[[self contentView] bounds]]; } @@ -59,14 +65,17 @@ - (void)enterFullscreen { + fullscreen = YES; + initialFrame = [self frame]; SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar); - [self setFrame:[[self screen] frame] display: YES]; + [self setFrame:[[self screen] frame] display:YES animate:YES]; } - (void)leaveFullscreen { + fullscreen = NO; SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar); - [self setFrame:rect display: YES]; + [self setFrame:initialFrame display:YES animate:YES]; } - (BOOL)stretchesVideo diff --git a/modules/gui/minimal_macosx/VLCOpenGLVoutView.m b/modules/gui/minimal_macosx/VLCOpenGLVoutView.m index aa7fe0675866..0b6601ca8174 100644 --- a/modules/gui/minimal_macosx/VLCOpenGLVoutView.m +++ b/modules/gui/minimal_macosx/VLCOpenGLVoutView.m @@ -52,16 +52,16 @@ int cocoaglvoutviewInit( vout_thread_t * p_vout ) var_Create( p_vout, "drawable", VLC_VAR_DOINHERIT ); var_Get( p_vout, "drawable", &value_drawable ); + p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init]; + o_cocoaglview_container = (id) value_drawable.i_int; if (!o_cocoaglview_container) { msg_Warn( p_vout, "No drawable!, spawing a window" ); - o_cocoaglview_container = [[VLCMinimalVoutWindow alloc] initWithContentRect: NSMakeRect( 0, 0, 200, 200 )]; } p_vout->p_sys->b_embedded = VLC_FALSE; - p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init]; /* Create the GL view */ struct args { vout_thread_t * p_vout; id <VLCOpenGLVoutEmbedding> container; } args = { p_vout, o_cocoaglview_container }; @@ -95,6 +95,8 @@ void cocoaglvoutviewEnd( vout_thread_t * p_vout ) if( [(id)o_cocoaglview_container respondsToSelector:@selector(removeVoutSubview:)] ) [o_cocoaglview_container removeVoutSubview: p_vout->p_sys->o_glview]; + [p_vout->p_sys->o_glview release]; + [p_vout->p_sys->o_pool release]; } @@ -195,15 +197,22 @@ void cocoaglvoutviewUnlock( vout_thread_t * p_vout ) * vout_thread_t. Must be called from main thread. */ + (void) autoinitOpenGLVoutViewIntVoutWithContainer: (NSData *) argsAsData { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; struct args { vout_thread_t * p_vout; id <VLCOpenGLVoutEmbedding> container; } * args = (struct args *)[argsAsData bytes]; VLCOpenGLVoutView * oglview; + if( !args->container ) + { + args->container = [[VLCMinimalVoutWindow alloc] initWithContentRect: NSMakeRect( 0, 0, args->p_vout->i_window_width, args->p_vout->i_window_height )]; + [(VLCMinimalVoutWindow *)args->container makeKeyAndOrderFront: nil]; + } oglview = [[VLCOpenGLVoutView alloc] initWithVout: args->p_vout container: args->container]; - args->p_vout->p_sys->o_glview = [oglview autorelease]; - + args->p_vout->p_sys->o_glview = oglview; [args->container addVoutSubview: oglview]; + + [pool release]; } - (void)dealloc @@ -365,5 +374,9 @@ void cocoaglvoutviewUnlock( vout_thread_t * p_vout ) CGLUnlockContext([[p_vout->p_sys->o_glview openGLContext] CGLContextObj]); } +- (BOOL)mouseDownCanMoveWindow +{ + return YES; +} @end diff --git a/modules/gui/minimal_macosx/intf.h b/modules/gui/minimal_macosx/intf.h index a43b902f022e..0876f4d215c3 100644 --- a/modules/gui/minimal_macosx/intf.h +++ b/modules/gui/minimal_macosx/intf.h @@ -45,6 +45,6 @@ *****************************************************************************/ struct intf_sys_t { - NSAutoreleasePool * o_pool; + int nothing_for_now; }; diff --git a/modules/gui/minimal_macosx/intf.m b/modules/gui/minimal_macosx/intf.m index 62638e7f2950..340f1955f851 100644 --- a/modules/gui/minimal_macosx/intf.m +++ b/modules/gui/minimal_macosx/intf.m @@ -58,12 +58,9 @@ int E_(OpenIntf) ( vlc_object_t *p_this ) memset( p_intf->p_sys, 0, sizeof( *p_intf->p_sys ) ); - p_intf->p_sys->o_pool = [[NSAutoreleasePool alloc] init]; - - p_intf->b_play = VLC_TRUE; p_intf->pf_run = Run; - return( 0 ); + return VLC_SUCCESS; } /***************************************************************************** @@ -76,6 +73,17 @@ void E_(CloseIntf) ( vlc_object_t *p_this ) free( p_intf->p_sys ); } +/* Dock Connection */ +typedef struct CPSProcessSerNum +{ + UInt32 lo; + UInt32 hi; +} CPSProcessSerNum; + +extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn); +extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); +extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn); + /***************************************************************************** * Run: main loop *****************************************************************************/ @@ -95,7 +103,14 @@ static void Run( intf_thread_t *p_intf ) sigemptyset( &set ); sigaddset( &set, SIGTERM ); pthread_sigmask( SIG_UNBLOCK, &set, NULL ); - + CPSProcessSerNum PSN; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [NSApplication sharedApplication]; + if (!CPSGetCurrentProcess(&PSN)) + if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103)) + if (!CPSSetFrontProcess(&PSN)) + [NSApplication sharedApplication]; [NSApp run]; + [pool release]; } diff --git a/modules/gui/minimal_macosx/macosx.c b/modules/gui/minimal_macosx/macosx.c index 5a664ba1c8da..ae9e6a6c6161 100644 --- a/modules/gui/minimal_macosx/macosx.c +++ b/modules/gui/minimal_macosx/macosx.c @@ -47,8 +47,9 @@ void E_(CloseVideoGL) ( vlc_object_t * ); vlc_module_begin(); /* Minimal interface. see intf.m */ + set_shortname( _( "minimal_macosx" )); set_description( _("Mac OS X minimal interface") ); - set_capability( "interface", 50 ); + set_capability( "interface", 110 ); set_callbacks( E_(OpenIntf), E_(CloseIntf) ); set_category( CAT_INTERFACE ); set_subcategory( SUBCAT_INTERFACE_MAIN ); @@ -56,7 +57,7 @@ vlc_module_begin(); add_submodule(); /* Will be loaded even without interface module. see voutgl.m */ set_description( "Mac OS X minimal OpenGL video output (opens a borderless window)" ); - set_capability( "opengl provider", 50 ); + set_capability( "opengl provider", 110 ); set_category( CAT_VIDEO); set_subcategory( SUBCAT_VIDEO_VOUT ); set_callbacks( E_(OpenVideoGL), E_(CloseVideoGL) ); -- GitLab