Commit 5df7c698 authored by Eric Petit's avatar Eric Petit

Backport of [11282]

parent 7deac3a3
...@@ -690,6 +690,7 @@ ...@@ -690,6 +690,7 @@
- (void)dealloc - (void)dealloc
{ {
free( psz_name ); free( psz_name );
[super dealloc];
} }
- (char *)name - (char *)name
......
...@@ -30,17 +30,20 @@ ...@@ -30,17 +30,20 @@
@interface VLCWindow : NSWindow @interface VLCWindow : NSWindow
{ {
vout_thread_t * p_vout; 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; Ptr p_fullscreen_state;
mtime_t i_time_mouse_last_moved; mtime_t i_time_mouse_last_moved;
NSRect * s_frame;
vlc_bool_t b_init_ok; 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; - (id) initReal: (id) sender;
- (void)close; - (void) close;
- (id) closeReal: (id) sender;
- (void)setOnTop:(BOOL)b_on_top; - (void)setOnTop:(BOOL)b_on_top;
- (void)hideMouse:(BOOL)b_hide; - (void)hideMouse:(BOOL)b_hide;
......
...@@ -65,20 +65,15 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -65,20 +65,15 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
*****************************************************************************/ *****************************************************************************/
@implementation VLCWindow @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; p_vout = vout;
o_view = view;
s_frame = frame; s_frame = frame;
if( MACOS_VERSION >= 10.2 )
{
[self performSelectorOnMainThread: @selector(initReal:) [self performSelectorOnMainThread: @selector(initReal:)
withObject: NULL waitUntilDone: YES]; withObject: NULL waitUntilDone: YES];
}
else
{
[self initReal: NULL];
}
if( !b_init_ok ) if( !b_init_ok )
{ {
...@@ -283,19 +278,31 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -283,19 +278,31 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
[self setAcceptsMouseMovedEvents: YES]; [self setAcceptsMouseMovedEvents: YES];
[self makeFirstResponder: self]; [self makeFirstResponder: self];
/* Add the view. It's automatically resized to fit the window */
[self setContentView: o_view];
[o_pool release]; [o_pool release];
b_init_ok = VLC_TRUE; b_init_ok = VLC_TRUE;
return self; 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]; [super close];
if( p_fullscreen_state ) if( p_fullscreen_state )
{ {
EndFullScreen( p_fullscreen_state, 0 ); EndFullScreen( p_fullscreen_state, 0 );
} }
return NULL;
} }
- (void)setOnTop:(BOOL)b_on_top - (void)setOnTop:(BOOL)b_on_top
...@@ -701,11 +708,9 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -701,11 +708,9 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
NSPoint ml; NSPoint ml;
NSRect s_rect; NSRect s_rect;
BOOL b_inside; BOOL b_inside;
NSView * o_view;
i_time_mouse_last_moved = mdate(); i_time_mouse_last_moved = mdate();
o_view = [self contentView];
s_rect = [o_view bounds]; s_rect = [o_view bounds];
ml = [o_view convertPoint: [o_event locationInWindow] fromView: nil]; ml = [o_view convertPoint: [o_event locationInWindow] fromView: nil];
b_inside = [o_view mouse: ml inRect: s_rect]; b_inside = [o_view mouse: ml inRect: s_rect];
......
...@@ -48,11 +48,9 @@ ...@@ -48,11 +48,9 @@
vout_thread_t * p_vout; vout_thread_t * p_vout;
} }
- (id)initWithFrame: (NSRect) frame vout: (vout_thread_t*) p_vout; - (id) initWithVout: (vout_thread_t *) p_vout;
@end @end
struct vout_sys_t struct vout_sys_t
{ {
NSAutoreleasePool * o_pool; NSAutoreleasePool * o_pool;
...@@ -99,23 +97,19 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this ) ...@@ -99,23 +97,19 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init]; p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
vlc_mutex_init( p_vout, &p_vout->p_sys->lock ); 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->b_got_frame = VLC_FALSE;
p_vout->p_sys->o_window = [[VLCWindow alloc] initWithVout: p_vout 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 ) if( !p_vout->p_sys->o_window )
{ {
return VLC_EGENERIC; 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_init = Init;
p_vout->pf_end = End; p_vout->pf_end = End;
p_vout->pf_manage = Manage; p_vout->pf_manage = Manage;
...@@ -132,12 +126,6 @@ void E_(CloseVideoGL) ( vlc_object_t * p_this ) ...@@ -132,12 +126,6 @@ void E_(CloseVideoGL) ( vlc_object_t * p_this )
vout_thread_t * p_vout = (vout_thread_t *) p_this; vout_thread_t * p_vout = (vout_thread_t *) p_this;
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init]; 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 */ /* Close the window */
[p_vout->p_sys->o_window close]; [p_vout->p_sys->o_window close];
...@@ -177,23 +165,25 @@ static int Manage( vout_thread_t * p_vout ) ...@@ -177,23 +165,25 @@ static int Manage( vout_thread_t * p_vout )
p_vout->b_fullscreen = !p_vout->b_fullscreen; 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 ) if( p_vout->p_sys->b_saved_frame )
{ {
p_vout->p_sys->o_window = [[VLCWindow alloc] 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 else
{ {
p_vout->p_sys->o_window = [[VLCWindow alloc] 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]; [[o_glview openGLContext] makeCurrentContext];
#undef o_glview #undef o_glview
[o_pool release]; [o_pool release];
p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE; p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
...@@ -246,9 +236,9 @@ static void Unlock( vout_thread_t * p_vout ) ...@@ -246,9 +236,9 @@ static void Unlock( vout_thread_t * p_vout )
*****************************************************************************/ *****************************************************************************/
@implementation VLCGLView @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[] = NSOpenGLPixelFormatAttribute attribs[] =
{ {
...@@ -270,7 +260,7 @@ static void Unlock( vout_thread_t * p_vout ) ...@@ -270,7 +260,7 @@ static void Unlock( vout_thread_t * p_vout )
return nil; return nil;
} }
self = [super initWithFrame:frame pixelFormat: fmt]; self = [super initWithFrame: NSMakeRect(0,0,10,10) pixelFormat: fmt];
[fmt release]; [fmt release];
[[self openGLContext] makeCurrentContext]; [[self openGLContext] makeCurrentContext];
......
...@@ -140,25 +140,6 @@ int E_(OpenVideoQT) ( vlc_object_t *p_this ) ...@@ -140,25 +140,6 @@ int E_(OpenVideoQT) ( vlc_object_t *p_this )
else else
p_vout->p_sys->b_embedded = VLC_FALSE; 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; 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" ); msg_Dbg( p_vout, "We do%s have Altivec", p_vout->p_sys->b_altivec ? "" : "n't" );
...@@ -221,9 +202,27 @@ int E_(OpenVideoQT) ( vlc_object_t *p_this ) ...@@ -221,9 +202,27 @@ int E_(OpenVideoQT) ( vlc_object_t *p_this )
#define o_qtview p_vout->p_sys->o_qtview #define o_qtview p_vout->p_sys->o_qtview
o_qtview = [[VLCQTView alloc] initWithVout: p_vout]; o_qtview = [[VLCQTView alloc] initWithVout: p_vout];
[p_vout->p_sys->o_window setContentView: o_qtview];
[o_qtview autorelease]; [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 */ /* Retrieve the QuickDraw port */
if( p_vout->p_sys->b_embedded ) if( p_vout->p_sys->b_embedded )
{ {
...@@ -498,22 +497,22 @@ static int CoToggleFullscreen( vout_thread_t *p_vout ) ...@@ -498,22 +497,22 @@ static int CoToggleFullscreen( vout_thread_t *p_vout )
p_vout->b_fullscreen = !p_vout->b_fullscreen; 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 ) if( p_vout->p_sys->b_saved_frame )
{ {
p_vout->p_sys->o_window = [[VLCWindow alloc] 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 else
{ {
p_vout->p_sys->o_window = [[VLCWindow alloc] 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 */ /* Retrieve the QuickDraw port */
[o_qtview lockFocus]; [o_qtview lockFocus];
p_vout->p_sys->p_qdport = [o_qtview qdPort]; p_vout->p_sys->p_qdport = [o_qtview qdPort];
......
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