gl/cocoa: pass a NSView to set_window_handle instead of a NSWindow

Fix backwards compatibility

https://bugzilla.gnome.org/show_bug.cgi?id=728451
This commit is contained in:
Julien Isorce 2014-04-24 10:37:00 +01:00 committed by Tim-Philipp Müller
parent 9db9834128
commit 2cd72a49ec

View file

@ -81,8 +81,8 @@ static void gst_gl_window_cocoa_send_message_async (GstGLWindow * window,
struct _GstGLWindowCocoaPrivate struct _GstGLWindowCocoaPrivate
{ {
GstGLNSWindow *internal_win_id; GstGLNSWindow *internal_win_id;
NSView *external_view;
gboolean visible; gboolean visible;
NSWindow *parent;
NSThread *thread; NSThread *thread;
gboolean running; gboolean running;
}; };
@ -179,11 +179,11 @@ gst_gl_window_cocoa_set_window_handle (GstGLWindow * window, guintptr handle)
} }
if (handle) { if (handle) {
priv->parent = (NSWindow*) handle; priv->external_view = (NSView *) handle;
priv->visible = TRUE; priv->visible = TRUE;
} else { } else {
/* bring back our internal window */ /* bring back our internal window */
priv->parent = priv->internal_win_id; priv->external_view = 0;
priv->visible = FALSE; priv->visible = FALSE;
} }
@ -193,7 +193,7 @@ gst_gl_window_cocoa_set_window_handle (GstGLWindow * window, guintptr handle)
[pool release]; [pool release];
} else { } else {
/* not internal window yet so delay it to the next drawing */ /* not internal window yet so delay it to the next drawing */
priv->parent = (NSWindow*) handle; priv->external_view = (NSView*) handle;
priv->visible = FALSE; priv->visible = FALSE;
} }
} }
@ -216,12 +216,12 @@ gst_gl_window_cocoa_draw (GstGLWindow * window, guint width, guint height)
/* useful when set_window_handle is called before /* useful when set_window_handle is called before
* the internal NSWindow */ * the internal NSWindow */
if (priv->parent && !priv->visible) { if (priv->external_view && !priv->visible) {
gst_gl_window_cocoa_set_window_handle (window, (guintptr) priv->parent); gst_gl_window_cocoa_set_window_handle (window, (guintptr) priv->external_view);
priv->visible = TRUE; priv->visible = TRUE;
} }
if (!priv->parent && !priv->visible) { if (!priv->external_view && !priv->visible) {
static gint x = 0; static gint x = 0;
static gint y = 0; static gint y = 0;
@ -383,9 +383,15 @@ gst_gl_window_cocoa_send_message_async (GstGLWindow * window,
[self orderOut:m_cocoa->priv->internal_win_id]; [self orderOut:m_cocoa->priv->internal_win_id];
if (m_cocoa->priv->parent) { if (m_cocoa->priv->external_view) {
NSWindow *window = m_cocoa->priv->parent; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[window setContentView: [m_cocoa->priv->internal_win_id contentView]]; NSView *view = [m_cocoa->priv->internal_win_id contentView];
[m_cocoa->priv->external_view addSubview: view];
[view setFrame: [m_cocoa->priv->external_view bounds]];
[view setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
[pool release];
} }
return self; return self;
@ -581,11 +587,14 @@ gst_gl_window_cocoa_send_message_async (GstGLWindow * window,
- (void) setWindow { - (void) setWindow {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSWindow *window = m_cocoa->priv->parent; NSView *view = [m_cocoa->priv->internal_win_id contentView];
[m_cocoa->priv->internal_win_id orderOut:m_cocoa->priv->internal_win_id]; [m_cocoa->priv->internal_win_id orderOut:m_cocoa->priv->internal_win_id];
[window setContentView: [m_cocoa->priv->internal_win_id contentView]]; [m_cocoa->priv->external_view addSubview: view];
[view setFrame: [m_cocoa->priv->external_view bounds]];
[view setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
[pool release]; [pool release];
} }