Commit 8d7e530f authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

minimal_macosx: Fix the minimal window.

parent d4db9fc9
...@@ -27,7 +27,10 @@ ...@@ -27,7 +27,10 @@
@interface VLCMinimalVoutWindow : NSWindow @interface VLCMinimalVoutWindow : NSWindow
{ {
NSRect rect; NSRect initialFrame;
NSPoint initialLocation, initialLocationOnScreen;
BOOL fullscreen;
BOOL mouseDraggedShouldResize;
} }
- (id)initWithContentRect:(NSRect)contentRect; - (id)initWithContentRect:(NSRect)contentRect;
......
...@@ -39,14 +39,20 @@ ...@@ -39,14 +39,20 @@
{ {
if( self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) if( self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO])
{ {
rect = contentRect; initialFrame = contentRect;
fullscreen = NO;
[self setBackgroundColor:[NSColor blackColor]]; [self setBackgroundColor:[NSColor blackColor]];
[self setHasShadow:YES];
[self setMovableByWindowBackground: YES]; [self setMovableByWindowBackground: YES];
[self center];
} }
return self; return self;
} }
/* @protocol VLCOpenGLVoutEmbedding */
- (void)addVoutSubview:(NSView *)view - (void)addVoutSubview:(NSView *)view
{ {
[view setAutoresizingMask:NSViewHeightSizable|NSViewWidthSizable];
[[self contentView] addSubview:view]; [[self contentView] addSubview:view];
[view setFrame:[[self contentView] bounds]]; [view setFrame:[[self contentView] bounds]];
} }
...@@ -59,14 +65,17 @@ ...@@ -59,14 +65,17 @@
- (void)enterFullscreen - (void)enterFullscreen
{ {
fullscreen = YES;
initialFrame = [self frame];
SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar); SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar);
[self setFrame:[[self screen] frame] display: YES]; [self setFrame:[[self screen] frame] display:YES animate:YES];
} }
- (void)leaveFullscreen - (void)leaveFullscreen
{ {
fullscreen = NO;
SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar); SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar);
[self setFrame:rect display: YES]; [self setFrame:initialFrame display:YES animate:YES];
} }
- (BOOL)stretchesVideo - (BOOL)stretchesVideo
......
...@@ -52,16 +52,16 @@ int cocoaglvoutviewInit( vout_thread_t * p_vout ) ...@@ -52,16 +52,16 @@ int cocoaglvoutviewInit( vout_thread_t * p_vout )
var_Create( p_vout, "drawable", VLC_VAR_DOINHERIT ); var_Create( p_vout, "drawable", VLC_VAR_DOINHERIT );
var_Get( p_vout, "drawable", &value_drawable ); var_Get( p_vout, "drawable", &value_drawable );
p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
o_cocoaglview_container = (id) value_drawable.i_int; o_cocoaglview_container = (id) value_drawable.i_int;
if (!o_cocoaglview_container) if (!o_cocoaglview_container)
{ {
msg_Warn( p_vout, "No drawable!, spawing a window" ); 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->b_embedded = VLC_FALSE;
p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
/* Create the GL view */ /* Create the GL view */
struct args { vout_thread_t * p_vout; id <VLCOpenGLVoutEmbedding> container; } args = { p_vout, o_cocoaglview_container }; 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 ) ...@@ -95,6 +95,8 @@ void cocoaglvoutviewEnd( vout_thread_t * p_vout )
if( [(id)o_cocoaglview_container respondsToSelector:@selector(removeVoutSubview:)] ) if( [(id)o_cocoaglview_container respondsToSelector:@selector(removeVoutSubview:)] )
[o_cocoaglview_container removeVoutSubview: p_vout->p_sys->o_glview]; [o_cocoaglview_container removeVoutSubview: p_vout->p_sys->o_glview];
[p_vout->p_sys->o_glview release];
[p_vout->p_sys->o_pool release]; [p_vout->p_sys->o_pool release];
} }
...@@ -195,15 +197,22 @@ void cocoaglvoutviewUnlock( vout_thread_t * p_vout ) ...@@ -195,15 +197,22 @@ void cocoaglvoutviewUnlock( vout_thread_t * p_vout )
* vout_thread_t. Must be called from main thread. */ * vout_thread_t. Must be called from main thread. */
+ (void) autoinitOpenGLVoutViewIntVoutWithContainer: (NSData *) argsAsData + (void) autoinitOpenGLVoutViewIntVoutWithContainer: (NSData *) argsAsData
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
struct args { vout_thread_t * p_vout; id <VLCOpenGLVoutEmbedding> container; } * struct args { vout_thread_t * p_vout; id <VLCOpenGLVoutEmbedding> container; } *
args = (struct args *)[argsAsData bytes]; args = (struct args *)[argsAsData bytes];
VLCOpenGLVoutView * oglview; 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]; 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]; [args->container addVoutSubview: oglview];
[pool release];
} }
- (void)dealloc - (void)dealloc
...@@ -365,5 +374,9 @@ void cocoaglvoutviewUnlock( vout_thread_t * p_vout ) ...@@ -365,5 +374,9 @@ void cocoaglvoutviewUnlock( vout_thread_t * p_vout )
CGLUnlockContext([[p_vout->p_sys->o_glview openGLContext] CGLContextObj]); CGLUnlockContext([[p_vout->p_sys->o_glview openGLContext] CGLContextObj]);
} }
- (BOOL)mouseDownCanMoveWindow
{
return YES;
}
@end @end
...@@ -45,6 +45,6 @@ ...@@ -45,6 +45,6 @@
*****************************************************************************/ *****************************************************************************/
struct intf_sys_t struct intf_sys_t
{ {
NSAutoreleasePool * o_pool; int nothing_for_now;
}; };
...@@ -58,12 +58,9 @@ int E_(OpenIntf) ( vlc_object_t *p_this ) ...@@ -58,12 +58,9 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
memset( p_intf->p_sys, 0, sizeof( *p_intf->p_sys ) ); 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; p_intf->pf_run = Run;
return( 0 ); return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -76,6 +73,17 @@ void E_(CloseIntf) ( vlc_object_t *p_this ) ...@@ -76,6 +73,17 @@ void E_(CloseIntf) ( vlc_object_t *p_this )
free( p_intf->p_sys ); 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 * Run: main loop
*****************************************************************************/ *****************************************************************************/
...@@ -95,7 +103,14 @@ static void Run( intf_thread_t *p_intf ) ...@@ -95,7 +103,14 @@ static void Run( intf_thread_t *p_intf )
sigemptyset( &set ); sigemptyset( &set );
sigaddset( &set, SIGTERM ); sigaddset( &set, SIGTERM );
pthread_sigmask( SIG_UNBLOCK, &set, NULL ); 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]; [NSApp run];
[pool release];
} }
...@@ -47,8 +47,9 @@ void E_(CloseVideoGL) ( vlc_object_t * ); ...@@ -47,8 +47,9 @@ void E_(CloseVideoGL) ( vlc_object_t * );
vlc_module_begin(); vlc_module_begin();
/* Minimal interface. see intf.m */ /* Minimal interface. see intf.m */
set_shortname( _( "minimal_macosx" ));
set_description( _("Mac OS X minimal interface") ); set_description( _("Mac OS X minimal interface") );
set_capability( "interface", 50 ); set_capability( "interface", 110 );
set_callbacks( E_(OpenIntf), E_(CloseIntf) ); set_callbacks( E_(OpenIntf), E_(CloseIntf) );
set_category( CAT_INTERFACE ); set_category( CAT_INTERFACE );
set_subcategory( SUBCAT_INTERFACE_MAIN ); set_subcategory( SUBCAT_INTERFACE_MAIN );
...@@ -56,7 +57,7 @@ vlc_module_begin(); ...@@ -56,7 +57,7 @@ vlc_module_begin();
add_submodule(); add_submodule();
/* Will be loaded even without interface module. see voutgl.m */ /* Will be loaded even without interface module. see voutgl.m */
set_description( "Mac OS X minimal OpenGL video output (opens a borderless window)" ); 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_category( CAT_VIDEO);
set_subcategory( SUBCAT_VIDEO_VOUT ); set_subcategory( SUBCAT_VIDEO_VOUT );
set_callbacks( E_(OpenVideoGL), E_(CloseVideoGL) ); set_callbacks( E_(OpenVideoGL), E_(CloseVideoGL) );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment