changeset 15728:caa1d0aeffd5

device_id flag force fullscreen device
author nplourde
date Wed, 15 Jun 2005 16:54:43 +0000
parents dfe70cdbb699
children 55aaeb7b6aae
files libvo/vo_macosx.m
diffstat 1 files changed, 50 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_macosx.m	Wed Jun 15 14:55:08 2005 +0000
+++ b/libvo/vo_macosx.m	Wed Jun 15 16:54:43 2005 +0000
@@ -27,11 +27,12 @@
 NSAutoreleasePool *autoreleasepool;
 OSType pixelFormat;
 
-//Device
-static int device_width;
-static int device_height;
-static int device_id;
-static GDHandle device_handle;
+//Screen
+int screen_id;
+BOOL screen_force;
+NSRect screen_frame;
+NSScreen *screen_handle;
+NSArray *screen_array;
 
 //image
 unsigned char *image_data;
@@ -86,27 +87,22 @@
 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;
-	
-	//Get Main device info///////////////////////////////////////////////////
-	device_handle = GetMainDevice();
-	
-	for(i=0; i<device_id; i++)
+
+	//init screen
+	screen_array = [NSScreen screens];
+	if(screen_id < [screen_array count])
 	{
-		device_handle = GetNextDevice(device_handle);
-		
-		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;
-		}
+		screen_handle = [screen_array objectAtIndex:screen_id];
 	}
+	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];
-	device_width = device_rect.size.width;
-	device_height = device_rect.size.height;
-	monitor_aspect = (float)device_width/(float)device_height;
+	monitor_aspect = (float)screen_frame.size.width/(float)screen_frame.size.height;
 	
 	//misc mplayer setup
 	image_width = width;
@@ -128,7 +124,7 @@
 	panscan_init();
 	aspect_save_orig(width,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);
 	
 	movie_aspect = (float)d_width/(float)d_height;
@@ -208,21 +204,6 @@
 {
 	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)
 	//this chunk of code is heavily based off SDL_macosx.m from SDL 
 	//it uses an Apple private function to request foreground operation
@@ -243,6 +224,22 @@
 	}
 	#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();
 	autoreleasepool = [[NSAutoreleasePool alloc] init];
 	
@@ -303,6 +300,7 @@
 	NSRect frame;
 	CVReturn error = kCVReturnSuccess;
 	
+	//config window
 	aspect((int *)&d_width, (int *)&d_height,A_NOZOOM);
 	frame = NSMakeRect(0, 0, d_width, d_height);
 	[window setContentSize: frame.size];
@@ -328,6 +326,10 @@
 	if(error != kCVReturnSuccess)
 		mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture(%d)\n", error);
 	
+	//show window
+	[window center];
+	[window makeKeyAndOrderFront:mpGLView];
+	
 	if(vo_rootwin)
 		[mpGLView rootwin];	
 
@@ -336,10 +338,6 @@
 	
 	if(vo_ontop)
 		[mpGLView ontop];
-		
-	//show window
-	[window center];
-	[window makeKeyAndOrderFront:mpGLView];
 }
 
 /*
@@ -659,7 +657,11 @@
 {
 	static NSRect old_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();
 			
@@ -675,13 +677,13 @@
 		}
 		
 		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];
 		
 		//fix origin for multi screen setup
-		device_rect.origin.x = 0;
-		device_rect.origin.y = 0;
-		[self setFrame:device_rect];
+		screen_frame.origin.x = 0;
+		screen_frame.origin.y = 0;
+		[self setFrame:screen_frame];
 		[self setNeedsDisplay:YES];
 		[window setHasShadow:NO];
 		isFullscreen = 1;