diff options
author | wm4 <wm4@mplayer2.org> | 2012-04-29 07:16:09 +0200 |
---|---|---|
committer | wm4 <wm4@mplayer2.org> | 2012-04-29 10:01:28 +0200 |
commit | 97ac824124fc5cdfbd9ac74156b79c098bce09c6 (patch) | |
tree | 2c924403e2fb619ec57ee0933cd12d32ef1bb62a /libvo/cocoa_common.m | |
parent | 87f4cafe9c0881743d1117c2e8cd7e3376e33302 (diff) | |
parent | f64a4e9931428de0f308f6ed0a0144edb8ce9619 (diff) | |
download | mpv-97ac824124fc5cdfbd9ac74156b79c098bce09c6.tar.bz2 mpv-97ac824124fc5cdfbd9ac74156b79c098bce09c6.tar.xz |
Merge remote-tracking branch 'origin/master'
Conflicts:
bstr.c
bstr.h
libvo/cocoa_common.m
libvo/gl_common.c
libvo/video_out.c
mplayer.c
screenshot.c
sub/subassconvert.c
Merge of cocoa_common.m done by pigoz.
Picking my version of screenshot.c. The fix in commit aadf1002f8a will
be redone in a follow-up commit, as the original commit causes too many
conflicts with the work done locally in this branch, and other work in
progress.
Diffstat (limited to 'libvo/cocoa_common.m')
-rw-r--r-- | libvo/cocoa_common.m | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/libvo/cocoa_common.m b/libvo/cocoa_common.m index e8ef278b1e..66f4cd3937 100644 --- a/libvo/cocoa_common.m +++ b/libvo/cocoa_common.m @@ -21,6 +21,8 @@ #import <OpenGL/OpenGL.h> #import <QuartzCore/QuartzCore.h> #import <CoreServices/CoreServices.h> // for CGDisplayHideCursor and Gestalt +#include <dlfcn.h> + #include "cocoa_common.h" #include "options.h" @@ -66,6 +68,7 @@ struct vo_cocoa_state { NSAutoreleasePool *pool; GLMPlayerWindow *window; NSOpenGLContext *glContext; + NSOpenGLPixelFormat *pixelFormat; NSSize current_video_size; NSSize previous_video_size; @@ -125,6 +128,24 @@ struct vo_cocoa_state *vo_cocoa_init_state(void) return s; } +bool vo_cocoa_gui_running(void) +{ + return !!s; +} + +void *vo_cocoa_glgetaddr(const char *s) +{ + void *ret = NULL; + void *handle = dlopen( + "/System/Library/Frameworks/OpenGL.framework/OpenGL", + RTLD_LAZY | RTLD_LOCAL); + if (!handle) + return NULL; + ret = dlsym(handle, s); + dlclose(handle); + return ret; +} + int vo_cocoa_init(struct vo *vo) { s = vo_cocoa_init_state(); @@ -140,6 +161,8 @@ int vo_cocoa_init(struct vo *vo) void vo_cocoa_uninit(struct vo *vo) { CGDisplayShowCursor(kCGDirectMainDisplay); + [NSApp setPresentationOptions:NSApplicationPresentationDefault]; + [s->window release]; s->window = nil; [s->glContext release]; @@ -148,6 +171,7 @@ void vo_cocoa_uninit(struct vo *vo) s->pool = nil; talloc_free(s); + s = nil; } void update_screen_info(void) @@ -232,8 +256,8 @@ int vo_cocoa_create_window(struct vo *vo, uint32_t d_width, attr[i++] = (NSOpenGLPixelFormatAttribute)16; // 16 bit depth buffer attr[i] = (NSOpenGLPixelFormatAttribute)0; - NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; - s->glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil]; + s->pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attr] autorelease]; + s->glContext = [[NSOpenGLContext alloc] initWithFormat:s->pixelFormat shareContext:nil]; create_menu(); @@ -365,6 +389,16 @@ int vo_cocoa_swap_interval(int enabled) return 0; } +void *vo_cocoa_cgl_context(void) +{ + return [s->glContext CGLContextObj]; +} + +void *vo_cocoa_cgl_pixel_format(void) +{ + return [s->pixelFormat CGLPixelFormatObj]; +} + void create_menu() { NSMenu *menu; @@ -565,18 +599,19 @@ bool is_lion_or_better(void) - (void) applicationWillBecomeActive:(NSNotification *)aNotification { if (vo_fs) { + [s->window makeKeyAndOrderFront:s->window]; [s->window setLevel:s->fullscreen_window_level]; - [NSApp setPresentationOptions:NSApplicationPresentationHideDock|NSApplicationPresentationHideMenuBar]; - [s->window makeKeyAndOrderFront:nil]; - [NSApp activateIgnoringOtherApps: YES]; + [NSApp setPresentationOptions:NSApplicationPresentationHideDock| + NSApplicationPresentationHideMenuBar]; } } - (void) applicationWillResignActive:(NSNotification *)aNotification { if (vo_fs) { - [s->window setLevel:s->windowed_window_level]; [NSApp setPresentationOptions:NSApplicationPresentationDefault]; + [s->window setLevel:s->windowed_window_level]; + [s->window orderBack:s->window]; } } |