- (void)dealloc
{
free( psz_name );
+ [super dealloc];
}
- (char *)name
@interface VLCWindow : NSWindow
{
vout_thread_t * p_vout;
- vout_thread_t * p_real_vout;
+ NSView * o_view;
+ NSRect * s_frame;
+ vout_thread_t * p_real_vout;
Ptr p_fullscreen_state;
mtime_t i_time_mouse_last_moved;
- NSRect * s_frame;
vlc_bool_t b_init_ok;
}
-- (id) initWithVout: (vout_thread_t *) p_vout frame: (NSRect *) s_frame;
+- (id) initWithVout: (vout_thread_t *) p_vout view: (NSView *) view
+ frame: (NSRect *) s_frame;
- (id) initReal: (id) sender;
-- (void)close;
+- (void) close;
+- (id) closeReal: (id) sender;
- (void)setOnTop:(BOOL)b_on_top;
- (void)hideMouse:(BOOL)b_hide;
*****************************************************************************/
@implementation VLCWindow
-- (id) initWithVout: (vout_thread_t *) vout frame: (NSRect *) frame
+- (id) initWithVout: (vout_thread_t *) vout view: (NSView *) view
+ frame: (NSRect *) frame
{
p_vout = vout;
+ o_view = view;
s_frame = frame;
- if( MACOS_VERSION >= 10.2 )
- {
- [self performSelectorOnMainThread: @selector(initReal:)
- withObject: NULL waitUntilDone: YES];
- }
- else
- {
- [self initReal: NULL];
- }
+ [self performSelectorOnMainThread: @selector(initReal:)
+ withObject: NULL waitUntilDone: YES];
if( !b_init_ok )
{
/* We'll catch mouse events */
[self setAcceptsMouseMovedEvents: YES];
[self makeFirstResponder: self];
+
+ /* Add the view. It's automatically resized to fit the window */
+ [self setContentView: o_view];
[o_pool release];
return self;
}
-- (void)close
+- (void) close
+{
+ /* XXX waitUntilDone = NO to avoid a possible deadlock when hitting
+ Command-Q */
+ [self performSelectorOnMainThread: @selector(closeReal:)
+ withObject: NULL waitUntilDone: NO];
+}
+
+- (id) closeReal: (id) sender
{
[super close];
if( p_fullscreen_state )
{
EndFullScreen( p_fullscreen_state, 0 );
}
+ return NULL;
}
- (void)setOnTop:(BOOL)b_on_top
NSPoint ml;
NSRect s_rect;
BOOL b_inside;
- NSView * o_view;
i_time_mouse_last_moved = mdate();
- o_view = [self contentView];
s_rect = [o_view bounds];
ml = [o_view convertPoint: [o_event locationInWindow] fromView: nil];
b_inside = [o_view mouse: ml inRect: s_rect];
vout_thread_t * p_vout;
}
-- (id)initWithFrame: (NSRect) frame vout: (vout_thread_t*) p_vout;
-
+- (id) initWithVout: (vout_thread_t *) p_vout;
@end
-
struct vout_sys_t
{
NSAutoreleasePool * o_pool;
p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
vlc_mutex_init( p_vout, &p_vout->p_sys->lock );
- /* Spawn window */
+ /* Create the GL view */
+ p_vout->p_sys->o_glview = [[VLCGLView alloc] initWithVout: p_vout];
+ [p_vout->p_sys->o_glview autorelease];
+
+ /* Spawn the window */
p_vout->p_sys->b_got_frame = VLC_FALSE;
p_vout->p_sys->o_window = [[VLCWindow alloc] initWithVout: p_vout
- frame: nil];
+ view: p_vout->p_sys->o_glview frame: nil];
if( !p_vout->p_sys->o_window )
{
return VLC_EGENERIC;
}
- /* Add OpenGL view */
-#define o_glview p_vout->p_sys->o_glview
- o_glview = [[VLCGLView alloc] initWithFrame:
- [p_vout->p_sys->o_window frame] vout: p_vout];
- [p_vout->p_sys->o_window setContentView: o_glview];
- [o_glview autorelease];
-#undef o_glview
-
p_vout->pf_init = Init;
p_vout->pf_end = End;
p_vout->pf_manage = Manage;
vout_thread_t * p_vout = (vout_thread_t *) p_this;
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
- /* Remove the GLView from the window, because we are not sure OS X
- will actually close the window right away. When it doesn't,
- VLCGLView's reshape is called while p_vout and p_vout->p_sys
- aren't valid anymore and crashes. */
- [p_vout->p_sys->o_window setContentView: NULL];
-
/* Close the window */
[p_vout->p_sys->o_window close];
p_vout->b_fullscreen = !p_vout->b_fullscreen;
+#define o_glview p_vout->p_sys->o_glview
+ o_glview = [[VLCGLView alloc] initWithVout: p_vout];
+ [o_glview autorelease];
+
if( p_vout->p_sys->b_saved_frame )
{
p_vout->p_sys->o_window = [[VLCWindow alloc]
- initWithVout: p_vout frame: &p_vout->p_sys->s_frame];
+ initWithVout: p_vout view: o_glview
+ frame: &p_vout->p_sys->s_frame];
}
else
{
p_vout->p_sys->o_window = [[VLCWindow alloc]
- initWithVout: p_vout frame: nil];
+ initWithVout: p_vout view: o_glview frame: nil];
}
-#define o_glview p_vout->p_sys->o_glview
- o_glview = [[VLCGLView alloc] initWithFrame: [p_vout->p_sys->o_window frame] vout: p_vout];
- [p_vout->p_sys->o_window setContentView: o_glview];
- [o_glview autorelease];
[[o_glview openGLContext] makeCurrentContext];
#undef o_glview
+
[o_pool release];
p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
*****************************************************************************/
@implementation VLCGLView
-- (id) initWithFrame: (NSRect) frame vout: (vout_thread_t*) _p_vout
+- (id) initWithVout: (vout_thread_t *) vout
{
- p_vout = _p_vout;
+ p_vout = vout;
NSOpenGLPixelFormatAttribute attribs[] =
{
return nil;
}
- self = [super initWithFrame:frame pixelFormat: fmt];
+ self = [super initWithFrame: NSMakeRect(0,0,10,10) pixelFormat: fmt];
[fmt release];
[[self openGLContext] makeCurrentContext];
else
p_vout->p_sys->b_embedded = VLC_FALSE;
- if( p_vout->p_sys->b_embedded )
- {
- /* Zero the clipping rectangle */
- p_vout->p_sys->clipping_rect.left = 0;
- p_vout->p_sys->clipping_rect.right = 0;
- p_vout->p_sys->clipping_rect.top = 0;
- p_vout->p_sys->clipping_rect.bottom = 0;
- }
- else
- {
- /* Spawn window */
- p_vout->p_sys->o_window =
- [[VLCWindow alloc] initWithVout: p_vout frame: nil];
- if( !p_vout->p_sys->o_window )
- {
- return VLC_EGENERIC;
- }
- }
-
p_vout->p_sys->b_altivec = p_vout->p_libvlc->i_cpu & CPU_CAPABILITY_ALTIVEC;
msg_Dbg( p_vout, "We do%s have Altivec", p_vout->p_sys->b_altivec ? "" : "n't" );
#define o_qtview p_vout->p_sys->o_qtview
o_qtview = [[VLCQTView alloc] initWithVout: p_vout];
- [p_vout->p_sys->o_window setContentView: o_qtview];
[o_qtview autorelease];
+ if( p_vout->p_sys->b_embedded )
+ {
+ /* Zero the clipping rectangle */
+ p_vout->p_sys->clipping_rect.left = 0;
+ p_vout->p_sys->clipping_rect.right = 0;
+ p_vout->p_sys->clipping_rect.top = 0;
+ p_vout->p_sys->clipping_rect.bottom = 0;
+ }
+ else
+ {
+ /* Spawn window */
+ p_vout->p_sys->o_window = [[VLCWindow alloc]
+ initWithVout: p_vout view: o_qtview frame: nil];
+ if( !p_vout->p_sys->o_window )
+ {
+ return VLC_EGENERIC;
+ }
+ }
+
/* Retrieve the QuickDraw port */
if( p_vout->p_sys->b_embedded )
{
p_vout->b_fullscreen = !p_vout->b_fullscreen;
+#define o_qtview p_vout->p_sys->o_qtview
+ o_qtview = [[VLCQTView alloc] initWithVout: p_vout];
+ [o_qtview autorelease];
+
if( p_vout->p_sys->b_saved_frame )
{
p_vout->p_sys->o_window = [[VLCWindow alloc]
- initWithVout: p_vout frame: &p_vout->p_sys->s_frame];
+ initWithVout: p_vout view: o_qtview
+ frame: &p_vout->p_sys->s_frame];
}
else
{
p_vout->p_sys->o_window = [[VLCWindow alloc]
- initWithVout: p_vout frame: nil];
+ initWithVout: p_vout view: o_qtview frame: nil];
}
-#define o_qtview p_vout->p_sys->o_qtview
- o_qtview = [[VLCQTView alloc] initWithVout: p_vout];
- [p_vout->p_sys->o_window setContentView: o_qtview];
- [o_qtview autorelease];
-
/* Retrieve the QuickDraw port */
[o_qtview lockFocus];
p_vout->p_sys->p_qdport = [o_qtview qdPort];