Commit e4ceccd3 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

-

parent 359a9baf
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* darwin_specific.h: Darwin specific features * darwin_specific.h: Darwin specific features
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: darwin_specific.h,v 1.8 2004/01/25 18:17:08 zorglub Exp $ * $Id$
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -20,4 +20,3 @@ ...@@ -20,4 +20,3 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
...@@ -70,8 +70,6 @@ int E_(OpenIntf) ( vlc_object_t *p_this ) ...@@ -70,8 +70,6 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
p_intf->b_play = VLC_TRUE; p_intf->b_play = VLC_TRUE;
p_intf->pf_run = Run; p_intf->pf_run = Run;
[[VLCMain sharedInstance] setIntf: p_intf];
return( 0 ); return( 0 );
} }
...@@ -99,21 +97,24 @@ static void Run( intf_thread_t *p_intf ) ...@@ -99,21 +97,24 @@ static void Run( intf_thread_t *p_intf )
* fails to go to real-time priority with the first launched thread * fails to go to real-time priority with the first launched thread
* (???) --Meuuh */ * (???) --Meuuh */
vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
[[VLCMain sharedInstance] setIntf: p_intf];
[NSBundle loadNibNamed: @"MainMenu" owner: NSApp]; [NSBundle loadNibNamed: @"MainMenu" owner: NSApp];
[NSApp run];
[[VLCMain sharedInstance] terminate];
} }
int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
{ {
int i_ret = 0; int i_ret = 0;
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; //NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
if( [target respondsToSelector: @selector(performSelectorOnMainThread: if( [target respondsToSelector: @selector(performSelectorOnMainThread:
withObject:waitUntilDone:)] ) withObject:waitUntilDone:)] )
{ {
[target performSelectorOnMainThread: sel [target performSelectorOnMainThread: sel
withObject: [NSValue valueWithPointer: p_arg] withObject: [NSValue valueWithPointer: p_arg]
waitUntilDone: YES]; waitUntilDone: NO];
} }
else if( NSApp != nil && [[VLCMain sharedInstance] respondsToSelector: @selector(getIntf)] ) else if( NSApp != nil && [[VLCMain sharedInstance] respondsToSelector: @selector(getIntf)] )
{ {
...@@ -161,7 +162,7 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) ...@@ -161,7 +162,7 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
i_ret = 1; i_ret = 1;
} }
[o_pool release]; //[o_pool release];
return( i_ret ); return( i_ret );
} }
...@@ -290,7 +291,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -290,7 +291,6 @@ static VLCMain *_o_sharedMainInstance = nil;
- (void)awakeFromNib - (void)awakeFromNib
{ {
unsigned int i_key = 0; unsigned int i_key = 0;
intf_thread_t * p_intf = VLCIntf;
playlist_t *p_playlist; playlist_t *p_playlist;
vlc_value_t val; vlc_value_t val;
...@@ -527,7 +527,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -527,7 +527,7 @@ static VLCMain *_o_sharedMainInstance = nil;
vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
} }
/*
- (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename - (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename
{ {
NSDictionary *o_dic = [NSDictionary dictionaryWithObjectsAndKeys: o_filename, @"ITEM_URL", nil]; NSDictionary *o_dic = [NSDictionary dictionaryWithObjectsAndKeys: o_filename, @"ITEM_URL", nil];
...@@ -536,7 +536,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -536,7 +536,7 @@ static VLCMain *_o_sharedMainInstance = nil;
return( TRUE ); return( TRUE );
} }
*/
- (NSString *)localizedString:(char *)psz - (NSString *)localizedString:(char *)psz
{ {
NSString * o_str = nil; NSString * o_str = nil;
...@@ -637,7 +637,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -637,7 +637,7 @@ static VLCMain *_o_sharedMainInstance = nil;
int i; int i;
val.i_int = 0; val.i_int = 0;
p_hotkeys = VLCIntf->p_vlc->p_hotkeys; p_hotkeys = p_intf->p_vlc->p_hotkeys;
i_pressed_modifiers = [o_event modifierFlags]; i_pressed_modifiers = [o_event modifierFlags];
...@@ -658,7 +658,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -658,7 +658,7 @@ static VLCMain *_o_sharedMainInstance = nil;
{ {
if( p_hotkeys[i].i_key == val.i_int ) if( p_hotkeys[i].i_key == val.i_int )
{ {
var_Set( VLCIntf->p_vlc, "key-pressed", val ); var_Set( p_intf->p_vlc, "key-pressed", val );
return YES; return YES;
} }
} }
...@@ -696,6 +696,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -696,6 +696,7 @@ static VLCMain *_o_sharedMainInstance = nil;
- (void)manage - (void)manage
{ {
NSDate * o_sleep_date; NSDate * o_sleep_date;
/* new thread requires a new pool */
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
...@@ -809,7 +810,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -809,7 +810,7 @@ static VLCMain *_o_sharedMainInstance = nil;
{ {
if( [[o_vout_wnd className] isEqualToString: @"VLCWindow"] ) if( [[o_vout_wnd className] isEqualToString: @"VLCWindow"] )
{ {
[o_vout_wnd updateTitle]; ;//[o_vout_wnd updateTitle];
} }
} }
vlc_object_release( (vlc_object_t *)p_vout ); vlc_object_release( (vlc_object_t *)p_vout );
...@@ -1134,7 +1135,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1134,7 +1135,6 @@ static VLCMain *_o_sharedMainInstance = nil;
- (IBAction)timesliderUpdate:(id)sender - (IBAction)timesliderUpdate:(id)sender
{ {
intf_thread_t * p_intf;
input_thread_t * p_input; input_thread_t * p_input;
float f_updated; float f_updated;
......
...@@ -74,29 +74,18 @@ ...@@ -74,29 +74,18 @@
@end @end
/*****************************************************************************
* VLCVout interface
*****************************************************************************/
@interface VLCVout : NSObject
{
}
- (void)createWindow:(NSValue *)o_value;
- (void)destroyWindow:(NSValue *)o_value;
@end
/***************************************************************************** /*****************************************************************************
* vout_sys_t: MacOS X video output method descriptor * vout_sys_t: MacOS X video output method descriptor
*****************************************************************************/ *****************************************************************************/
struct vout_sys_t struct vout_sys_t
{ {
int i_opengl; NSAutoreleasePool *o_pool;
NSRect s_rect; NSRect s_rect;
int b_pos_saved;
VLCWindow * o_window; VLCWindow * o_window;
int i_opengl;
int b_pos_saved;
vlc_bool_t b_mouse_moved; vlc_bool_t b_mouse_moved;
mtime_t i_time_mouse_last_moved; mtime_t i_time_mouse_last_moved;
......
...@@ -68,7 +68,6 @@ static void vout_End ( vout_thread_t * ); ...@@ -68,7 +68,6 @@ static void vout_End ( vout_thread_t * );
static int vout_Manage ( vout_thread_t * ); static int vout_Manage ( vout_thread_t * );
static void vout_Display ( vout_thread_t *, picture_t * ); static void vout_Display ( vout_thread_t *, picture_t * );
static int CoSendRequest ( vout_thread_t *, SEL );
static int CoCreateWindow ( vout_thread_t * ); static int CoCreateWindow ( vout_thread_t * );
static int CoDestroyWindow ( vout_thread_t * ); static int CoDestroyWindow ( vout_thread_t * );
static int CoToggleFullscreen ( vout_thread_t * ); static int CoToggleFullscreen ( vout_thread_t * );
...@@ -119,6 +118,7 @@ int E_(OpenVideo) ( vlc_object_t *p_this ) ...@@ -119,6 +118,7 @@ int E_(OpenVideo) ( vlc_object_t *p_this )
return( 1 ); return( 1 );
} }
p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
p_vout->p_sys->b_mouse_moved = VLC_TRUE; p_vout->p_sys->b_mouse_moved = VLC_TRUE;
p_vout->p_sys->i_time_mouse_last_moved = mdate(); p_vout->p_sys->i_time_mouse_last_moved = mdate();
...@@ -168,6 +168,7 @@ int E_(OpenVideo) ( vlc_object_t *p_this ) ...@@ -168,6 +168,7 @@ int E_(OpenVideo) ( vlc_object_t *p_this )
nil, &p_vout->p_sys->img_dc ); nil, &p_vout->p_sys->img_dc );
vlc_mutex_unlock( &p_vout->p_vlc->quicktime_lock ); vlc_mutex_unlock( &p_vout->p_vlc->quicktime_lock );
if( err == noErr && p_vout->p_sys->img_dc != 0 ) if( err == noErr && p_vout->p_sys->img_dc != 0 )
{ {
p_vout->output.i_chroma = VLC_FOURCC('I','4','2','0'); p_vout->output.i_chroma = VLC_FOURCC('I','4','2','0');
...@@ -192,7 +193,6 @@ int E_(OpenVideo) ( vlc_object_t *p_this ) ...@@ -192,7 +193,6 @@ int E_(OpenVideo) ( vlc_object_t *p_this )
msg_Dbg( p_vout, "using OpenGL mode" ); msg_Dbg( p_vout, "using OpenGL mode" );
} }
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
NSArray * o_screens = [NSScreen screens]; NSArray * o_screens = [NSScreen screens];
if( [o_screens count] > 0 && var_Type( p_vout, "video-device" ) == 0 ) if( [o_screens count] > 0 && var_Type( p_vout, "video-device" ) == 0 )
{ {
...@@ -236,7 +236,6 @@ int E_(OpenVideo) ( vlc_object_t *p_this ) ...@@ -236,7 +236,6 @@ int E_(OpenVideo) ( vlc_object_t *p_this )
val.b_bool = VLC_TRUE; val.b_bool = VLC_TRUE;
var_Set( p_vout, "intf-change", val ); var_Set( p_vout, "intf-change", val );
} }
[o_pool release];
if( CoCreateWindow( p_vout ) ) if( CoCreateWindow( p_vout ) )
{ {
...@@ -433,6 +432,7 @@ static void vout_End( vout_thread_t *p_vout ) ...@@ -433,6 +432,7 @@ static void vout_End( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
void E_(CloseVideo) ( vlc_object_t *p_this ) void E_(CloseVideo) ( vlc_object_t *p_this )
{ {
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
vout_thread_t * p_vout = (vout_thread_t *)p_this; vout_thread_t * p_vout = (vout_thread_t *)p_this;
if( p_vout->p_sys->i_opengl ) if( p_vout->p_sys->i_opengl )
...@@ -457,6 +457,7 @@ void E_(CloseVideo) ( vlc_object_t *p_this ) ...@@ -457,6 +457,7 @@ void E_(CloseVideo) ( vlc_object_t *p_this )
DisposeHandle( (Handle)p_vout->p_sys->h_img_descr ); DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
} }
[o_pool release];
free( p_vout->p_sys ); free( p_vout->p_sys );
} }
...@@ -570,52 +571,120 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -570,52 +571,120 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
} }
/***************************************************************************** /*****************************************************************************
* CoSendRequest: send request to interface thread * CoCreateWindow: create new window
***************************************************************************** *****************************************************************************
* Returns 0 on success, 1 otherwise * Returns 0 on success, 1 otherwise
*****************************************************************************/ *****************************************************************************/
static int CoSendRequest( vout_thread_t *p_vout, SEL sel ) static int CoCreateWindow( vout_thread_t *p_vout )
{ {
int i_ret = 0;
vlc_value_t val; vlc_value_t val;
intf_thread_t * p_intf; VLCQTView * o_view;
NSScreen * o_screen;
vlc_bool_t b_main_screen;
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
VLCVout * o_vlv = [[VLCVout alloc] init]; p_vout->p_sys->o_window = [VLCWindow alloc];
[p_vout->p_sys->o_window setReleasedWhenClosed: YES];
if( ( i_ret = ExecuteOnMainThread( o_vlv, sel, (void *)p_vout ) ) ) if( var_Get( p_vout, "video-device", &val ) < 0 )
{ {
msg_Err( p_vout, "SendRequest: no way to communicate with mt" ); o_screen = [NSScreen mainScreen];
b_main_screen = 1;
} }
else
{
NSArray *o_screens = [NSScreen screens];
unsigned int i_index = val.i_int;
[o_vlv release]; if( [o_screens count] < i_index )
{
o_screen = [NSScreen mainScreen];
b_main_screen = 1;
}
else
{
i_index--;
o_screen = [o_screens objectAtIndex: i_index];
config_PutInt( p_vout, "macosx-vdev", i_index );
b_main_screen = (i_index == 0);
}
}
/*This makes this function dependant of the presence of a macosx if( p_vout->b_fullscreen )
interface. We do not check if this interface exists, since it has {
already been done before.*/ NSRect screen_rect = [o_screen frame];
screen_rect.origin.x = screen_rect.origin.y = 0;
/*p_intf = VLCIntf; if ( b_main_screen && p_vout->p_sys->p_fullscreen_state == NULL )
BeginFullScreen( &p_vout->p_sys->p_fullscreen_state, NULL, 0, 0,
NULL, NULL, fullScreenAllowEvents );
val.b_bool = VLC_TRUE; [p_vout->p_sys->o_window
var_Create(p_intf,"intf-change",VLC_VAR_BOOL); initWithContentRect: screen_rect
var_Set(p_intf, "intf-change",val); styleMask: NSBorderlessWindowMask
*/ backing: NSBackingStoreBuffered
return( i_ret ); defer: NO screen: o_screen];
}
/***************************************************************************** [p_vout->p_sys->o_window setVout: p_vout];
* CoCreateWindow: create new window p_vout->p_sys->b_mouse_moved = YES;
***************************************************************************** p_vout->p_sys->i_time_mouse_last_moved = mdate();
* Returns 0 on success, 1 otherwise }
*****************************************************************************/ else
static int CoCreateWindow( vout_thread_t *p_vout )
{
if( CoSendRequest( p_vout, @selector(createWindow:) ) )
{ {
msg_Err( p_vout, "CoSendRequest (createWindow) failed" ); unsigned int i_stylemask = NSTitledWindowMask |
return( 1 ); NSMiniaturizableWindowMask |
NSClosableWindowMask |
NSResizableWindowMask;
if ( p_vout->p_sys->p_fullscreen_state != NULL )
EndFullScreen ( p_vout->p_sys->p_fullscreen_state, NULL );
p_vout->p_sys->p_fullscreen_state = NULL;
[p_vout->p_sys->o_window
initWithContentRect: p_vout->p_sys->s_rect
styleMask: i_stylemask
backing: NSBackingStoreBuffered
defer: NO screen: o_screen];
[p_vout->p_sys->o_window setVout: p_vout];
[p_vout->p_sys->o_window setAlphaValue: config_GetFloat( p_vout, "macosx-opaqueness" )];
if( config_GetInt( p_vout, "video-on-top" ) )
{
[p_vout->p_sys->o_window setLevel: NSStatusWindowLevel];
} }
return( 0 ); if( !p_vout->p_sys->b_pos_saved )
{
[p_vout->p_sys->o_window center];
}
}
if( !p_vout->p_sys->i_opengl )
{
o_view = [[VLCQTView alloc] init];
/* FIXME: [o_view setMenu:] */
[p_vout->p_sys->o_window setContentView: o_view];
[o_view autorelease];
[o_view lockFocus];
p_vout->p_sys->p_qdport = [o_view qdPort];
[o_view unlockFocus];
}
else
{
#define o_glview p_vout->p_sys->o_glview
o_glview = [[VLCGLView alloc] initWithFrame: p_vout->p_sys->s_rect vout: p_vout];
[p_vout->p_sys->o_window setContentView: o_glview];
[o_glview autorelease];
#undef o_glview
}
[p_vout->p_sys->o_window updateTitle];
[p_vout->p_sys->o_window makeKeyAndOrderFront: nil];
[o_pool release];
return( 0);
} }
/***************************************************************************** /*****************************************************************************
...@@ -625,16 +694,27 @@ static int CoCreateWindow( vout_thread_t *p_vout ) ...@@ -625,16 +694,27 @@ static int CoCreateWindow( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
static int CoDestroyWindow( vout_thread_t *p_vout ) static int CoDestroyWindow( vout_thread_t *p_vout )
{ {
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
VLCHideMouse( p_vout, NO ); VLCHideMouse( p_vout, NO );
if( CoSendRequest( p_vout, @selector(destroyWindow:) ) ) if( !p_vout->b_fullscreen )
{ {
msg_Err( p_vout, "CoSendRequest (destroyWindow) failed" ); NSRect s_rect;
return( 1 );
s_rect = [[p_vout->p_sys->o_window contentView] frame];
p_vout->p_sys->s_rect.size = s_rect.size;
s_rect = [p_vout->p_sys->o_window frame];
p_vout->p_sys->s_rect.origin = s_rect.origin;
p_vout->p_sys->b_pos_saved = YES;
} }
return( 0 ); p_vout->p_sys->p_qdport = nil;
[p_vout->p_sys->o_window close];
p_vout->p_sys->o_window = nil;
[o_pool release];
return 0;
} }
/***************************************************************************** /*****************************************************************************
...@@ -644,6 +724,8 @@ static int CoDestroyWindow( vout_thread_t *p_vout ) ...@@ -644,6 +724,8 @@ static int CoDestroyWindow( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
static int CoToggleFullscreen( vout_thread_t *p_vout ) static int CoToggleFullscreen( vout_thread_t *p_vout )
{ {
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
if( !p_vout->p_sys->i_opengl ) if( !p_vout->p_sys->i_opengl )
{ {
QTDestroySequence( p_vout ); QTDestroySequence( p_vout );
...@@ -684,6 +766,7 @@ static int CoToggleFullscreen( vout_thread_t *p_vout ) ...@@ -684,6 +766,7 @@ static int CoToggleFullscreen( vout_thread_t *p_vout )
} }
} }
[o_pool release];
return( 0 ); return( 0 );
} }
...@@ -1013,12 +1096,12 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -1013,12 +1096,12 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
{ {
return( YES ); return( YES );
} }
/*
- (BOOL)performKeyEquivalent:(NSEvent *)o_event - (BOOL)performKeyEquivalent:(NSEvent *)o_event
{ {
return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event]; return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event];
} }
*/
- (void)keyDown:(NSEvent *)o_event - (void)keyDown:(NSEvent *)o_event
{ {
unichar key = 0; unichar key = 0;
...@@ -1738,146 +1821,3 @@ CATCH_MOUSE_EVENTS ...@@ -1738,146 +1821,3 @@ CATCH_MOUSE_EVENTS
} }
@end @end
/*****************************************************************************
* VLCVout implementation
*****************************************************************************/
@implementation VLCVout
- (void)createWindow:(NSValue *)o_value
{
vlc_value_t val;
VLCQTView * o_view;
NSScreen * o_screen;
vout_thread_t * p_vout;
vlc_bool_t b_main_screen;
p_vout = (vout_thread_t *)[o_value pointerValue];
p_vout->p_sys->o_window = [VLCWindow alloc];
[p_vout->p_sys->o_window setVout: p_vout];
[p_vout->p_sys->o_window setReleasedWhenClosed: YES];
if( var_Get( p_vout, "video-device", &val ) < 0 )
{
o_screen = [NSScreen mainScreen];
b_main_screen = 1;
}
else
{
NSArray *o_screens = [NSScreen screens];
unsigned int i_index = val.i_int;
if( [o_screens count] < i_index )
{
o_screen = [NSScreen mainScreen];
b_main_screen = 1;
}
else
{
i_index--;
o_screen = [o_screens objectAtIndex: i_index];
config_PutInt( p_vout, "macosx-vdev", i_index );
b_main_screen = (i_index == 0);
}
}
if( p_vout->b_fullscreen )
{
NSRect screen_rect = [o_screen frame];
screen_rect.origin.x = screen_rect.origin.y = 0;
if ( b_main_screen && p_vout->p_sys->p_fullscreen_state == NULL )
BeginFullScreen( &p_vout->p_sys->p_fullscreen_state, NULL, 0, 0,
NULL, NULL, fullScreenAllowEvents );
[p_vout->p_sys->o_window
initWithContentRect: screen_rect
styleMask: NSBorderlessWindowMask
backing: NSBackingStoreBuffered
defer: NO screen: o_screen];
//[p_vout->p_sys->o_window setLevel: NSPopUpMenuWindowLevel - 1];
p_vout->p_sys->b_mouse_moved = YES;
p_vout->p_sys->i_time_mouse_last_moved = mdate();
}
else
{
unsigned int i_stylemask = NSTitledWindowMask |
NSMiniaturizableWindowMask |
NSClosableWindowMask |
NSResizableWindowMask;
if ( p_vout->p_sys->p_fullscreen_state != NULL )
EndFullScreen ( p_vout->p_sys->p_fullscreen_state, NULL );
p_vout->p_sys->p_fullscreen_state = NULL;
[p_vout->p_sys->o_window
initWithContentRect: p_vout->p_sys->s_rect
styleMask: i_stylemask
backing: NSBackingStoreBuffered
defer: NO screen: o_screen];
[p_vout->p_sys->o_window setAlphaValue: config_GetFloat( p_vout, "macosx-opaqueness" )];
if( config_GetInt( p_vout, "video-on-top" ) )
{
[p_vout->p_sys->o_window setLevel: NSStatusWindowLevel];
}
if( !p_vout->p_sys->b_pos_saved )
{
[p_vout->p_sys->o_window center];
}
}
if( !p_vout->p_sys->i_opengl )
{
o_view = [[VLCQTView alloc] init];
/* FIXME: [o_view setMenu:] */
[p_vout->p_sys->o_window setContentView: o_view];
[o_view autorelease];
[o_view lockFocus];
p_vout->p_sys->p_qdport = [o_view qdPort];
[o_view unlockFocus];
}
else
{
#define o_glview p_vout->p_sys->o_glview
o_glview = [[VLCGLView alloc] initWithFrame: p_vout->p_sys->s_rect vout: p_vout];
[p_vout->p_sys->o_window setContentView: o_glview];
[o_glview autorelease];
#undef o_glview
}
[p_vout->p_sys->o_window updateTitle];
[p_vout->p_sys->o_window makeKeyAndOrderFront: nil];
}
- (void)destroyWindow:(NSValue *)o_value
{
vout_thread_t * p_vout;
p_vout = (vout_thread_t *)[o_value pointerValue];
if( !p_vout->b_fullscreen )
{
NSRect s_rect;
s_rect = [[p_vout->p_sys->o_window contentView] frame];
p_vout->p_sys->s_rect.size = s_rect.size;
s_rect = [p_vout->p_sys->o_window frame];
p_vout->p_sys->s_rect.origin = s_rect.origin;
p_vout->p_sys->b_pos_saved = YES;
}
p_vout->p_sys->p_qdport = nil;
[p_vout->p_sys->o_window close];
p_vout->p_sys->o_window = nil;
}
@end
...@@ -60,6 +60,17 @@ static int SwitchIntfCallback( vlc_object_t *, char const *, ...@@ -60,6 +60,17 @@ static int SwitchIntfCallback( vlc_object_t *, char const *,
static int AddIntfCallback( vlc_object_t *, char const *, static int AddIntfCallback( vlc_object_t *, char const *,
vlc_value_t , vlc_value_t , void * ); vlc_value_t , vlc_value_t , void * );
#ifdef SYS_DARWIN
/*****************************************************************************
* VLCApplication interface
*****************************************************************************/
@interface VLCApplication : NSApplication
{
}
@end
#endif
/***************************************************************************** /*****************************************************************************
* intf_Create: prepare interface before main loop * intf_Create: prepare interface before main loop
***************************************************************************** *****************************************************************************
...@@ -131,6 +142,8 @@ intf_thread_t* __intf_Create( vlc_object_t *p_this, const char *psz_module ) ...@@ -131,6 +142,8 @@ intf_thread_t* __intf_Create( vlc_object_t *p_this, const char *psz_module )
int intf_RunThread( intf_thread_t *p_intf ) int intf_RunThread( intf_thread_t *p_intf )
{ {
#ifdef SYS_DARWIN #ifdef SYS_DARWIN
NSAutoreleasePool * o_pool;
if( p_intf->b_block ) if( p_intf->b_block )
{ {
/* This is the primary intf */ /* This is the primary intf */
...@@ -143,28 +156,36 @@ int intf_RunThread( intf_thread_t *p_intf ) ...@@ -143,28 +156,36 @@ int intf_RunThread( intf_thread_t *p_intf )
} }
} }
if( p_intf->b_block && !strncmp( p_intf->p_module->psz_shortname, "macosx" , 6 ) ) if( p_intf->b_block && strncmp( p_intf->p_module->psz_shortname, "clivlc", 6) )
{ {
/* this is OSX, we are cheating :) o_pool = [[NSAutoreleasePool alloc] init];
This is NOT I REPEAT NOT blocking since [NSApp run] is */ [VLCApplication sharedApplication];
p_intf->b_block = VLC_FALSE;
RunInterface( p_intf );
p_intf->b_block = VLC_TRUE;
} }
else if( p_intf->b_block && !strncmp( p_intf->p_vlc->psz_object_name, "clivlc", 6 ) )
if( p_intf->b_block && ( !strncmp( p_intf->p_module->psz_shortname, "macosx" , 6 ) ||
!strncmp( p_intf->p_vlc->psz_object_name, "clivlc", 6 ) ) )
{ {
/* VLC OS X in cli mode ( no blocking [NSApp run] ) /* VLC in normal primary interface mode */
this is equal to running in normal non-OSX primary intf mode */
RunInterface( p_intf ); RunInterface( p_intf );
p_intf->b_die = VLC_TRUE; p_intf->b_die = VLC_TRUE;
} }
else else
{ {
/* If anything else is the primary intf and we are not in cli mode, /* Run the interface in a separate thread */
then don't make it blocking ([NSApp run] will be blocking) if( vlc_thread_create( p_intf, "interface", RunInterface,
but run it in a seperate thread. */ VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
p_intf->b_block = VLC_FALSE; {
msg_Err( p_intf, "cannot spawn interface thread" );
return VLC_EGENERIC;
}
if( p_intf->b_block )
{
/* VLC in primary interface mode with a working macosx vout */
[NSApp run];
p_intf->b_die = VLC_TRUE;
}
}
#else #else
if( p_intf->b_block ) if( p_intf->b_block )
{ {
...@@ -183,7 +204,6 @@ int intf_RunThread( intf_thread_t *p_intf ) ...@@ -183,7 +204,6 @@ int intf_RunThread( intf_thread_t *p_intf )
} }
else else
{ {
#endif
/* Run the interface in a separate thread */ /* Run the interface in a separate thread */
if( vlc_thread_create( p_intf, "interface", RunInterface, if( vlc_thread_create( p_intf, "interface", RunInterface,
VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) ) VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
...@@ -192,6 +212,7 @@ int intf_RunThread( intf_thread_t *p_intf ) ...@@ -192,6 +212,7 @@ int intf_RunThread( intf_thread_t *p_intf )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
} }
#endif
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -418,3 +439,37 @@ static int AddIntfCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -418,3 +439,37 @@ static int AddIntfCallback( vlc_object_t *p_this, char const *psz_cmd,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
#ifdef SYS_DARWIN
/*****************************************************************************
* VLCApplication implementation
*****************************************************************************/
@implementation VLCApplication
- (void)stop: (id)sender
{
NSEvent *o_event;
NSAutoreleasePool *o_pool;
[super stop:sender];
o_pool = [[NSAutoreleasePool alloc] init];
/* send a dummy event to break out of the event loop */
o_event = [NSEvent mouseEventWithType: NSLeftMouseDown
location: NSMakePoint( 1, 1 ) modifierFlags: 0
timestamp: 1 windowNumber: [[NSApp mainWindow] windowNumber]
context: [NSGraphicsContext currentContext] eventNumber: 1
clickCount: 1 pressure: 0.0];
[NSApp postEvent: o_event atStart: YES];
[o_pool release];
}
- (void)terminate: (id)sender
{
if( [NSApp isRunning] )
[NSApp stop:sender];
[super terminate: sender];
}
@end
#endif
...@@ -1316,3 +1316,4 @@ static struct hotkey p_hotkeys[] = ...@@ -1316,3 +1316,4 @@ static struct hotkey p_hotkeys[] =
{ "key-history-forward", ACTIONID_HISTORY_FORWARD, 0}, { "key-history-forward", ACTIONID_HISTORY_FORWARD, 0},
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* darwin_specific.m: Darwin specific features * darwin_specific.m: Darwin specific features
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2004 VideoLAN * Copyright (C) 2001-2004 VideoLAN
* $Id: darwin_specific.m,v 1.18 2004/01/06 12:02:06 zorglub Exp $ * $Id$
* *
* Authors: Sam Hocevar <sam@zoy.org> * Authors: Sam Hocevar <sam@zoy.org>
* Christophe Massiot <massiot@via.ecp.fr> * Christophe Massiot <massiot@via.ecp.fr>
......
...@@ -1099,7 +1099,7 @@ static void ErrorThread( vout_thread_t *p_vout ) ...@@ -1099,7 +1099,7 @@ static void ErrorThread( vout_thread_t *p_vout )
* EndThread: thread destruction * EndThread: thread destruction
***************************************************************************** *****************************************************************************
* This function is called when the thread ends after a sucessful * This function is called when the thread ends after a sucessful
* initialization. It frees all ressources allocated by InitThread. * initialization. It frees all resources allocated by InitThread.
*****************************************************************************/ *****************************************************************************/
static void EndThread( vout_thread_t *p_vout ) static void EndThread( vout_thread_t *p_vout )
{ {
......
...@@ -35,16 +35,9 @@ ...@@ -35,16 +35,9 @@
#ifdef HAVE_TIME_H #ifdef HAVE_TIME_H
# include <time.h> /* time() */ # include <time.h> /* time() */
#endif #endif
#ifdef HAVE_STRINGS_H
# include <strings.h> /* strncmp() */
#endif
#include <vlc/vlc.h> #include <vlc/vlc.h>
#ifdef SYS_DARWIN
#include <Cocoa/Cocoa.h>
#endif
/***************************************************************************** /*****************************************************************************
* Local prototypes. * Local prototypes.
*****************************************************************************/ *****************************************************************************/
...@@ -52,46 +45,6 @@ ...@@ -52,46 +45,6 @@
static void SigHandler ( int i_signal ); static void SigHandler ( int i_signal );
#endif #endif
#ifdef SYS_DARWIN
/*****************************************************************************
* VLCApplication interface
*****************************************************************************/
@interface VLCApplication : NSApplication
{
}
@end
/*****************************************************************************
* VLCApplication implementation
*****************************************************************************/
@implementation VLCApplication
- (void)stop: (id)sender
{
NSEvent *o_event;
[super stop:sender];
/* send a dummy event to break out of the event loop */
o_event = [NSEvent mouseEventWithType: NSLeftMouseDown
location: NSMakePoint( 1, 1 ) modifierFlags: 0
timestamp: 1 windowNumber: [[NSApp mainWindow] windowNumber]
context: [NSGraphicsContext currentContext] eventNumber: 1
clickCount: 1 pressure: 0.0];
[NSApp postEvent: o_event atStart: YES];
}
- (void)terminate: (id)sender
{
if( [NSApp isRunning] )
[NSApp stop:sender];
[super terminate: sender];
}
@end
#endif /* SYS_DARWIN */
/***************************************************************************** /*****************************************************************************
* main: parse command line, start interface and spawn threads. * main: parse command line, start interface and spawn threads.
*****************************************************************************/ *****************************************************************************/
...@@ -150,53 +103,14 @@ int main( int i_argc, char *ppsz_argv[] ) ...@@ -150,53 +103,14 @@ int main( int i_argc, char *ppsz_argv[] )
return i_ret; return i_ret;
} }
#ifdef HAVE_STRINGS_H
/* if first 3 chars of argv[0] are cli, then this is clivlc
* We detect this specifically for Mac OS X, so you can launch vlc
* from the commandline even if you are not logged in on the GUI */
if( i_argc > 0 )
{
char *psz_temp;
char *psz_program = psz_temp = ppsz_argv[0];
while( *psz_temp )
{
if( *psz_temp == '/' ) psz_program = ++psz_temp;
else ++psz_temp;
}
b_cli = !strncmp( psz_program, "cli", 3 );
}
#endif
#ifdef SYS_DARWIN
if( !b_cli )
{
[VLCApplication sharedApplication];
}
i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE ); i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE );
if( !b_cli )
{
/* This is a blocking call */
[NSApp run];
}
#else
i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE );
#endif /* SYS_DARWIN */
/* Finish the threads */ /* Finish the threads */
VLC_CleanUp( 0 ); VLC_CleanUp( 0 );
/* Destroy the libvlc structure */ /* Destroy the libvlc structure */
VLC_Destroy( 0 ); VLC_Destroy( 0 );
#ifdef SYS_DARWIN
if( !b_cli )
{
[NSApp terminate:NULL];
}
#endif /* SYS_DARWIN */
return i_ret; return i_ret;
} }
......
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