mirror of
https://code.videolan.org/videolan/vlc
synced 2024-09-28 23:09:59 +02:00
-
This commit is contained in:
parent
359a9bafcc
commit
e4ceccd323
@ -2,7 +2,7 @@
|
||||
* darwin_specific.h: Darwin specific features
|
||||
*****************************************************************************
|
||||
* 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>
|
||||
*
|
||||
@ -20,4 +20,3 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
|
@ -70,8 +70,6 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
|
||||
p_intf->b_play = VLC_TRUE;
|
||||
p_intf->pf_run = Run;
|
||||
|
||||
[[VLCMain sharedInstance] setIntf: p_intf];
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
@ -99,21 +97,24 @@ static void Run( intf_thread_t *p_intf )
|
||||
* fails to go to real-time priority with the first launched thread
|
||||
* (???) --Meuuh */
|
||||
vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
|
||||
[[VLCMain sharedInstance] setIntf: p_intf];
|
||||
[NSBundle loadNibNamed: @"MainMenu" owner: NSApp];
|
||||
[NSApp run];
|
||||
[[VLCMain sharedInstance] terminate];
|
||||
}
|
||||
|
||||
int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
|
||||
{
|
||||
int i_ret = 0;
|
||||
|
||||
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
|
||||
//NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
if( [target respondsToSelector: @selector(performSelectorOnMainThread:
|
||||
withObject:waitUntilDone:)] )
|
||||
{
|
||||
[target performSelectorOnMainThread: sel
|
||||
withObject: [NSValue valueWithPointer: p_arg]
|
||||
waitUntilDone: YES];
|
||||
waitUntilDone: NO];
|
||||
}
|
||||
else if( NSApp != nil && [[VLCMain sharedInstance] respondsToSelector: @selector(getIntf)] )
|
||||
{
|
||||
@ -161,7 +162,7 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
|
||||
i_ret = 1;
|
||||
}
|
||||
|
||||
[o_pool release];
|
||||
//[o_pool release];
|
||||
|
||||
return( i_ret );
|
||||
}
|
||||
@ -290,7 +291,6 @@ static VLCMain *_o_sharedMainInstance = nil;
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
unsigned int i_key = 0;
|
||||
intf_thread_t * p_intf = VLCIntf;
|
||||
playlist_t *p_playlist;
|
||||
vlc_value_t val;
|
||||
|
||||
@ -527,7 +527,7 @@ static VLCMain *_o_sharedMainInstance = nil;
|
||||
|
||||
vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
|
||||
}
|
||||
/*
|
||||
|
||||
- (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename
|
||||
{
|
||||
NSDictionary *o_dic = [NSDictionary dictionaryWithObjectsAndKeys: o_filename, @"ITEM_URL", nil];
|
||||
@ -536,7 +536,7 @@ static VLCMain *_o_sharedMainInstance = nil;
|
||||
|
||||
return( TRUE );
|
||||
}
|
||||
*/
|
||||
|
||||
- (NSString *)localizedString:(char *)psz
|
||||
{
|
||||
NSString * o_str = nil;
|
||||
@ -637,7 +637,7 @@ static VLCMain *_o_sharedMainInstance = nil;
|
||||
int i;
|
||||
|
||||
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];
|
||||
|
||||
@ -658,7 +658,7 @@ static VLCMain *_o_sharedMainInstance = nil;
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -696,6 +696,7 @@ static VLCMain *_o_sharedMainInstance = nil;
|
||||
- (void)manage
|
||||
{
|
||||
NSDate * o_sleep_date;
|
||||
/* new thread requires a new pool */
|
||||
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
|
||||
@ -809,7 +810,7 @@ static VLCMain *_o_sharedMainInstance = nil;
|
||||
{
|
||||
if( [[o_vout_wnd className] isEqualToString: @"VLCWindow"] )
|
||||
{
|
||||
[o_vout_wnd updateTitle];
|
||||
;//[o_vout_wnd updateTitle];
|
||||
}
|
||||
}
|
||||
vlc_object_release( (vlc_object_t *)p_vout );
|
||||
@ -1134,7 +1135,6 @@ static VLCMain *_o_sharedMainInstance = nil;
|
||||
|
||||
- (IBAction)timesliderUpdate:(id)sender
|
||||
{
|
||||
intf_thread_t * p_intf;
|
||||
input_thread_t * p_input;
|
||||
float f_updated;
|
||||
|
||||
|
@ -74,29 +74,18 @@
|
||||
|
||||
@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
|
||||
*****************************************************************************/
|
||||
struct vout_sys_t
|
||||
{
|
||||
int i_opengl;
|
||||
|
||||
NSAutoreleasePool *o_pool;
|
||||
NSRect s_rect;
|
||||
int b_pos_saved;
|
||||
VLCWindow * o_window;
|
||||
|
||||
int i_opengl;
|
||||
int b_pos_saved;
|
||||
|
||||
vlc_bool_t b_mouse_moved;
|
||||
mtime_t i_time_mouse_last_moved;
|
||||
|
||||
|
@ -68,7 +68,6 @@ static void vout_End ( vout_thread_t * );
|
||||
static int vout_Manage ( vout_thread_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 CoDestroyWindow ( vout_thread_t * );
|
||||
static int CoToggleFullscreen ( vout_thread_t * );
|
||||
@ -119,6 +118,7 @@ int E_(OpenVideo) ( vlc_object_t *p_this )
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
|
||||
p_vout->p_sys->b_mouse_moved = VLC_TRUE;
|
||||
p_vout->p_sys->i_time_mouse_last_moved = mdate();
|
||||
|
||||
@ -168,6 +168,7 @@ int E_(OpenVideo) ( vlc_object_t *p_this )
|
||||
nil, &p_vout->p_sys->img_dc );
|
||||
|
||||
vlc_mutex_unlock( &p_vout->p_vlc->quicktime_lock );
|
||||
|
||||
if( err == noErr && p_vout->p_sys->img_dc != 0 )
|
||||
{
|
||||
p_vout->output.i_chroma = VLC_FOURCC('I','4','2','0');
|
||||
@ -192,7 +193,6 @@ int E_(OpenVideo) ( vlc_object_t *p_this )
|
||||
msg_Dbg( p_vout, "using OpenGL mode" );
|
||||
}
|
||||
|
||||
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
|
||||
NSArray * o_screens = [NSScreen screens];
|
||||
if( [o_screens count] > 0 && var_Type( p_vout, "video-device" ) == 0 )
|
||||
{
|
||||
@ -236,7 +236,6 @@ int E_(OpenVideo) ( vlc_object_t *p_this )
|
||||
val.b_bool = VLC_TRUE;
|
||||
var_Set( p_vout, "intf-change", val );
|
||||
}
|
||||
[o_pool release];
|
||||
|
||||
if( CoCreateWindow( p_vout ) )
|
||||
{
|
||||
@ -433,6 +432,7 @@ static void vout_End( vout_thread_t *p_vout )
|
||||
*****************************************************************************/
|
||||
void E_(CloseVideo) ( vlc_object_t *p_this )
|
||||
{
|
||||
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
|
||||
vout_thread_t * p_vout = (vout_thread_t *)p_this;
|
||||
|
||||
if( p_vout->p_sys->i_opengl )
|
||||
@ -457,6 +457,7 @@ void E_(CloseVideo) ( vlc_object_t *p_this )
|
||||
DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
|
||||
}
|
||||
|
||||
[o_pool release];
|
||||
free( p_vout->p_sys );
|
||||
}
|
||||
|
||||
@ -569,39 +570,6 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* CoSendRequest: send request to interface thread
|
||||
*****************************************************************************
|
||||
* Returns 0 on success, 1 otherwise
|
||||
*****************************************************************************/
|
||||
static int CoSendRequest( vout_thread_t *p_vout, SEL sel )
|
||||
{
|
||||
int i_ret = 0;
|
||||
vlc_value_t val;
|
||||
intf_thread_t * p_intf;
|
||||
|
||||
VLCVout * o_vlv = [[VLCVout alloc] init];
|
||||
|
||||
if( ( i_ret = ExecuteOnMainThread( o_vlv, sel, (void *)p_vout ) ) )
|
||||
{
|
||||
msg_Err( p_vout, "SendRequest: no way to communicate with mt" );
|
||||
}
|
||||
|
||||
[o_vlv release];
|
||||
|
||||
/*This makes this function dependant of the presence of a macosx
|
||||
interface. We do not check if this interface exists, since it has
|
||||
already been done before.*/
|
||||
|
||||
/*p_intf = VLCIntf;
|
||||
|
||||
val.b_bool = VLC_TRUE;
|
||||
var_Create(p_intf,"intf-change",VLC_VAR_BOOL);
|
||||
var_Set(p_intf, "intf-change",val);
|
||||
*/
|
||||
return( i_ret );
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* CoCreateWindow: create new window
|
||||
*****************************************************************************
|
||||
@ -609,12 +577,113 @@ static int CoSendRequest( vout_thread_t *p_vout, SEL sel )
|
||||
*****************************************************************************/
|
||||
static int CoCreateWindow( vout_thread_t *p_vout )
|
||||
{
|
||||
if( CoSendRequest( p_vout, @selector(createWindow:) ) )
|
||||
vlc_value_t val;
|
||||
VLCQTView * o_view;
|
||||
NSScreen * o_screen;
|
||||
vlc_bool_t b_main_screen;
|
||||
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
p_vout->p_sys->o_window = [VLCWindow alloc];
|
||||
[p_vout->p_sys->o_window setReleasedWhenClosed: YES];
|
||||
|
||||
if( var_Get( p_vout, "video-device", &val ) < 0 )
|
||||
{
|
||||
msg_Err( p_vout, "CoSendRequest (createWindow) failed" );
|
||||
return( 1 );
|
||||
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 setVout: p_vout];
|
||||
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 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];
|
||||
}
|
||||
|
||||
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 )
|
||||
*****************************************************************************/
|
||||
static int CoDestroyWindow( vout_thread_t *p_vout )
|
||||
{
|
||||
|
||||
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
|
||||
VLCHideMouse( p_vout, NO );
|
||||
|
||||
if( CoSendRequest( p_vout, @selector(destroyWindow:) ) )
|
||||
if( !p_vout->b_fullscreen )
|
||||
{
|
||||
msg_Err( p_vout, "CoSendRequest (destroyWindow) failed" );
|
||||
return( 1 );
|
||||
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;
|
||||
}
|
||||
|
||||
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 )
|
||||
*****************************************************************************/
|
||||
static int CoToggleFullscreen( vout_thread_t *p_vout )
|
||||
{
|
||||
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
if( !p_vout->p_sys->i_opengl )
|
||||
{
|
||||
QTDestroySequence( p_vout );
|
||||
@ -684,6 +766,7 @@ static int CoToggleFullscreen( vout_thread_t *p_vout )
|
||||
}
|
||||
}
|
||||
|
||||
[o_pool release];
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
@ -1013,12 +1096,12 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
|
||||
{
|
||||
return( YES );
|
||||
}
|
||||
|
||||
/*
|
||||
- (BOOL)performKeyEquivalent:(NSEvent *)o_event
|
||||
{
|
||||
return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event];
|
||||
}
|
||||
|
||||
*/
|
||||
- (void)keyDown:(NSEvent *)o_event
|
||||
{
|
||||
unichar key = 0;
|
||||
@ -1738,146 +1821,3 @@ CATCH_MOUSE_EVENTS
|
||||
}
|
||||
|
||||
@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 *,
|
||||
static int AddIntfCallback( vlc_object_t *, char const *,
|
||||
vlc_value_t , vlc_value_t , void * );
|
||||
|
||||
#ifdef SYS_DARWIN
|
||||
/*****************************************************************************
|
||||
* VLCApplication interface
|
||||
*****************************************************************************/
|
||||
@interface VLCApplication : NSApplication
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* 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 )
|
||||
int intf_RunThread( intf_thread_t *p_intf )
|
||||
{
|
||||
#ifdef SYS_DARWIN
|
||||
NSAutoreleasePool * o_pool;
|
||||
|
||||
if( p_intf->b_block )
|
||||
{
|
||||
/* This is the primary 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 :)
|
||||
This is NOT I REPEAT NOT blocking since [NSApp run] is */
|
||||
p_intf->b_block = VLC_FALSE;
|
||||
|
||||
RunInterface( p_intf );
|
||||
p_intf->b_block = VLC_TRUE;
|
||||
o_pool = [[NSAutoreleasePool alloc] init];
|
||||
[VLCApplication sharedApplication];
|
||||
}
|
||||
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] )
|
||||
this is equal to running in normal non-OSX primary intf mode */
|
||||
/* VLC in normal primary interface mode */
|
||||
RunInterface( p_intf );
|
||||
p_intf->b_die = VLC_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If anything else is the primary intf and we are not in cli mode,
|
||||
then don't make it blocking ([NSApp run] will be blocking)
|
||||
but run it in a seperate thread. */
|
||||
p_intf->b_block = VLC_FALSE;
|
||||
/* Run the interface in a separate thread */
|
||||
if( vlc_thread_create( p_intf, "interface", RunInterface,
|
||||
VLC_THREAD_PRIORITY_LOW, 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
|
||||
if( p_intf->b_block )
|
||||
{
|
||||
@ -183,7 +204,6 @@ int intf_RunThread( intf_thread_t *p_intf )
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
/* Run the interface in a separate thread */
|
||||
if( vlc_thread_create( p_intf, "interface", RunInterface,
|
||||
VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
|
||||
@ -192,6 +212,7 @@ int intf_RunThread( intf_thread_t *p_intf )
|
||||
return VLC_EGENERIC;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
@ -418,3 +439,37 @@ static int AddIntfCallback( vlc_object_t *p_this, char const *psz_cmd,
|
||||
|
||||
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[] =
|
||||
{ "key-history-forward", ACTIONID_HISTORY_FORWARD, 0},
|
||||
{ NULL, 0, 0 }
|
||||
};
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* darwin_specific.m: Darwin specific features
|
||||
*****************************************************************************
|
||||
* 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>
|
||||
* Christophe Massiot <massiot@via.ecp.fr>
|
||||
|
@ -1099,7 +1099,7 @@ static void ErrorThread( vout_thread_t *p_vout )
|
||||
* EndThread: thread destruction
|
||||
*****************************************************************************
|
||||
* 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 )
|
||||
{
|
||||
|
86
src/vlc.c
86
src/vlc.c
@ -35,16 +35,9 @@
|
||||
#ifdef HAVE_TIME_H
|
||||
# include <time.h> /* time() */
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h> /* strncmp() */
|
||||
#endif
|
||||
|
||||
#include <vlc/vlc.h>
|
||||
|
||||
#ifdef SYS_DARWIN
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Local prototypes.
|
||||
*****************************************************************************/
|
||||
@ -52,46 +45,6 @@
|
||||
static void SigHandler ( int i_signal );
|
||||
#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.
|
||||
*****************************************************************************/
|
||||
@ -150,53 +103,14 @@ int main( int i_argc, char *ppsz_argv[] )
|
||||
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 );
|
||||
|
||||
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 */
|
||||
VLC_CleanUp( 0 );
|
||||
|
||||
/* Destroy the libvlc structure */
|
||||
VLC_Destroy( 0 );
|
||||
|
||||
#ifdef SYS_DARWIN
|
||||
if( !b_cli )
|
||||
{
|
||||
[NSApp terminate:NULL];
|
||||
}
|
||||
#endif /* SYS_DARWIN */
|
||||
|
||||
return i_ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user