mirror of
https://github.com/mpv-player/mpv
synced 2024-12-11 09:25:56 +00:00
device_id flag force fullscreen device
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15729 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
e2fab0fbc0
commit
1865cc057a
@ -27,11 +27,12 @@ MPlayerOpenGLView *mpGLView;
|
|||||||
NSAutoreleasePool *autoreleasepool;
|
NSAutoreleasePool *autoreleasepool;
|
||||||
OSType pixelFormat;
|
OSType pixelFormat;
|
||||||
|
|
||||||
//Device
|
//Screen
|
||||||
static int device_width;
|
int screen_id;
|
||||||
static int device_height;
|
BOOL screen_force;
|
||||||
static int device_id;
|
NSRect screen_frame;
|
||||||
static GDHandle device_handle;
|
NSScreen *screen_handle;
|
||||||
|
NSArray *screen_array;
|
||||||
|
|
||||||
//image
|
//image
|
||||||
unsigned char *image_data;
|
unsigned char *image_data;
|
||||||
@ -86,27 +87,22 @@ static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigne
|
|||||||
static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
|
static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
//Get Main device info///////////////////////////////////////////////////
|
//init screen
|
||||||
device_handle = GetMainDevice();
|
screen_array = [NSScreen screens];
|
||||||
|
if(screen_id < [screen_array count])
|
||||||
for(i=0; i<device_id; i++)
|
|
||||||
{
|
{
|
||||||
device_handle = GetNextDevice(device_handle);
|
screen_handle = [screen_array objectAtIndex:screen_id];
|
||||||
|
|
||||||
if(device_handle == NULL)
|
|
||||||
{
|
|
||||||
mp_msg(MSGT_VO, MSGL_FATAL, "Get device error: Device ID %d do not exist, falling back to main device.\n", device_id);
|
|
||||||
device_handle = GetMainDevice();
|
|
||||||
device_id = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mp_msg(MSGT_VO, MSGL_FATAL, "Get device error: Device ID %d do not exist, falling back to main device.\n", screen_id);
|
||||||
|
screen_handle = [screen_array objectAtIndex:0];
|
||||||
|
screen_id = 0;
|
||||||
|
}
|
||||||
|
screen_frame = [screen_handle frame];
|
||||||
|
|
||||||
NSRect device_rect = [[NSScreen mainScreen] frame];
|
monitor_aspect = (float)screen_frame.size.width/(float)screen_frame.size.height;
|
||||||
device_width = device_rect.size.width;
|
|
||||||
device_height = device_rect.size.height;
|
|
||||||
monitor_aspect = (float)device_width/(float)device_height;
|
|
||||||
|
|
||||||
//misc mplayer setup
|
//misc mplayer setup
|
||||||
image_width = width;
|
image_width = width;
|
||||||
@ -128,7 +124,7 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32
|
|||||||
panscan_init();
|
panscan_init();
|
||||||
aspect_save_orig(width,height);
|
aspect_save_orig(width,height);
|
||||||
aspect_save_prescale(d_width,d_height);
|
aspect_save_prescale(d_width,d_height);
|
||||||
aspect_save_screenres(device_width,device_height);
|
aspect_save_screenres(screen_frame.size.width, screen_frame.size.height);
|
||||||
aspect((int *)&d_width,(int *)&d_height,A_NOZOOM);
|
aspect((int *)&d_width,(int *)&d_height,A_NOZOOM);
|
||||||
|
|
||||||
movie_aspect = (float)d_width/(float)d_height;
|
movie_aspect = (float)d_width/(float)d_height;
|
||||||
@ -208,21 +204,6 @@ static uint32_t preinit(const char *arg)
|
|||||||
{
|
{
|
||||||
int parse_err = 0;
|
int parse_err = 0;
|
||||||
|
|
||||||
if(arg)
|
|
||||||
{
|
|
||||||
char *parse_pos = (char *)&arg[0];
|
|
||||||
while (parse_pos[0] && !parse_err)
|
|
||||||
{
|
|
||||||
if (strncmp (parse_pos, "device_id=", 10) == 0)
|
|
||||||
{
|
|
||||||
parse_pos = &parse_pos[10];
|
|
||||||
device_id = strtol(parse_pos, &parse_pos, 0);
|
|
||||||
}
|
|
||||||
if (parse_pos[0] == ':') parse_pos = &parse_pos[1];
|
|
||||||
else if (parse_pos[0]) parse_err = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined (MACOSX_FINDER_SUPPORT) || !defined (HAVE_SDL)
|
#if !defined (MACOSX_FINDER_SUPPORT) || !defined (HAVE_SDL)
|
||||||
//this chunk of code is heavily based off SDL_macosx.m from SDL
|
//this chunk of code is heavily based off SDL_macosx.m from SDL
|
||||||
//it uses an Apple private function to request foreground operation
|
//it uses an Apple private function to request foreground operation
|
||||||
@ -243,6 +224,22 @@ static uint32_t preinit(const char *arg)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(arg)
|
||||||
|
{
|
||||||
|
char *parse_pos = (char *)&arg[0];
|
||||||
|
while (parse_pos[0] && !parse_err)
|
||||||
|
{
|
||||||
|
if (strncmp (parse_pos, "device_id=", 10) == 0)
|
||||||
|
{
|
||||||
|
parse_pos = &parse_pos[10];
|
||||||
|
screen_id = strtol(parse_pos, &parse_pos, 0);
|
||||||
|
screen_force = YES;
|
||||||
|
}
|
||||||
|
if (parse_pos[0] == ':') parse_pos = &parse_pos[1];
|
||||||
|
else if (parse_pos[0]) parse_err = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NSApplicationLoad();
|
NSApplicationLoad();
|
||||||
autoreleasepool = [[NSAutoreleasePool alloc] init];
|
autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
@ -303,6 +300,7 @@ static uint32_t control(uint32_t request, void *data, ...)
|
|||||||
NSRect frame;
|
NSRect frame;
|
||||||
CVReturn error = kCVReturnSuccess;
|
CVReturn error = kCVReturnSuccess;
|
||||||
|
|
||||||
|
//config window
|
||||||
aspect((int *)&d_width, (int *)&d_height,A_NOZOOM);
|
aspect((int *)&d_width, (int *)&d_height,A_NOZOOM);
|
||||||
frame = NSMakeRect(0, 0, d_width, d_height);
|
frame = NSMakeRect(0, 0, d_width, d_height);
|
||||||
[window setContentSize: frame.size];
|
[window setContentSize: frame.size];
|
||||||
@ -328,6 +326,10 @@ static uint32_t control(uint32_t request, void *data, ...)
|
|||||||
if(error != kCVReturnSuccess)
|
if(error != kCVReturnSuccess)
|
||||||
mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture(%d)\n", error);
|
mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture(%d)\n", error);
|
||||||
|
|
||||||
|
//show window
|
||||||
|
[window center];
|
||||||
|
[window makeKeyAndOrderFront:mpGLView];
|
||||||
|
|
||||||
if(vo_rootwin)
|
if(vo_rootwin)
|
||||||
[mpGLView rootwin];
|
[mpGLView rootwin];
|
||||||
|
|
||||||
@ -336,10 +338,6 @@ static uint32_t control(uint32_t request, void *data, ...)
|
|||||||
|
|
||||||
if(vo_ontop)
|
if(vo_ontop)
|
||||||
[mpGLView ontop];
|
[mpGLView ontop];
|
||||||
|
|
||||||
//show window
|
|
||||||
[window center];
|
|
||||||
[window makeKeyAndOrderFront:mpGLView];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -659,7 +657,11 @@ static uint32_t control(uint32_t request, void *data, ...)
|
|||||||
{
|
{
|
||||||
static NSRect old_frame;
|
static NSRect old_frame;
|
||||||
static NSRect old_view_frame;
|
static NSRect old_view_frame;
|
||||||
NSRect device_rect = [[window screen] frame];
|
|
||||||
|
if(screen_force)
|
||||||
|
screen_frame = [screen_handle frame];
|
||||||
|
else
|
||||||
|
screen_frame = [[window screen] frame];
|
||||||
|
|
||||||
panscan_calc();
|
panscan_calc();
|
||||||
|
|
||||||
@ -675,13 +677,13 @@ static uint32_t control(uint32_t request, void *data, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
old_frame = [window frame]; //save main window size & position
|
old_frame = [window frame]; //save main window size & position
|
||||||
[window setFrame:device_rect display:YES animate:animate]; //zoom-in window with nice useless sfx
|
[window setFrame:screen_frame display:YES animate:animate]; //zoom-in window with nice useless sfx
|
||||||
old_view_frame = [self bounds];
|
old_view_frame = [self bounds];
|
||||||
|
|
||||||
//fix origin for multi screen setup
|
//fix origin for multi screen setup
|
||||||
device_rect.origin.x = 0;
|
screen_frame.origin.x = 0;
|
||||||
device_rect.origin.y = 0;
|
screen_frame.origin.y = 0;
|
||||||
[self setFrame:device_rect];
|
[self setFrame:screen_frame];
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay:YES];
|
||||||
[window setHasShadow:NO];
|
[window setHasShadow:NO];
|
||||||
isFullscreen = 1;
|
isFullscreen = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user