2009-02-08 03:27:30 +00:00
|
|
|
/*
|
2009-05-04 16:55:05 +00:00
|
|
|
* CoreVideo video output driver
|
2009-03-07 13:45:48 +00:00
|
|
|
* Copyright (c) 2005 Nicolas Plourde <nicolasplourde@gmail.com>
|
|
|
|
*
|
2009-02-08 03:27:30 +00:00
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2009-05-04 16:55:05 +00:00
|
|
|
#import "vo_corevideo.h"
|
2005-09-04 12:58:16 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ipc.h>
|
2008-11-30 12:55:11 +00:00
|
|
|
#include <sys/mman.h>
|
2008-12-08 00:12:53 +00:00
|
|
|
#include <unistd.h>
|
2008-11-24 13:22:18 +00:00
|
|
|
#include <CoreServices/CoreServices.h>
|
|
|
|
//special workaround for Apple bug #6267445
|
|
|
|
//(OSServices Power API disabled in OSServices.h for 64bit systems)
|
|
|
|
#ifndef __POWER__
|
|
|
|
#include <CoreServices/../Frameworks/OSServices.framework/Headers/Power.h>
|
|
|
|
#endif
|
2005-04-29 11:05:16 +00:00
|
|
|
|
|
|
|
//MPLAYER
|
|
|
|
#include "config.h"
|
|
|
|
#include "fastmemcpy.h"
|
|
|
|
#include "video_out.h"
|
|
|
|
#include "video_out_internal.h"
|
|
|
|
#include "aspect.h"
|
|
|
|
#include "mp_msg.h"
|
|
|
|
#include "m_option.h"
|
2008-12-08 00:02:07 +00:00
|
|
|
#include "mp_fifo.h"
|
2011-01-26 17:40:52 +00:00
|
|
|
#include "sub/sub.h"
|
2008-12-19 20:33:54 +00:00
|
|
|
#include "subopt-helper.h"
|
2005-04-29 11:05:16 +00:00
|
|
|
|
|
|
|
#include "input/input.h"
|
2011-04-25 06:43:59 +00:00
|
|
|
#include "input/keycodes.h"
|
2009-08-28 13:29:07 +00:00
|
|
|
#include "osx_common.h"
|
2005-04-29 11:05:16 +00:00
|
|
|
|
|
|
|
//Cocoa
|
2007-11-28 00:01:35 +00:00
|
|
|
NSDistantObject *mplayerosxProxy;
|
|
|
|
id <MPlayerOSXVOProto> mplayerosxProto;
|
2005-06-02 14:10:52 +00:00
|
|
|
MPlayerOpenGLView *mpGLView;
|
2005-04-29 11:05:16 +00:00
|
|
|
NSAutoreleasePool *autoreleasepool;
|
|
|
|
OSType pixelFormat;
|
|
|
|
|
2005-09-04 12:58:16 +00:00
|
|
|
//shared memory
|
|
|
|
BOOL shared_buffer = false;
|
2008-12-30 21:39:42 +00:00
|
|
|
#define DEFAULT_BUFFER_NAME "mplayerosx"
|
|
|
|
static char *buffer_name;
|
2005-09-04 12:58:16 +00:00
|
|
|
|
2005-06-15 16:54:43 +00:00
|
|
|
//Screen
|
2009-01-18 18:05:16 +00:00
|
|
|
int screen_id = -1;
|
2005-06-15 16:54:43 +00:00
|
|
|
NSRect screen_frame;
|
|
|
|
NSScreen *screen_handle;
|
|
|
|
NSArray *screen_array;
|
2005-04-29 11:05:16 +00:00
|
|
|
|
|
|
|
//image
|
|
|
|
unsigned char *image_data;
|
2007-11-30 04:20:38 +00:00
|
|
|
// For double buffering
|
|
|
|
static uint8_t image_page = 0;
|
|
|
|
static unsigned char *image_datas[2];
|
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
static uint32_t image_width;
|
|
|
|
static uint32_t image_height;
|
|
|
|
static uint32_t image_depth;
|
|
|
|
static uint32_t image_bytes;
|
|
|
|
static uint32_t image_format;
|
|
|
|
|
|
|
|
//vo
|
|
|
|
static int isFullscreen;
|
2005-05-02 01:48:37 +00:00
|
|
|
static int isOntop;
|
2005-05-02 18:05:59 +00:00
|
|
|
static int isRootwin;
|
2005-04-29 11:05:16 +00:00
|
|
|
|
2005-06-16 00:26:47 +00:00
|
|
|
static float winAlpha = 1;
|
2005-04-29 11:05:16 +00:00
|
|
|
static int int_pause = 0;
|
|
|
|
|
2007-11-30 00:03:01 +00:00
|
|
|
static BOOL isLeopardOrLater;
|
|
|
|
|
2011-03-13 15:54:18 +00:00
|
|
|
#define NSLeftAlternateKeyMask (0x000020 | NSAlternateKeyMask)
|
|
|
|
#define NSRightAlternateKeyMask (0x000040 | NSAlternateKeyMask)
|
|
|
|
|
2009-07-06 23:26:13 +00:00
|
|
|
static vo_info_t info =
|
2005-04-29 11:05:16 +00:00
|
|
|
{
|
2009-03-07 17:41:34 +00:00
|
|
|
"Mac OS X Core Video",
|
2009-05-04 16:55:05 +00:00
|
|
|
"corevideo",
|
2005-04-29 11:05:16 +00:00
|
|
|
"Nicolas Plourde <nicolas.plourde@gmail.com>",
|
|
|
|
""
|
|
|
|
};
|
|
|
|
|
2009-05-04 16:55:05 +00:00
|
|
|
LIBVO_EXTERN(corevideo)
|
2005-04-29 11:05:16 +00:00
|
|
|
|
|
|
|
static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride)
|
|
|
|
{
|
|
|
|
switch (image_format)
|
|
|
|
{
|
2010-04-05 13:11:06 +00:00
|
|
|
case IMGFMT_RGB24:
|
|
|
|
vo_draw_alpha_rgb24(w,h,src,srca,stride,image_data+3*(y0*image_width+x0),3*image_width);
|
|
|
|
break;
|
|
|
|
case IMGFMT_ARGB:
|
|
|
|
case IMGFMT_BGRA:
|
2005-04-29 11:05:16 +00:00
|
|
|
vo_draw_alpha_rgb32(w,h,src,srca,stride,image_data+4*(y0*image_width+x0),4*image_width);
|
|
|
|
break;
|
|
|
|
case IMGFMT_YUY2:
|
|
|
|
vo_draw_alpha_yuy2(w,h,src,srca,stride,image_data + (x0 + y0 * image_width) * 2,image_width*2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-01 09:36:04 +00:00
|
|
|
static void update_screen_info(void)
|
2005-04-29 11:05:16 +00:00
|
|
|
{
|
2009-12-15 20:25:50 +00:00
|
|
|
if (screen_id == -1 && xinerama_screen > -1)
|
|
|
|
screen_id = xinerama_screen;
|
|
|
|
|
2005-06-15 16:54:43 +00:00
|
|
|
screen_array = [NSScreen screens];
|
2010-07-25 11:38:45 +00:00
|
|
|
if(screen_id >= (int)[screen_array count])
|
2005-06-15 16:54:43 +00:00
|
|
|
{
|
2009-05-04 16:55:05 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, "[vo_corevideo] Device ID %d does not exist, falling back to main device\n", screen_id);
|
2009-01-18 18:05:16 +00:00
|
|
|
screen_id = -1;
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
2010-07-25 11:38:45 +00:00
|
|
|
if (screen_id < 0 && [mpGLView window])
|
|
|
|
screen_handle = [[mpGLView window] screen];
|
|
|
|
else
|
2010-07-25 11:49:36 +00:00
|
|
|
screen_handle = [screen_array objectAtIndex:(screen_id < 0 ? 0 : screen_id)];
|
2009-09-01 09:36:04 +00:00
|
|
|
|
2010-07-25 11:38:45 +00:00
|
|
|
screen_frame = [screen_handle frame];
|
2007-12-17 15:49:54 +00:00
|
|
|
vo_screenwidth = screen_frame.size.width;
|
|
|
|
vo_screenheight = screen_frame.size.height;
|
2009-09-01 09:36:04 +00:00
|
|
|
xinerama_x = xinerama_y = 0;
|
|
|
|
aspect_save_screenres(vo_screenwidth, vo_screenheight);
|
|
|
|
}
|
|
|
|
|
2009-09-01 20:09:01 +00:00
|
|
|
static void free_file_specific(void)
|
|
|
|
{
|
|
|
|
if(shared_buffer)
|
|
|
|
{
|
|
|
|
[mplayerosxProto stop];
|
|
|
|
mplayerosxProto = nil;
|
|
|
|
[mplayerosxProxy release];
|
|
|
|
mplayerosxProxy = nil;
|
|
|
|
|
|
|
|
if (munmap(image_data, image_width*image_height*image_bytes) == -1)
|
|
|
|
mp_msg(MSGT_VO, MSGL_FATAL, "[vo_corevideo] uninit: munmap failed. Error: %s\n", strerror(errno));
|
|
|
|
|
|
|
|
if (shm_unlink(buffer_name) == -1)
|
|
|
|
mp_msg(MSGT_VO, MSGL_FATAL, "[vo_corevideo] uninit: shm_unlink failed. Error: %s\n", strerror(errno));
|
|
|
|
} else {
|
|
|
|
free(image_datas[0]);
|
|
|
|
if (vo_doublebuffering)
|
|
|
|
free(image_datas[1]);
|
|
|
|
image_datas[0] = NULL;
|
|
|
|
image_datas[1] = NULL;
|
|
|
|
image_data = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-01 09:36:04 +00:00
|
|
|
static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
|
|
|
|
{
|
2009-09-01 20:09:01 +00:00
|
|
|
free_file_specific();
|
2005-09-04 12:58:16 +00:00
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
//misc mplayer setup
|
|
|
|
image_width = width;
|
|
|
|
image_height = height;
|
2009-07-06 23:26:13 +00:00
|
|
|
switch (image_format)
|
2005-04-29 11:05:16 +00:00
|
|
|
{
|
2010-04-05 13:11:06 +00:00
|
|
|
case IMGFMT_RGB24:
|
|
|
|
image_depth = 24;
|
|
|
|
break;
|
|
|
|
case IMGFMT_ARGB:
|
|
|
|
case IMGFMT_BGRA:
|
2005-04-29 11:05:16 +00:00
|
|
|
image_depth = 32;
|
|
|
|
break;
|
2005-09-04 12:58:16 +00:00
|
|
|
case IMGFMT_YUY2:
|
2005-04-29 11:05:16 +00:00
|
|
|
image_depth = 16;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
image_bytes = (image_depth + 7) / 8;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-09-04 12:58:16 +00:00
|
|
|
if(!shared_buffer)
|
2009-07-06 23:26:13 +00:00
|
|
|
{
|
2009-09-20 19:07:57 +00:00
|
|
|
config_movie_aspect((float)d_width/d_height);
|
|
|
|
|
|
|
|
vo_dwidth = d_width *= mpGLView->winSizeMult;
|
|
|
|
vo_dheight = d_height *= mpGLView->winSizeMult;
|
|
|
|
|
2007-11-23 13:22:21 +00:00
|
|
|
image_data = malloc(image_width*image_height*image_bytes);
|
2007-11-30 04:20:38 +00:00
|
|
|
image_datas[0] = image_data;
|
|
|
|
if (vo_doublebuffering)
|
|
|
|
image_datas[1] = malloc(image_width*image_height*image_bytes);
|
|
|
|
image_page = 0;
|
2007-11-23 13:22:21 +00:00
|
|
|
|
2005-09-04 12:58:16 +00:00
|
|
|
vo_fs = flags & VOFLAG_FULLSCREEN;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-09-04 12:58:16 +00:00
|
|
|
//config OpenGL View
|
|
|
|
[mpGLView config];
|
|
|
|
[mpGLView reshape];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-01 12:12:45 +00:00
|
|
|
int shm_fd;
|
2009-05-04 16:55:05 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, "[vo_corevideo] writing output to a shared buffer "
|
2009-04-20 18:20:37 +00:00
|
|
|
"named \"%s\"\n",buffer_name);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2008-11-30 12:55:11 +00:00
|
|
|
// create shared memory
|
2008-12-30 21:39:42 +00:00
|
|
|
shm_fd = shm_open(buffer_name, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
|
2008-11-30 12:55:11 +00:00
|
|
|
if (shm_fd == -1)
|
2005-09-04 12:58:16 +00:00
|
|
|
{
|
2009-07-06 23:26:13 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_FATAL,
|
2009-05-04 16:55:05 +00:00
|
|
|
"[vo_corevideo] failed to open shared memory. Error: %s\n", strerror(errno));
|
2005-09-04 12:58:16 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
|
|
|
|
2008-11-30 12:55:11 +00:00
|
|
|
if (ftruncate(shm_fd, image_width*image_height*image_bytes) == -1)
|
|
|
|
{
|
2009-07-06 23:26:13 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_FATAL,
|
2009-05-04 16:55:05 +00:00
|
|
|
"[vo_corevideo] failed to size shared memory, possibly already in use. Error: %s\n", strerror(errno));
|
2009-09-01 12:12:45 +00:00
|
|
|
close(shm_fd);
|
2008-12-30 21:39:42 +00:00
|
|
|
shm_unlink(buffer_name);
|
2005-09-04 12:58:16 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2008-11-30 12:55:11 +00:00
|
|
|
image_data = mmap(NULL, image_width*image_height*image_bytes,
|
|
|
|
PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0);
|
2009-09-01 12:12:45 +00:00
|
|
|
close(shm_fd);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2008-11-30 12:55:11 +00:00
|
|
|
if (image_data == MAP_FAILED)
|
|
|
|
{
|
2009-07-06 23:26:13 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_FATAL,
|
2009-05-04 16:55:05 +00:00
|
|
|
"[vo_corevideo] failed to map shared memory. Error: %s\n", strerror(errno));
|
2008-12-30 21:39:42 +00:00
|
|
|
shm_unlink(buffer_name);
|
2008-11-30 12:55:11 +00:00
|
|
|
return 1;
|
2009-07-06 23:26:13 +00:00
|
|
|
}
|
|
|
|
|
2009-03-07 17:41:34 +00:00
|
|
|
//connect to mplayerosx
|
2008-12-30 21:39:42 +00:00
|
|
|
mplayerosxProxy=[NSConnection rootProxyForConnectionWithRegisteredName:[NSString stringWithCString:buffer_name] host:nil];
|
2007-11-28 00:01:35 +00:00
|
|
|
if ([mplayerosxProxy conformsToProtocol:@protocol(MPlayerOSXVOProto)]) {
|
|
|
|
[mplayerosxProxy setProtocolForProxy:@protocol(MPlayerOSXVOProto)];
|
|
|
|
mplayerosxProto = (id <MPlayerOSXVOProto>)mplayerosxProxy;
|
2009-09-01 09:36:04 +00:00
|
|
|
[mplayerosxProto startWithWidth: image_width withHeight: image_height withBytes: image_bytes withAspect:d_width*100/d_height];
|
2007-11-28 00:01:35 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
[mplayerosxProxy release];
|
|
|
|
mplayerosxProxy = nil;
|
|
|
|
mplayerosxProto = nil;
|
|
|
|
}
|
2005-09-04 12:58:16 +00:00
|
|
|
}
|
2005-04-29 11:05:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_events(void)
|
|
|
|
{
|
2009-05-18 21:19:11 +00:00
|
|
|
if (mpGLView)
|
|
|
|
[mpGLView check_events];
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_osd(void)
|
|
|
|
{
|
|
|
|
vo_draw_text(image_width, image_height, draw_alpha);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void flip_page(void)
|
|
|
|
{
|
2009-05-18 21:00:35 +00:00
|
|
|
if(shared_buffer) {
|
|
|
|
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
2007-11-28 00:01:35 +00:00
|
|
|
[mplayerosxProto render];
|
2009-05-18 21:00:35 +00:00
|
|
|
[pool release];
|
|
|
|
} else {
|
2007-11-23 04:49:10 +00:00
|
|
|
[mpGLView setCurrentTexture];
|
2005-09-04 12:58:16 +00:00
|
|
|
[mpGLView render];
|
2007-11-30 04:20:38 +00:00
|
|
|
if (vo_doublebuffering) {
|
|
|
|
image_page = 1 - image_page;
|
|
|
|
image_data = image_datas[image_page];
|
|
|
|
}
|
2007-11-23 04:49:10 +00:00
|
|
|
}
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
|
|
|
|
2005-08-05 01:24:37 +00:00
|
|
|
static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y)
|
2005-04-29 11:05:16 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-08-05 01:24:37 +00:00
|
|
|
static int draw_frame(uint8_t *src[])
|
2005-04-29 11:05:16 +00:00
|
|
|
{
|
2010-04-05 07:15:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-29 11:05:16 +00:00
|
|
|
|
2010-04-05 07:15:22 +00:00
|
|
|
static uint32_t draw_image(mp_image_t *mpi)
|
|
|
|
{
|
|
|
|
memcpy_pic(image_data, mpi->planes[0], image_width*image_bytes, image_height, image_width*image_bytes, mpi->stride[0]);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-08-05 01:24:37 +00:00
|
|
|
static int query_format(uint32_t format)
|
2005-04-29 11:05:16 +00:00
|
|
|
{
|
2010-04-05 13:11:06 +00:00
|
|
|
const int supportflags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN;
|
2005-04-29 11:05:16 +00:00
|
|
|
image_format = format;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
switch(format)
|
|
|
|
{
|
|
|
|
case IMGFMT_YUY2:
|
|
|
|
pixelFormat = kYUVSPixelFormat;
|
2010-04-05 13:11:06 +00:00
|
|
|
return supportflags;
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2010-04-05 13:11:06 +00:00
|
|
|
case IMGFMT_RGB24:
|
|
|
|
pixelFormat = k24RGBPixelFormat;
|
|
|
|
return supportflags;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2010-04-05 13:11:06 +00:00
|
|
|
case IMGFMT_ARGB:
|
2005-04-29 11:05:16 +00:00
|
|
|
pixelFormat = k32ARGBPixelFormat;
|
2010-04-05 13:11:06 +00:00
|
|
|
return supportflags;
|
|
|
|
|
|
|
|
case IMGFMT_BGRA:
|
|
|
|
pixelFormat = k32BGRAPixelFormat;
|
|
|
|
return supportflags;
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void uninit(void)
|
|
|
|
{
|
2006-12-10 01:38:54 +00:00
|
|
|
SetSystemUIMode( kUIModeNormal, 0);
|
|
|
|
CGDisplayShowCursor(kCGDirectMainDisplay);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2009-09-01 20:09:01 +00:00
|
|
|
free_file_specific();
|
|
|
|
|
2006-12-10 01:38:54 +00:00
|
|
|
if(mpGLView)
|
|
|
|
{
|
2007-11-26 02:57:02 +00:00
|
|
|
NSAutoreleasePool *finalPool;
|
2007-10-13 12:17:37 +00:00
|
|
|
mpGLView = nil;
|
2006-12-10 01:38:54 +00:00
|
|
|
[autoreleasepool release];
|
2007-11-26 02:57:02 +00:00
|
|
|
finalPool = [[NSAutoreleasePool alloc] init];
|
2007-11-19 12:01:30 +00:00
|
|
|
[NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES];
|
|
|
|
[finalPool release];
|
2006-12-10 01:38:54 +00:00
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2010-11-14 09:12:34 +00:00
|
|
|
free(buffer_name);
|
2008-12-30 21:39:42 +00:00
|
|
|
buffer_name = NULL;
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
|
|
|
|
2009-09-04 18:21:28 +00:00
|
|
|
static const opt_t subopts[] = {
|
2009-01-18 18:05:16 +00:00
|
|
|
{"device_id", OPT_ARG_INT, &screen_id, NULL},
|
2008-12-19 20:33:54 +00:00
|
|
|
{"shared_buffer", OPT_ARG_BOOL, &shared_buffer, NULL},
|
2008-12-30 21:39:42 +00:00
|
|
|
{"buffer_name", OPT_ARG_MSTRZ,&buffer_name, NULL},
|
2008-12-19 20:33:54 +00:00
|
|
|
{NULL}
|
|
|
|
};
|
|
|
|
|
2005-08-05 01:24:37 +00:00
|
|
|
static int preinit(const char *arg)
|
2005-04-29 11:05:16 +00:00
|
|
|
{
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2008-12-19 20:33:54 +00:00
|
|
|
// set defaults
|
2009-01-18 18:05:16 +00:00
|
|
|
screen_id = -1;
|
2008-12-19 20:33:54 +00:00
|
|
|
shared_buffer = false;
|
2009-01-03 22:33:04 +00:00
|
|
|
buffer_name = NULL;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2008-12-19 20:33:54 +00:00
|
|
|
if (subopt_parse(arg, subopts) != 0) {
|
|
|
|
mp_msg(MSGT_VO, MSGL_FATAL,
|
2009-05-04 16:55:05 +00:00
|
|
|
"\n-vo corevideo command line help:\n"
|
|
|
|
"Example: mplayer -vo corevideo:device_id=1:shared_buffer:buffer_name=mybuff\n"
|
2008-12-19 20:33:54 +00:00
|
|
|
"\nOptions:\n"
|
|
|
|
" device_id=<0-...>\n"
|
2009-03-07 17:41:34 +00:00
|
|
|
" Set screen device ID for fullscreen.\n"
|
2008-12-19 20:33:54 +00:00
|
|
|
" shared_buffer\n"
|
|
|
|
" Write output to a shared memory buffer instead of displaying it.\n"
|
2008-12-30 21:39:42 +00:00
|
|
|
" buffer_name=<name>\n"
|
|
|
|
" Name of the shared buffer created with shm_open() as well as\n"
|
|
|
|
" the name of the NSConnection MPlayer will try to open.\n"
|
|
|
|
" Setting buffer_name implicitly enables shared_buffer.\n"
|
2008-12-19 20:33:54 +00:00
|
|
|
"\n" );
|
|
|
|
return -1;
|
|
|
|
}
|
2005-06-15 16:54:43 +00:00
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
autoreleasepool = [[NSAutoreleasePool alloc] init];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2009-01-03 22:33:04 +00:00
|
|
|
if (!buffer_name)
|
|
|
|
buffer_name = strdup(DEFAULT_BUFFER_NAME);
|
|
|
|
else
|
2008-12-30 21:39:42 +00:00
|
|
|
shared_buffer = true;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-09-04 12:58:16 +00:00
|
|
|
if(!shared_buffer)
|
2005-07-28 22:19:34 +00:00
|
|
|
{
|
2009-05-18 21:19:11 +00:00
|
|
|
NSApplicationLoad();
|
|
|
|
NSApp = [NSApplication sharedApplication];
|
|
|
|
isLeopardOrLater = floor(NSAppKitVersionNumber) > 824;
|
|
|
|
|
2010-03-26 15:02:14 +00:00
|
|
|
osx_foreground_hack();
|
2006-01-11 02:45:17 +00:00
|
|
|
|
2005-09-04 12:58:16 +00:00
|
|
|
if(!mpGLView)
|
|
|
|
{
|
|
|
|
mpGLView = [[MPlayerOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) pixelFormat:[MPlayerOpenGLView defaultPixelFormat]];
|
|
|
|
[mpGLView autorelease];
|
|
|
|
}
|
2010-07-25 17:06:41 +00:00
|
|
|
// Install an event handler so the Quit menu entry works
|
|
|
|
// The proper way using NSApp setDelegate: and
|
|
|
|
// applicationShouldTerminate: does not work,
|
|
|
|
// probably NSApplication never installs its handler.
|
|
|
|
[[NSAppleEventManager sharedAppleEventManager]
|
|
|
|
setEventHandler:mpGLView
|
|
|
|
andSelector:@selector(handleQuitEvent:withReplyEvent:)
|
|
|
|
forEventClass:kCoreEventClass
|
|
|
|
andEventID:kAEQuitApplication];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-09-04 12:58:16 +00:00
|
|
|
[mpGLView display];
|
|
|
|
[mpGLView preinit];
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-29 10:29:28 +00:00
|
|
|
static int control(uint32_t request, void *data)
|
2005-04-29 11:05:16 +00:00
|
|
|
{
|
|
|
|
switch (request)
|
|
|
|
{
|
2010-04-05 07:15:22 +00:00
|
|
|
case VOCTRL_DRAW_IMAGE: return draw_image(data);
|
2008-05-16 08:33:27 +00:00
|
|
|
case VOCTRL_PAUSE: return int_pause = 1;
|
|
|
|
case VOCTRL_RESUME: return int_pause = 0;
|
2010-07-25 11:14:07 +00:00
|
|
|
case VOCTRL_QUERY_FORMAT: return query_format(*(uint32_t*)data);
|
|
|
|
case VOCTRL_ONTOP: vo_ontop = !vo_ontop; if(!shared_buffer){ [mpGLView ontop]; } else { [mplayerosxProto ontop]; } return VO_TRUE;
|
|
|
|
case VOCTRL_ROOTWIN: vo_rootwin = !vo_rootwin; [mpGLView rootwin]; return VO_TRUE;
|
|
|
|
case VOCTRL_FULLSCREEN: vo_fs = !vo_fs; if(!shared_buffer){ [mpGLView fullscreen: NO]; } else { [mplayerosxProto toggleFullscreen]; } return VO_TRUE;
|
2005-04-29 11:05:16 +00:00
|
|
|
case VOCTRL_GET_PANSCAN: return VO_TRUE;
|
2005-06-02 14:10:52 +00:00
|
|
|
case VOCTRL_SET_PANSCAN: [mpGLView panscan]; return VO_TRUE;
|
2009-09-01 09:36:04 +00:00
|
|
|
case VOCTRL_UPDATE_SCREENINFO: update_screen_info(); return VO_TRUE;
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
|
|
|
return VO_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// NSOpenGLView Subclass
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2005-06-02 14:10:52 +00:00
|
|
|
@implementation MPlayerOpenGLView
|
2007-08-18 10:30:15 +00:00
|
|
|
- (void) preinit
|
2005-04-29 11:05:16 +00:00
|
|
|
{
|
2009-09-01 21:16:58 +00:00
|
|
|
NSOpenGLContext *glContext;
|
2009-09-01 10:48:47 +00:00
|
|
|
GLint swapInterval = 1;
|
|
|
|
CVReturn error;
|
|
|
|
|
2005-05-25 23:38:59 +00:00
|
|
|
//init menu
|
|
|
|
[self initMenu];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
//create window
|
2009-07-06 23:26:13 +00:00
|
|
|
window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100)
|
2005-04-29 11:05:16 +00:00
|
|
|
styleMask:NSTitledWindowMask|NSTexturedBackgroundWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask
|
2005-06-05 14:57:36 +00:00
|
|
|
backing:NSBackingStoreBuffered defer:NO];
|
2005-04-29 11:05:16 +00:00
|
|
|
|
2005-07-28 22:19:34 +00:00
|
|
|
[window autorelease];
|
2005-06-15 14:48:33 +00:00
|
|
|
[window setDelegate:mpGLView];
|
|
|
|
[window setContentView:mpGLView];
|
|
|
|
[window setInitialFirstResponder:mpGLView];
|
2005-04-29 11:05:16 +00:00
|
|
|
[window setAcceptsMouseMovedEvents:YES];
|
2010-07-25 11:49:36 +00:00
|
|
|
[window setTitle:@"MPlayer - The Movie Player"];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-06-15 14:48:33 +00:00
|
|
|
isFullscreen = 0;
|
2005-06-29 21:54:48 +00:00
|
|
|
winSizeMult = 1;
|
2009-09-01 10:48:47 +00:00
|
|
|
|
|
|
|
//create OpenGL Context
|
|
|
|
glContext = [[NSOpenGLContext alloc] initWithFormat:[NSOpenGLView defaultPixelFormat] shareContext:nil];
|
|
|
|
|
|
|
|
[self setOpenGLContext:glContext];
|
|
|
|
[glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
|
|
|
|
[glContext setView:self];
|
|
|
|
[glContext makeCurrentContext];
|
2009-09-01 21:16:58 +00:00
|
|
|
[glContext release];
|
2009-09-01 10:48:47 +00:00
|
|
|
|
|
|
|
error = CVOpenGLTextureCacheCreate(NULL, 0, [glContext CGLContextObj], [[self pixelFormat] CGLPixelFormatObj], 0, &textureCache);
|
|
|
|
if(error != kCVReturnSuccess)
|
|
|
|
mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture Cache(%d)\n", error);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) releaseVideoSpecific
|
|
|
|
{
|
|
|
|
CVPixelBufferRelease(frameBuffers[0]);
|
|
|
|
frameBuffers[0] = NULL;
|
|
|
|
CVPixelBufferRelease(frameBuffers[1]);
|
|
|
|
frameBuffers[1] = NULL;
|
|
|
|
CVOpenGLTextureRelease(texture);
|
|
|
|
texture = NULL;
|
2005-06-15 14:48:33 +00:00
|
|
|
}
|
|
|
|
|
2009-09-01 21:12:33 +00:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[self releaseVideoSpecific];
|
|
|
|
CVOpenGLTextureCacheRelease(textureCache);
|
|
|
|
textureCache = NULL;
|
|
|
|
[self setOpenGLContext:nil];
|
|
|
|
[super dealloc];
|
2005-06-15 14:48:33 +00:00
|
|
|
}
|
|
|
|
|
2007-08-18 10:30:15 +00:00
|
|
|
- (void) config
|
2005-06-15 14:48:33 +00:00
|
|
|
{
|
2009-12-15 20:38:54 +00:00
|
|
|
NSRect visibleFrame;
|
2005-06-15 14:48:33 +00:00
|
|
|
CVReturn error = kCVReturnSuccess;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-06-15 16:54:43 +00:00
|
|
|
//config window
|
2009-12-15 20:38:54 +00:00
|
|
|
[window setContentSize:NSMakeSize(vo_dwidth, vo_dheight)];
|
|
|
|
|
|
|
|
// Use visibleFrame to position the window taking the menu bar and dock into account.
|
|
|
|
// Also flip vo_dy since the screen origin is in the bottom left on OSX.
|
2010-07-25 11:53:44 +00:00
|
|
|
update_screen_info();
|
|
|
|
visibleFrame = [screen_handle visibleFrame];
|
2009-12-15 20:38:54 +00:00
|
|
|
[window setFrameTopLeftPoint:NSMakePoint(
|
|
|
|
visibleFrame.origin.x + vo_dx,
|
|
|
|
visibleFrame.origin.y + visibleFrame.size.height - vo_dy)];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2009-09-01 10:48:47 +00:00
|
|
|
[self releaseVideoSpecific];
|
2007-11-30 04:20:38 +00:00
|
|
|
error = CVPixelBufferCreateWithBytes(NULL, image_width, image_height, pixelFormat, image_datas[0], image_width*image_bytes, NULL, NULL, NULL, &frameBuffers[0]);
|
2005-04-29 11:05:16 +00:00
|
|
|
if(error != kCVReturnSuccess)
|
2009-05-04 16:55:05 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create Pixel Buffer(%d)\n", error);
|
2007-11-30 04:20:38 +00:00
|
|
|
if (vo_doublebuffering) {
|
|
|
|
error = CVPixelBufferCreateWithBytes(NULL, image_width, image_height, pixelFormat, image_datas[1], image_width*image_bytes, NULL, NULL, NULL, &frameBuffers[1]);
|
|
|
|
if(error != kCVReturnSuccess)
|
2009-05-04 16:55:05 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create Pixel Double Buffer(%d)\n", error);
|
2007-11-30 04:20:38 +00:00
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2007-11-30 04:20:38 +00:00
|
|
|
error = CVOpenGLTextureCacheCreateTextureFromImage(NULL, textureCache, frameBuffers[image_page], 0, &texture);
|
2005-04-29 11:05:16 +00:00
|
|
|
if(error != kCVReturnSuccess)
|
2009-05-04 16:55:05 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture(%d)\n", error);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-06-15 16:54:43 +00:00
|
|
|
//show window
|
|
|
|
[window makeKeyAndOrderFront:mpGLView];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-06-15 14:48:33 +00:00
|
|
|
if(vo_rootwin)
|
2009-07-06 23:26:13 +00:00
|
|
|
[mpGLView rootwin];
|
2005-06-15 14:48:33 +00:00
|
|
|
|
|
|
|
if(vo_fs)
|
|
|
|
[mpGLView fullscreen: NO];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-06-15 14:48:33 +00:00
|
|
|
if(vo_ontop)
|
|
|
|
[mpGLView ontop];
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
|
|
|
|
2005-05-25 23:38:59 +00:00
|
|
|
/*
|
|
|
|
Init Menu
|
|
|
|
*/
|
|
|
|
- (void)initMenu
|
|
|
|
{
|
2006-12-01 14:58:11 +00:00
|
|
|
NSMenu *menu, *aspectMenu;
|
2005-05-25 23:38:59 +00:00
|
|
|
NSMenuItem *menuItem;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2011-03-10 22:29:19 +00:00
|
|
|
menu = [[NSMenu new] autorelease];
|
|
|
|
menuItem = [[NSMenuItem new] autorelease];
|
|
|
|
[menu addItem: menuItem];
|
|
|
|
[NSApp setMainMenu: menu];
|
2005-05-25 23:38:59 +00:00
|
|
|
|
|
|
|
//Create Movie Menu
|
|
|
|
menu = [[NSMenu alloc] initWithTitle:@"Movie"];
|
|
|
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Half Size" action:@selector(menuAction:) keyEquivalent:@"0"]; [menu addItem:menuItem];
|
|
|
|
kHalfScreenCmd = menuItem;
|
|
|
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Normal Size" action:@selector(menuAction:) keyEquivalent:@"1"]; [menu addItem:menuItem];
|
|
|
|
kNormalScreenCmd = menuItem;
|
|
|
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Double Size" action:@selector(menuAction:) keyEquivalent:@"2"]; [menu addItem:menuItem];
|
|
|
|
kDoubleScreenCmd = menuItem;
|
|
|
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Full Size" action:@selector(menuAction:) keyEquivalent:@"f"]; [menu addItem:menuItem];
|
|
|
|
kFullScreenCmd = menuItem;
|
2010-07-25 11:14:07 +00:00
|
|
|
menuItem = [NSMenuItem separatorItem]; [menu addItem:menuItem];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2010-07-25 11:49:36 +00:00
|
|
|
aspectMenu = [[NSMenu alloc] initWithTitle:@"Aspect Ratio"];
|
|
|
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Keep" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
|
|
|
|
if(vo_keepaspect) [menuItem setState:NSOnState];
|
|
|
|
kKeepAspectCmd = menuItem;
|
|
|
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Pan-Scan" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
|
|
|
|
if(vo_panscan) [menuItem setState:NSOnState];
|
|
|
|
kPanScanCmd = menuItem;
|
|
|
|
menuItem = [NSMenuItem separatorItem]; [aspectMenu addItem:menuItem];
|
|
|
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Original" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
|
|
|
|
kAspectOrgCmd = menuItem;
|
|
|
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"4:3" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
|
|
|
|
kAspectFullCmd = menuItem;
|
|
|
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"16:9" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
|
|
|
|
kAspectWideCmd = menuItem;
|
|
|
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Aspect Ratio" action:nil keyEquivalent:@""];
|
|
|
|
[menuItem setSubmenu:aspectMenu];
|
|
|
|
[menu addItem:menuItem];
|
|
|
|
[aspectMenu release];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-05-25 23:38:59 +00:00
|
|
|
//Add to menubar
|
|
|
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Movie" action:nil keyEquivalent:@""];
|
|
|
|
[menuItem setSubmenu:menu];
|
|
|
|
[[NSApp mainMenu] addItem:menuItem];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-05-25 23:38:59 +00:00
|
|
|
//Create Window Menu
|
|
|
|
menu = [[NSMenu alloc] initWithTitle:@"Window"];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-05-25 23:38:59 +00:00
|
|
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; [menu addItem:menuItem];
|
|
|
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""]; [menu addItem:menuItem];
|
|
|
|
|
|
|
|
//Add to menubar
|
|
|
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
|
|
|
[menuItem setSubmenu:menu];
|
|
|
|
[[NSApp mainMenu] addItem:menuItem];
|
|
|
|
[NSApp setWindowsMenu:menu];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-05-25 23:38:59 +00:00
|
|
|
[menu release];
|
|
|
|
[menuItem release];
|
|
|
|
}
|
|
|
|
|
2009-09-04 18:43:28 +00:00
|
|
|
- (void)set_winSizeMult:(float)mult
|
|
|
|
{
|
|
|
|
NSRect frame;
|
|
|
|
int d_width, d_height;
|
|
|
|
aspect(&d_width, &d_height, A_NOZOOM);
|
|
|
|
|
|
|
|
if (isFullscreen) {
|
|
|
|
vo_fs = !vo_fs;
|
|
|
|
[self fullscreen:NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
winSizeMult = mult;
|
|
|
|
frame.size.width = d_width * mult;
|
|
|
|
frame.size.height = d_height * mult;
|
|
|
|
[window setContentSize: frame.size];
|
|
|
|
[self reshape];
|
|
|
|
}
|
|
|
|
|
2005-05-25 23:38:59 +00:00
|
|
|
/*
|
|
|
|
Menu Action
|
|
|
|
*/
|
|
|
|
- (void)menuAction:(id)sender
|
|
|
|
{
|
|
|
|
if(sender == kHalfScreenCmd)
|
2009-09-04 18:43:28 +00:00
|
|
|
[self set_winSizeMult: 0.5];
|
2005-05-25 23:38:59 +00:00
|
|
|
if(sender == kNormalScreenCmd)
|
2009-09-04 18:43:28 +00:00
|
|
|
[self set_winSizeMult: 1];
|
2005-05-25 23:38:59 +00:00
|
|
|
if(sender == kDoubleScreenCmd)
|
2009-09-04 18:43:28 +00:00
|
|
|
[self set_winSizeMult: 2];
|
2005-05-25 23:38:59 +00:00
|
|
|
if(sender == kFullScreenCmd)
|
|
|
|
{
|
2010-07-25 11:14:07 +00:00
|
|
|
vo_fs = !vo_fs;
|
2006-12-09 23:57:28 +00:00
|
|
|
[self fullscreen:NO];
|
2005-05-25 23:38:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(sender == kKeepAspectCmd)
|
|
|
|
{
|
2010-07-25 11:14:07 +00:00
|
|
|
vo_keepaspect = !vo_keepaspect;
|
2005-05-25 23:38:59 +00:00
|
|
|
if(vo_keepaspect)
|
|
|
|
[kKeepAspectCmd setState:NSOnState];
|
|
|
|
else
|
|
|
|
[kKeepAspectCmd setState:NSOffState];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-07-03 14:28:51 +00:00
|
|
|
[self reshape];
|
2005-05-25 23:38:59 +00:00
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-05-25 23:38:59 +00:00
|
|
|
if(sender == kPanScanCmd)
|
|
|
|
{
|
2010-07-25 11:14:07 +00:00
|
|
|
vo_panscan = !vo_panscan;
|
2005-05-25 23:38:59 +00:00
|
|
|
if(vo_panscan)
|
|
|
|
[kPanScanCmd setState:NSOnState];
|
|
|
|
else
|
|
|
|
[kPanScanCmd setState:NSOffState];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-07-03 12:24:48 +00:00
|
|
|
[self panscan];
|
2005-05-25 23:38:59 +00:00
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-05-25 23:38:59 +00:00
|
|
|
if(sender == kAspectOrgCmd)
|
2009-09-01 09:36:04 +00:00
|
|
|
change_movie_aspect(-1);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-05-25 23:38:59 +00:00
|
|
|
if(sender == kAspectFullCmd)
|
2009-09-01 09:36:04 +00:00
|
|
|
change_movie_aspect(4.0f/3.0f);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-05-25 23:38:59 +00:00
|
|
|
if(sender == kAspectWideCmd)
|
2009-09-01 09:36:04 +00:00
|
|
|
change_movie_aspect(16.0f/9.0f);
|
2005-05-25 23:38:59 +00:00
|
|
|
}
|
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
/*
|
|
|
|
Setup OpenGL
|
|
|
|
*/
|
|
|
|
- (void)prepareOpenGL
|
|
|
|
{
|
2009-07-06 23:26:13 +00:00
|
|
|
glEnable(GL_BLEND);
|
2005-04-29 11:05:16 +00:00
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
glDepthMask(GL_FALSE);
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
[self reshape];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
reshape OpenGL viewport
|
2009-07-06 23:26:13 +00:00
|
|
|
*/
|
2005-04-29 11:05:16 +00:00
|
|
|
- (void)reshape
|
|
|
|
{
|
2010-07-25 11:19:41 +00:00
|
|
|
int d_width, d_height;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
NSRect frame = [self frame];
|
2009-09-01 09:36:04 +00:00
|
|
|
vo_dwidth = frame.size.width;
|
|
|
|
vo_dheight = frame.size.height;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
glViewport(0, 0, frame.size.width, frame.size.height);
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity();
|
|
|
|
glOrtho(0, frame.size.width, frame.size.height, 0, -1.0, 1.0);
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity();
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-06-15 21:49:50 +00:00
|
|
|
//set texture frame
|
2005-04-29 11:05:16 +00:00
|
|
|
if(vo_keepaspect)
|
|
|
|
{
|
2010-07-25 11:19:41 +00:00
|
|
|
aspect(&d_width, &d_height, A_WINZOOM);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2009-09-01 09:36:04 +00:00
|
|
|
textureFrame = NSMakeRect((vo_dwidth - d_width) / 2, (vo_dheight - d_height) / 2, d_width, d_height);
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-06-15 21:49:50 +00:00
|
|
|
textureFrame = frame;
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Render frame
|
2009-07-06 23:26:13 +00:00
|
|
|
*/
|
2005-04-29 11:05:16 +00:00
|
|
|
- (void) render
|
|
|
|
{
|
2009-07-06 23:26:13 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
glEnable(CVOpenGLTextureGetTarget(texture));
|
|
|
|
glBindTexture(CVOpenGLTextureGetTarget(texture), CVOpenGLTextureGetName(texture));
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
glColor3f(1,1,1);
|
|
|
|
glBegin(GL_QUADS);
|
2005-06-15 21:49:50 +00:00
|
|
|
glTexCoord2f(upperLeft[0], upperLeft[1]); glVertex2i( textureFrame.origin.x-(vo_panscan_x >> 1), textureFrame.origin.y-(vo_panscan_y >> 1));
|
2007-12-18 16:37:36 +00:00
|
|
|
glTexCoord2f(lowerLeft[0], lowerLeft[1]); glVertex2i(textureFrame.origin.x-(vo_panscan_x >> 1), NSMaxY(textureFrame)+(vo_panscan_y >> 1));
|
|
|
|
glTexCoord2f(lowerRight[0], lowerRight[1]); glVertex2i(NSMaxX(textureFrame)+(vo_panscan_x >> 1), NSMaxY(textureFrame)+(vo_panscan_y >> 1));
|
|
|
|
glTexCoord2f(upperRight[0], upperRight[1]); glVertex2i(NSMaxX(textureFrame)+(vo_panscan_x >> 1), textureFrame.origin.y-(vo_panscan_y >> 1));
|
2005-04-29 11:05:16 +00:00
|
|
|
glEnd();
|
2005-05-04 12:00:54 +00:00
|
|
|
glDisable(CVOpenGLTextureGetTarget(texture));
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-05-04 12:00:54 +00:00
|
|
|
//render resize box
|
|
|
|
if(!isFullscreen)
|
|
|
|
{
|
|
|
|
NSRect frame = [self frame];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-05-04 12:00:54 +00:00
|
|
|
glBegin(GL_LINES);
|
|
|
|
glColor4f(0.2, 0.2, 0.2, 0.5);
|
|
|
|
glVertex2i(frame.size.width-1, frame.size.height-1); glVertex2i(frame.size.width-1, frame.size.height-1);
|
|
|
|
glVertex2i(frame.size.width-1, frame.size.height-5); glVertex2i(frame.size.width-5, frame.size.height-1);
|
|
|
|
glVertex2i(frame.size.width-1, frame.size.height-9); glVertex2i(frame.size.width-9, frame.size.height-1);
|
|
|
|
|
|
|
|
glColor4f(0.4, 0.4, 0.4, 0.5);
|
|
|
|
glVertex2i(frame.size.width-1, frame.size.height-2); glVertex2i(frame.size.width-2, frame.size.height-1);
|
|
|
|
glVertex2i(frame.size.width-1, frame.size.height-6); glVertex2i(frame.size.width-6, frame.size.height-1);
|
|
|
|
glVertex2i(frame.size.width-1, frame.size.height-10); glVertex2i(frame.size.width-10, frame.size.height-1);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-05-04 12:00:54 +00:00
|
|
|
glColor4f(0.6, 0.6, 0.6, 0.5);
|
|
|
|
glVertex2i(frame.size.width-1, frame.size.height-3); glVertex2i(frame.size.width-3, frame.size.height-1);
|
|
|
|
glVertex2i(frame.size.width-1, frame.size.height-7); glVertex2i(frame.size.width-7, frame.size.height-1);
|
|
|
|
glVertex2i(frame.size.width-1, frame.size.height-11); glVertex2i(frame.size.width-11, frame.size.height-1);
|
|
|
|
glEnd();
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
glFlush();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-07-06 23:26:13 +00:00
|
|
|
Create OpenGL texture from current frame & set texco
|
|
|
|
*/
|
2005-04-29 11:05:16 +00:00
|
|
|
- (void) setCurrentTexture
|
|
|
|
{
|
|
|
|
CVReturn error = kCVReturnSuccess;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2009-04-13 20:07:03 +00:00
|
|
|
CVOpenGLTextureRelease(texture);
|
2007-11-30 04:20:38 +00:00
|
|
|
error = CVOpenGLTextureCacheCreateTextureFromImage(NULL, textureCache, frameBuffers[image_page], 0, &texture);
|
2005-04-29 11:05:16 +00:00
|
|
|
if(error != kCVReturnSuccess)
|
2009-05-04 16:55:05 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture(%d)\n", error);
|
2005-04-29 11:05:16 +00:00
|
|
|
|
|
|
|
CVOpenGLTextureGetCleanTexCoords(texture, lowerLeft, lowerRight, upperRight, upperLeft);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
redraw win rect
|
2009-07-06 23:26:13 +00:00
|
|
|
*/
|
2005-04-29 11:05:16 +00:00
|
|
|
- (void) drawRect: (NSRect *) bounds
|
|
|
|
{
|
|
|
|
[self render];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Toggle Fullscreen
|
|
|
|
*/
|
|
|
|
- (void) fullscreen: (BOOL) animate
|
|
|
|
{
|
|
|
|
static NSRect old_frame;
|
|
|
|
static NSRect old_view_frame;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-05-26 16:33:28 +00:00
|
|
|
panscan_calc();
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
//go fullscreen
|
|
|
|
if(vo_fs)
|
|
|
|
{
|
2005-05-02 18:05:59 +00:00
|
|
|
if(!isRootwin)
|
|
|
|
{
|
2005-07-01 17:24:31 +00:00
|
|
|
SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar);
|
2006-04-08 16:16:48 +00:00
|
|
|
CGDisplayHideCursor(kCGDirectMainDisplay);
|
2005-05-02 18:05:59 +00:00
|
|
|
mouseHide = YES;
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
old_frame = [window frame]; //save main window size & position
|
2009-09-01 09:36:04 +00:00
|
|
|
update_screen_info();
|
2007-12-17 15:45:37 +00:00
|
|
|
|
2005-06-15 16:54:43 +00:00
|
|
|
[window setFrame:screen_frame display:YES animate:animate]; //zoom-in window with nice useless sfx
|
2005-04-29 11:05:16 +00:00
|
|
|
old_view_frame = [self bounds];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
//fix origin for multi screen setup
|
2005-06-15 16:54:43 +00:00
|
|
|
screen_frame.origin.x = 0;
|
|
|
|
screen_frame.origin.y = 0;
|
|
|
|
[self setFrame:screen_frame];
|
2005-04-29 11:05:16 +00:00
|
|
|
[self setNeedsDisplay:YES];
|
|
|
|
[window setHasShadow:NO];
|
|
|
|
isFullscreen = 1;
|
|
|
|
}
|
|
|
|
else
|
2009-07-06 23:26:13 +00:00
|
|
|
{
|
2005-07-03 12:24:48 +00:00
|
|
|
SetSystemUIMode( kUIModeNormal, 0);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
isFullscreen = 0;
|
2006-04-08 16:16:48 +00:00
|
|
|
CGDisplayShowCursor(kCGDirectMainDisplay);
|
2005-04-29 11:05:16 +00:00
|
|
|
mouseHide = NO;
|
|
|
|
|
|
|
|
//revert window to previous setting
|
|
|
|
[self setFrame:old_view_frame];
|
|
|
|
[self setNeedsDisplay:YES];
|
2005-07-24 15:16:27 +00:00
|
|
|
[window setHasShadow:YES];
|
2005-04-29 11:05:16 +00:00
|
|
|
[window setFrame:old_frame display:YES animate:animate];//zoom-out window with nice useless sfx
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Toggle ontop
|
|
|
|
*/
|
|
|
|
- (void) ontop
|
|
|
|
{
|
2005-05-02 01:48:37 +00:00
|
|
|
if(vo_ontop)
|
|
|
|
{
|
|
|
|
[window setLevel:NSScreenSaverWindowLevel];
|
|
|
|
isOntop = YES;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[window setLevel:NSNormalWindowLevel];
|
|
|
|
isOntop = NO;
|
|
|
|
}
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Toggle panscan
|
|
|
|
*/
|
|
|
|
- (void) panscan
|
|
|
|
{
|
2005-05-02 21:17:27 +00:00
|
|
|
panscan_calc();
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
|
|
|
|
2005-05-02 18:05:59 +00:00
|
|
|
/*
|
|
|
|
Toggle rootwin
|
|
|
|
*/
|
|
|
|
- (void) rootwin
|
|
|
|
{
|
|
|
|
if(vo_rootwin)
|
|
|
|
{
|
|
|
|
[window setLevel:CGWindowLevelForKey(kCGDesktopWindowLevelKey)];
|
|
|
|
[window orderBack:self];
|
|
|
|
isRootwin = YES;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[window setLevel:NSNormalWindowLevel];
|
|
|
|
isRootwin = NO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
/*
|
|
|
|
Check event for new event
|
2009-07-06 23:26:13 +00:00
|
|
|
*/
|
2005-04-29 11:05:16 +00:00
|
|
|
- (void) check_events
|
|
|
|
{
|
2010-07-25 17:43:22 +00:00
|
|
|
NSEvent *event;
|
2010-07-25 17:40:44 +00:00
|
|
|
int curTime = TickCount()/60;
|
|
|
|
|
|
|
|
//automatically hide mouse cursor (and future on-screen control?)
|
|
|
|
if(isFullscreen && !mouseHide && !isRootwin)
|
|
|
|
{
|
|
|
|
if(curTime - lastMouseHide >= 5 || lastMouseHide == 0)
|
|
|
|
{
|
|
|
|
CGDisplayHideCursor(kCGDirectMainDisplay);
|
|
|
|
mouseHide = TRUE;
|
|
|
|
lastMouseHide = curTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//update activity every 30 seconds to prevent
|
|
|
|
//screensaver from starting up.
|
|
|
|
if(curTime - lastScreensaverUpdate >= 30 || lastScreensaverUpdate == 0)
|
|
|
|
{
|
|
|
|
UpdateSystemActivity(UsrActivity);
|
|
|
|
lastScreensaverUpdate = curTime;
|
|
|
|
}
|
|
|
|
|
2010-07-25 17:00:04 +00:00
|
|
|
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES];
|
2007-11-29 23:32:08 +00:00
|
|
|
if (event == nil)
|
|
|
|
return;
|
2005-04-29 11:05:16 +00:00
|
|
|
[NSApp sendEvent:event];
|
2007-11-30 00:03:01 +00:00
|
|
|
// Without SDL's bootstrap code (include SDL.h in mplayer.c),
|
2009-03-07 17:41:34 +00:00
|
|
|
// on Leopard, we have trouble to get the play window automatically focused
|
|
|
|
// when the app is actived. The Following code fix this problem.
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifndef CONFIG_SDL
|
2007-11-30 00:03:01 +00:00
|
|
|
if (isLeopardOrLater && [event type] == NSAppKitDefined
|
|
|
|
&& [event subtype] == NSApplicationActivatedEventType) {
|
|
|
|
[window makeMainWindow];
|
|
|
|
[window makeKeyAndOrderFront:mpGLView];
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
|
|
|
|
2005-06-16 00:26:47 +00:00
|
|
|
/*
|
|
|
|
From NSView, respond to key equivalents.
|
|
|
|
*/
|
|
|
|
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
|
|
|
|
{
|
|
|
|
switch([theEvent keyCode])
|
2010-07-25 11:49:36 +00:00
|
|
|
{
|
2005-06-16 00:26:47 +00:00
|
|
|
case 0x21: [window setAlphaValue: winAlpha-=0.05]; return YES;
|
|
|
|
case 0x1e: [window setAlphaValue: winAlpha+=0.05]; return YES;
|
2010-07-25 11:49:36 +00:00
|
|
|
}
|
2005-06-16 00:26:47 +00:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
/*
|
|
|
|
Process key event
|
|
|
|
*/
|
|
|
|
- (void) keyDown: (NSEvent *) theEvent
|
|
|
|
{
|
2011-11-26 15:21:42 +00:00
|
|
|
unsigned char charcode;
|
|
|
|
if (([theEvent modifierFlags] & NSRightAlternateKeyMask) == NSRightAlternateKeyMask)
|
|
|
|
charcode = *[[theEvent characters] UTF8String];
|
|
|
|
else
|
|
|
|
charcode = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
|
|
|
|
|
|
|
|
int key = convert_key([theEvent keyCode], charcode);
|
|
|
|
|
|
|
|
if (key > -1) {
|
2011-03-03 11:27:30 +00:00
|
|
|
if([theEvent modifierFlags] & NSShiftKeyMask)
|
|
|
|
key |= KEY_MODIFIER_SHIFT;
|
|
|
|
if([theEvent modifierFlags] & NSControlKeyMask)
|
|
|
|
key |= KEY_MODIFIER_CTRL;
|
2011-03-13 15:54:18 +00:00
|
|
|
if(([theEvent modifierFlags] & NSLeftAlternateKeyMask) == NSLeftAlternateKeyMask)
|
2011-03-03 11:27:30 +00:00
|
|
|
key |= KEY_MODIFIER_ALT;
|
|
|
|
if([theEvent modifierFlags] & NSCommandKeyMask)
|
|
|
|
key |= KEY_MODIFIER_META;
|
|
|
|
mplayer_put_key(key);
|
|
|
|
}
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Process mouse button event
|
|
|
|
*/
|
|
|
|
- (void) mouseMoved: (NSEvent *) theEvent
|
|
|
|
{
|
2005-05-02 18:05:59 +00:00
|
|
|
if(isFullscreen && !isRootwin)
|
2005-04-29 11:05:16 +00:00
|
|
|
{
|
2006-04-08 16:16:48 +00:00
|
|
|
CGDisplayShowCursor(kCGDirectMainDisplay);
|
2005-04-29 11:05:16 +00:00
|
|
|
mouseHide = NO;
|
|
|
|
}
|
2007-12-22 14:55:26 +00:00
|
|
|
if (enable_mouse_movements && !isRootwin) {
|
2007-12-20 12:00:44 +00:00
|
|
|
NSPoint p =[self convertPoint:[theEvent locationInWindow] fromView:nil];
|
|
|
|
if ([self mouse:p inRect:textureFrame]) {
|
2010-04-26 16:22:56 +00:00
|
|
|
vo_mouse_movement(global_vo, vo_fs ? p.x : p.x - textureFrame.origin.x,
|
2010-04-25 16:13:57 +00:00
|
|
|
vo_fs ? [self frame].size.height - p.y : NSMaxY(textureFrame) - p.y);
|
2007-12-20 12:00:44 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) mouseDown: (NSEvent *) theEvent
|
|
|
|
{
|
|
|
|
[self mouseEvent: theEvent];
|
|
|
|
}
|
|
|
|
|
2007-08-18 22:46:29 +00:00
|
|
|
- (void) mouseUp: (NSEvent *) theEvent
|
|
|
|
{
|
|
|
|
[self mouseEvent: theEvent];
|
|
|
|
}
|
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
- (void) rightMouseDown: (NSEvent *) theEvent
|
|
|
|
{
|
|
|
|
[self mouseEvent: theEvent];
|
|
|
|
}
|
|
|
|
|
2007-08-18 22:46:29 +00:00
|
|
|
- (void) rightMouseUp: (NSEvent *) theEvent
|
|
|
|
{
|
|
|
|
[self mouseEvent: theEvent];
|
|
|
|
}
|
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
- (void) otherMouseDown: (NSEvent *) theEvent
|
|
|
|
{
|
|
|
|
[self mouseEvent: theEvent];
|
|
|
|
}
|
|
|
|
|
2007-08-18 22:46:29 +00:00
|
|
|
- (void) otherMouseUp: (NSEvent *) theEvent
|
|
|
|
{
|
|
|
|
[self mouseEvent: theEvent];
|
|
|
|
}
|
|
|
|
|
2005-04-29 11:05:16 +00:00
|
|
|
- (void) scrollWheel: (NSEvent *) theEvent
|
|
|
|
{
|
|
|
|
if([theEvent deltaY] > 0)
|
|
|
|
mplayer_put_key(MOUSE_BTN3);
|
|
|
|
else
|
|
|
|
mplayer_put_key(MOUSE_BTN4);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) mouseEvent: (NSEvent *) theEvent
|
|
|
|
{
|
2007-08-18 22:46:29 +00:00
|
|
|
if ( [theEvent buttonNumber] >= 0 && [theEvent buttonNumber] <= 9 )
|
|
|
|
{
|
2007-12-18 14:48:30 +00:00
|
|
|
int buttonNumber = [theEvent buttonNumber];
|
|
|
|
// Fix to mplayer defined button order: left, middle, right
|
|
|
|
if (buttonNumber == 1)
|
|
|
|
buttonNumber = 2;
|
2007-12-18 14:58:14 +00:00
|
|
|
else if (buttonNumber == 2)
|
|
|
|
buttonNumber = 1;
|
2007-08-18 22:46:29 +00:00
|
|
|
switch([theEvent type])
|
|
|
|
{
|
|
|
|
case NSLeftMouseDown:
|
|
|
|
case NSRightMouseDown:
|
|
|
|
case NSOtherMouseDown:
|
2007-12-18 14:48:30 +00:00
|
|
|
mplayer_put_key((MOUSE_BTN0 + buttonNumber) | MP_KEY_DOWN);
|
2007-08-18 22:46:29 +00:00
|
|
|
break;
|
|
|
|
case NSLeftMouseUp:
|
|
|
|
case NSRightMouseUp:
|
|
|
|
case NSOtherMouseUp:
|
2007-12-18 14:48:30 +00:00
|
|
|
mplayer_put_key(MOUSE_BTN0 + buttonNumber);
|
2007-08-18 22:46:29 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-04-29 11:05:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
NSResponder
|
2009-07-06 23:26:13 +00:00
|
|
|
*/
|
2005-04-29 11:05:16 +00:00
|
|
|
- (BOOL) acceptsFirstResponder
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) becomeFirstResponder
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) resignFirstResponder
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
2005-05-02 14:40:16 +00:00
|
|
|
|
2010-07-25 14:40:58 +00:00
|
|
|
- (BOOL)windowShouldClose:(id)sender
|
2005-05-02 14:40:16 +00:00
|
|
|
{
|
2010-07-25 11:07:15 +00:00
|
|
|
mplayer_put_key(KEY_CLOSE_WIN);
|
2010-07-25 14:40:58 +00:00
|
|
|
// We have to wait for MPlayer to handle this,
|
|
|
|
// otherwise we are in trouble if the
|
|
|
|
// KEY_CLOSE_WIN handler is disabled
|
|
|
|
return NO;
|
2005-05-02 14:40:16 +00:00
|
|
|
}
|
2010-07-25 17:06:41 +00:00
|
|
|
|
|
|
|
- (void)handleQuitEvent:(NSAppleEventDescriptor*)e withReplyEvent:(NSAppleEventDescriptor*)r
|
|
|
|
{
|
|
|
|
mplayer_put_key(KEY_CLOSE_WIN);
|
|
|
|
}
|
2005-05-02 14:40:16 +00:00
|
|
|
@end
|