/*****************************************************************************
- * voutgl.m: MacOS X OpenGL provider
+ * macosx.m: MacOS X OpenGL provider
*****************************************************************************
- * Copyright (C) 2001-2011 the VideoLAN team
+ * Copyright (C) 2001-2012 the VideoLAN team
* $Id$
*
* Authors: Colin Delacroix <colin@zoy.org>
#include <vlc_dialog.h>
#include "opengl.h"
+@interface NSWindow (VLCCustomCode)
+- (BOOL)isFullscreen;
+@end
+
/**
* Forward declarations
*/
BOOL _hasPendingReshape;
}
- (void)setVoutDisplay:(vout_display_t *)vd;
+- (vout_display_t *)voutDisplay;
- (void)setVoutFlushing:(BOOL)flushing;
@end
sys->gl.swap = OpenglSwap;
sys->gl.getProcAddress = NULL;
sys->gl.sys = sys;
+ const vlc_fourcc_t *subpicture_chromas;
+ video_format_t fmt = vd->fmt;
- sys->vgl = vout_display_opengl_New(&vd->fmt, NULL, &sys->gl);
- if (!sys->vgl)
+ sys->vgl = vout_display_opengl_New(&vd->fmt, &subpicture_chromas, &sys->gl);
+ if (!sys->vgl)
{
sys->gl.sys = NULL;
goto error;
/* */
vout_display_info_t info = vd->info;
info.has_pictures_invalid = false;
+ info.has_event_thread = true;
+ info.subpicture_chromas = subpicture_chromas;
/* Setup vout_display_t once everything is fine */
vd->info = info;
vout_display_t *vd = (vout_display_t *)this;
vout_display_sys_t *sys = vd->sys;
+ if ([[sys->glView window] level] != NSNormalWindowLevel)
+ [[sys->glView window] setLevel: NSNormalWindowLevel];
+
[sys->glView setVoutDisplay:nil];
var_Destroy(vd, "drawable-nsobject");
[sys->glView setVoutFlushing:NO];
picture_Release (pic);
sys->has_first_frame = true;
- (void)subpicture;
+
+ if (subpicture)
+ subpicture_Delete(subpicture);
}
static int Control (vout_display_t *vd, int query, va_list ap)
{
case VOUT_DISPLAY_CHANGE_FULLSCREEN:
{
- /* todo */
- return VLC_EGENERIC;
+ NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
+ [[sys->glView window] performSelectorOnMainThread:@selector(fullscreen:) withObject: nil waitUntilDone:NO];
+ [o_pool release];
+ return VLC_SUCCESS;
}
case VOUT_DISPLAY_CHANGE_WINDOW_STATE:
{
+ NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
unsigned state = va_arg (ap, unsigned);
- if( (state & VOUT_WINDOW_STATE_ABOVE) != 0)
- [[sys->glView window] setLevel: NSStatusWindowLevel];
- else
- [[sys->glView window] setLevel: NSNormalWindowLevel];
+ [sys->glView performSelectorOnMainThread:@selector(setWindowLevel:) withObject:[NSNumber numberWithUnsignedInt:state] waitUntilDone:NO];
+ [o_pool release];
return VLC_SUCCESS;
}
case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
{
- [[sys->glView window] performZoom: nil];
+ [[sys->glView window] performSelectorOnMainThread:@selector(performZoom:) withObject: nil waitUntilDone:NO];
return VLC_SUCCESS;
}
- case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
case VOUT_DISPLAY_CHANGE_ZOOM:
case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
+ return VLC_SUCCESS;
+ case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
{
+ // is needed in the case we do not an actual resize
+ [sys->glView performSelectorOnMainThread:@selector(reshapeView:) withObject:nil waitUntilDone:NO];
+
+ if (!config_GetInt( vd, "macosx-video-autoresize" ))
+ return VLC_SUCCESS;
+
+ NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
NSPoint topleftbase;
NSPoint topleftscreen;
NSRect new_frame;
const vout_display_cfg_t *cfg;
id o_window = [sys->glView window];
+ if (!o_window)
+ return VLC_SUCCESS; // this is okay, since the event will occur again when we have a window
NSRect windowFrame = [o_window frame];
NSRect glViewFrame = [sys->glView frame];
NSSize windowMinSize = [o_window minSize];
new_frame.origin.x = topleftscreen.x;
new_frame.origin.y = topleftscreen.y - new_frame.size.height;
- [o_window setFrame:new_frame display:YES animate:YES];
+ [sys->glView performSelectorOnMainThread:@selector(setWindowFrameWithValue:) withObject:[NSValue valueWithRect:new_frame] waitUntilDone:NO];
}
+ [o_pool release];
return VLC_SUCCESS;
}
[self setFrame:[value rectValue]];
}
+/**
+ * Gets called by Control() to make sure that we're performing on the main thread
+ */
+- (void)setWindowFrameWithValue:(NSValue *)value
+{
+ if (![[self window] isFullscreen])
+ {
+ NSRect frame = [value rectValue];
+ if (frame.origin.x <= 0.0 && frame.origin.y <= 0.0)
+ [[self window] center];
+ [[self window] setFrame:frame display:YES animate: YES];
+ }
+}
+
/**
* Gets called by the Close and Open methods.
* (Non main thread).
}
}
+- (vout_display_t *)voutDisplay
+{
+ return vd;
+}
/**
* Gets called when the vout will aquire the lock and flush.
glClear(GL_COLOR_BUFFER_BIT);
}
+- (void)reshapeView:(id)sender
+{
+ [self reshape];
+}
+
/**
* Method called by Cocoa when the view is resized.
*/
NSWindow *window = [self window];
// Remove flashes with splitter view.
- if ([window respondsToSelector:@selector(disableScreenUpdatesUntilFlush)])
- [window disableScreenUpdatesUntilFlush];
+ if ([window respondsToSelector:@selector(disableScreenUpdatesUntilFlush)])
+ [window disableScreenUpdatesUntilFlush];
[super renewGState];
}
{
return YES;
}
+
+- (void)setWindowLevel:(NSNumber*)state
+{
+ if( [state unsignedIntValue] & VOUT_WINDOW_STATE_ABOVE )
+ [[self window] setLevel: NSStatusWindowLevel];
+ else
+ [[self window] setLevel: NSNormalWindowLevel];
+}
@end