Mercurial > mplayer.hg
comparison libvo/vo_quartz.c @ 27986:9e17ab676ab9
Replace QuickDraw calls in vo_quartz.c to fix warnings when compiling with current SDK versions.
Patch by Gregor Riepl %onitake A gmail P com%
Original thread:
Date: Wed, Oct 29, 2008 at 7:26 PM
Subject: Re: [MPlayer-dev-eng] [PATCH] Replaced deprecated QuickDraw calls in vo_quartz
author | gpoirier |
---|---|
date | Mon, 24 Nov 2008 10:01:03 +0000 |
parents | d47744b95b78 |
children | 672f98720463 |
comparison
equal
deleted
inserted
replaced
27985:1c77b86d355d | 27986:9e17ab676ab9 |
---|---|
84 | 84 |
85 static int int_pause = 0; | 85 static int int_pause = 0; |
86 static float winAlpha = 1; | 86 static float winAlpha = 1; |
87 static int mouseHide = FALSE; | 87 static int mouseHide = FALSE; |
88 | 88 |
89 static int device_width; | 89 static int device_id = 0; |
90 static int device_height; | |
91 static int device_id; | |
92 | 90 |
93 static short fs_res_x=0; | 91 static short fs_res_x=0; |
94 static short fs_res_y=0; | 92 static short fs_res_y=0; |
95 | 93 |
96 static WindowRef theWindow = NULL; | 94 static WindowRef theWindow = NULL; |
97 static WindowGroupRef winGroup = NULL; | 95 static WindowGroupRef winGroup = NULL; |
98 static CGContextRef context; | |
99 static CGRect bounds; | 96 static CGRect bounds; |
100 static GDHandle deviceHdl; | 97 static CGDirectDisplayID displayId = 0; |
101 | 98 static CFDictionaryRef originalMode = NULL; |
102 static CGDataProviderRef dataProviderRef; | 99 |
103 static CGImageRef image; | 100 static CGDataProviderRef dataProviderRef = NULL; |
101 static CGImageRef image = NULL; | |
104 | 102 |
105 static Rect imgRect; // size of the original image (unscaled) | 103 static Rect imgRect; // size of the original image (unscaled) |
106 static Rect dstRect; // size of the displayed image (after scaling) | 104 static Rect dstRect; // size of the displayed image (after scaling) |
107 static Rect winRect; // size of the window containg the displayed image (include padding) | 105 static Rect winRect; // size of the window containg the displayed image (include padding) |
108 static Rect oldWinRect; // size of the window containg the displayed image (include padding) when NOT in FS mode | 106 static Rect oldWinRect; // size of the window containg the displayed image (include padding) when NOT in FS mode |
109 static Rect deviceRect; // size of the display device | 107 static CGRect displayRect; // size of the display device |
110 static Rect oldWinBounds; | 108 static Rect oldWinBounds; |
111 | 109 |
112 static MenuRef windMenu; | 110 static MenuRef windMenu; |
113 static MenuRef movMenu; | 111 static MenuRef movMenu; |
114 static MenuRef aspectMenu; | 112 static MenuRef aspectMenu; |
113 | |
114 static int lastScreensaverUpdate = 0; | |
115 static int lastMouseHide = 0; | |
115 | 116 |
116 enum | 117 enum |
117 { | 118 { |
118 kQuitCmd = 1, | 119 kQuitCmd = 1, |
119 kHalfScreenCmd = 2, | 120 kHalfScreenCmd = 2, |
280 { | 281 { |
281 case kEventMouseMoved: | 282 case kEventMouseMoved: |
282 { | 283 { |
283 if(vo_quartz_fs) | 284 if(vo_quartz_fs) |
284 { | 285 { |
285 CGDisplayShowCursor(kCGDirectMainDisplay); | 286 CGDisplayShowCursor(displayId); |
286 mouseHide = FALSE; | 287 mouseHide = FALSE; |
287 } | 288 } |
288 } | 289 } |
289 break; | 290 break; |
290 | 291 |
340 } | 341 } |
341 if( (winMousePos.h > (bounds.right - 15)) && (winMousePos.v > (bounds.bottom)) ) | 342 if( (winMousePos.h > (bounds.right - 15)) && (winMousePos.v > (bounds.bottom)) ) |
342 { | 343 { |
343 if(!vo_quartz_fs) | 344 if(!vo_quartz_fs) |
344 { | 345 { |
345 GrowWindow(theWindow, mousePos, NULL); | 346 Rect newSize; |
347 ResizeWindow(theWindow, mousePos, NULL, &newSize); | |
346 } | 348 } |
347 } | 349 } |
348 else if(part == inMenuBar) | 350 else if(part == inMenuBar) |
349 { | 351 { |
350 MenuSelect(mousePos); | 352 MenuSelect(mousePos); |
484 } | 486 } |
485 } | 487 } |
486 else if(class == kEventClassWindow) | 488 else if(class == kEventClassWindow) |
487 { | 489 { |
488 WindowRef window; | 490 WindowRef window; |
489 Rect rectPort = {0,0,0,0}; | 491 Rect rectWindow = {0,0,0,0}; |
490 | 492 |
491 GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window); | 493 GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window); |
492 | 494 |
493 if(window) | 495 if(window) |
494 { | 496 { |
495 GetPortBounds(GetWindowPort(window), &rectPort); | 497 GetWindowBounds(window, kWindowGlobalPortRgn, &rectWindow); |
496 } | 498 } |
497 | 499 |
498 switch (kind) | 500 switch (kind) |
499 { | 501 { |
500 case kEventWindowClosed: | 502 case kEventWindowClosed: |
620 | 622 |
621 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) | 623 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) |
622 { | 624 { |
623 WindowAttributes windowAttrs; | 625 WindowAttributes windowAttrs; |
624 OSErr qterr; | 626 OSErr qterr; |
625 int i; | |
626 CGRect tmpBounds; | 627 CGRect tmpBounds; |
628 CGDisplayCount displayCount; | |
629 CGDirectDisplayID *displays; | |
627 | 630 |
628 //Get Main device info/////////////////////////////////////////////////// | 631 //Get Main device info/////////////////////////////////////////////////// |
629 | 632 |
630 | 633 //Display IDs might not be consecutive, get the list of all devices up to # device_id |
631 deviceHdl = GetMainDevice(); | 634 displayCount = device_id + 1; |
632 | 635 displays = malloc(sizeof(CGDirectDisplayID) * displayCount); |
633 for(i=0; i<device_id; i++) | 636 if (kCGErrorSuccess != CGGetActiveDisplayList(displayCount, displays, &displayCount) || displayCount < device_id + 1) { |
634 { | |
635 deviceHdl = GetNextDevice(deviceHdl); | |
636 | |
637 if(deviceHdl == NULL) | |
638 { | |
639 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: Device ID %d do not exist, falling back to main device.\n", device_id); | 637 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: Device ID %d do not exist, falling back to main device.\n", device_id); |
640 deviceHdl = GetMainDevice(); | 638 displayId = kCGDirectMainDisplay; |
641 device_id = 0; | 639 device_id = 0; |
642 break; | 640 } |
643 } | 641 else |
644 } | 642 { |
645 | 643 displayId = displays[device_id]; |
646 deviceRect = (*deviceHdl)->gdRect; | 644 } |
647 device_width = deviceRect.right-deviceRect.left; | 645 free(displays); |
648 device_height = deviceRect.bottom-deviceRect.top; | 646 |
649 | 647 displayRect = CGDisplayBounds(displayId); |
650 monitor_aspect = (float)device_width/(float)device_height; | 648 |
649 monitor_aspect = (float)displayRect.size.width/(float)displayRect.size.height; | |
651 | 650 |
652 //misc mplayer setup///////////////////////////////////////////////////// | 651 //misc mplayer setup///////////////////////////////////////////////////// |
653 SetRect(&imgRect, 0, 0, width, height); | 652 SetRect(&imgRect, 0, 0, width, height); |
654 switch (image_format) | 653 switch (image_format) |
655 { | 654 { |
670 | 669 |
671 //get movie aspect | 670 //get movie aspect |
672 panscan_init(); | 671 panscan_init(); |
673 aspect_save_orig(width,height); | 672 aspect_save_orig(width,height); |
674 aspect_save_prescale(d_width,d_height); | 673 aspect_save_prescale(d_width,d_height); |
675 aspect_save_screenres(device_width, device_height); | 674 aspect_save_screenres(displayRect.size.width, displayRect.size.height); |
676 | 675 |
677 aspect(&d_width,&d_height,A_NOZOOM); | 676 aspect(&d_width,&d_height,A_NOZOOM); |
678 | 677 |
679 movie_aspect = (float)d_width/(float)d_height; | 678 movie_aspect = (float)d_width/(float)d_height; |
680 old_movie_aspect = movie_aspect; | 679 old_movie_aspect = movie_aspect; |
691 | 690 |
692 windowAttrs &= (~kWindowResizableAttribute); | 691 windowAttrs &= (~kWindowResizableAttribute); |
693 | 692 |
694 if (theWindow == NULL) | 693 if (theWindow == NULL) |
695 { | 694 { |
695 CGContextRef context; | |
696 | |
696 quartz_CreateWindow(d_width, d_height, windowAttrs); | 697 quartz_CreateWindow(d_width, d_height, windowAttrs); |
697 | 698 |
698 if (theWindow == NULL) | 699 if (theWindow == NULL) |
699 { | 700 { |
700 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: Couldn't create window !!!!!\n"); | 701 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: Couldn't create window !!!!!\n"); |
701 return -1; | 702 return -1; |
702 } | 703 } |
703 tmpBounds = CGRectMake( 0, 0, winRect.right, winRect.bottom); | 704 tmpBounds = CGRectMake( 0, 0, winRect.right, winRect.bottom); |
704 CreateCGContextForPort(GetWindowPort(theWindow),&context); | 705 QDBeginCGContext(GetWindowPort(theWindow),&context); |
705 CGContextFillRect(context, tmpBounds); | 706 CGContextFillRect(context, tmpBounds); |
707 QDEndCGContext(GetWindowPort(theWindow),&context); | |
706 } | 708 } |
707 else | 709 else |
708 { | 710 { |
709 HideWindow(theWindow); | 711 HideWindow(theWindow); |
710 ChangeWindowAttributes(theWindow, ~windowAttrs, windowAttrs); | 712 ChangeWindowAttributes(theWindow, ~windowAttrs, windowAttrs); |
715 | 717 |
716 switch (image_format) | 718 switch (image_format) |
717 { | 719 { |
718 case IMGFMT_RGB32: | 720 case IMGFMT_RGB32: |
719 { | 721 { |
720 CreateCGContextForPort (GetWindowPort (theWindow), &context); | 722 CGContextRef context; |
723 | |
724 QDBeginCGContext(GetWindowPort(theWindow),&context); | |
721 | 725 |
722 dataProviderRef = CGDataProviderCreateWithData (0, image_data, imgRect.right * imgRect.bottom * 4, 0); | 726 dataProviderRef = CGDataProviderCreateWithData (0, image_data, imgRect.right * imgRect.bottom * 4, 0); |
723 | 727 |
724 image = CGImageCreate (imgRect.right, | 728 image = CGImageCreate (imgRect.right, |
725 imgRect.bottom, | 729 imgRect.bottom, |
727 image_depth, | 731 image_depth, |
728 ((imgRect.right*32)+7)/8, | 732 ((imgRect.right*32)+7)/8, |
729 CGColorSpaceCreateDeviceRGB(), | 733 CGColorSpaceCreateDeviceRGB(), |
730 kCGImageAlphaNoneSkipFirst, | 734 kCGImageAlphaNoneSkipFirst, |
731 dataProviderRef, 0, 1, kCGRenderingIntentDefault); | 735 dataProviderRef, 0, 1, kCGRenderingIntentDefault); |
736 | |
737 QDEndCGContext(GetWindowPort(theWindow),&context); | |
732 break; | 738 break; |
733 } | 739 } |
734 | 740 |
735 case IMGFMT_YV12: | 741 case IMGFMT_YV12: |
736 case IMGFMT_IYUV: | 742 case IMGFMT_IYUV: |
919 } | 925 } |
920 | 926 |
921 static void flip_page(void) | 927 static void flip_page(void) |
922 { | 928 { |
923 int curTime; | 929 int curTime; |
924 static int lastTime = 0; | |
925 | 930 |
926 if(theWindow == NULL) | 931 if(theWindow == NULL) |
927 return; | 932 return; |
928 | 933 |
929 switch (image_format) | 934 switch (image_format) |
930 { | 935 { |
931 case IMGFMT_RGB32: | 936 case IMGFMT_RGB32: |
932 { | 937 { |
938 CGContextRef context; | |
939 QDBeginCGContext(GetWindowPort(theWindow),&context); | |
933 CGContextDrawImage (context, bounds, image); | 940 CGContextDrawImage (context, bounds, image); |
941 QDEndCGContext(GetWindowPort(theWindow),&context); | |
934 } | 942 } |
935 break; | 943 break; |
936 | 944 |
937 case IMGFMT_YV12: | 945 case IMGFMT_YV12: |
938 case IMGFMT_IYUV: | 946 case IMGFMT_IYUV: |
958 break; | 966 break; |
959 } | 967 } |
960 | 968 |
961 if(!vo_quartz_fs) | 969 if(!vo_quartz_fs) |
962 { | 970 { |
971 CGContextRef context; | |
972 | |
973 QDBeginCGContext(GetWindowPort(theWindow),&context); | |
963 //render resize box | 974 //render resize box |
964 CGContextBeginPath(context); | 975 CGContextBeginPath(context); |
965 CGContextSetAllowsAntialiasing(context, false); | 976 CGContextSetAllowsAntialiasing(context, false); |
966 //CGContextSaveGState(context); | 977 //CGContextSaveGState(context); |
967 | 978 |
986 CGContextMoveToPoint( context, winRect.right-1, 11); CGContextAddLineToPoint( context, winRect.right-11, 1); | 997 CGContextMoveToPoint( context, winRect.right-1, 11); CGContextAddLineToPoint( context, winRect.right-11, 1); |
987 CGContextStrokePath( context ); | 998 CGContextStrokePath( context ); |
988 | 999 |
989 //CGContextRestoreGState( context ); | 1000 //CGContextRestoreGState( context ); |
990 CGContextFlush (context); | 1001 CGContextFlush (context); |
991 } | 1002 QDEndCGContext(GetWindowPort(theWindow),&context); |
992 | 1003 } |
993 //auto hide mouse cursor and futur on-screen control? | 1004 |
1005 curTime = TickCount()/60; | |
1006 | |
1007 //auto hide mouse cursor (and future on-screen control?) | |
994 if(vo_quartz_fs && !mouseHide) | 1008 if(vo_quartz_fs && !mouseHide) |
995 { | 1009 { |
996 int curTime = TickCount()/60; | 1010 if( ((curTime - lastMouseHide) >= 5) || (lastMouseHide == 0) ) |
997 static int lastTime = 0; | 1011 { |
998 | 1012 CGDisplayHideCursor(displayId); |
999 if( ((curTime - lastTime) >= 5) || (lastTime == 0) ) | |
1000 { | |
1001 CGDisplayHideCursor(kCGDirectMainDisplay); | |
1002 mouseHide = TRUE; | 1013 mouseHide = TRUE; |
1003 lastTime = curTime; | 1014 lastMouseHide = curTime; |
1004 } | 1015 } |
1005 } | 1016 } |
1006 | 1017 |
1007 //update activity every 30 seconds to prevent | 1018 //update activity every 30 seconds to prevent |
1008 //screensaver from starting up. | 1019 //screensaver from starting up. |
1009 curTime = TickCount()/60; | 1020 if( ((curTime - lastScreensaverUpdate) >= 30) || (lastScreensaverUpdate == 0) ) |
1010 | |
1011 if( ((curTime - lastTime) >= 30) || (lastTime == 0) ) | |
1012 { | 1021 { |
1013 UpdateSystemActivity(UsrActivity); | 1022 UpdateSystemActivity(UsrActivity); |
1014 lastTime = curTime; | 1023 lastScreensaverUpdate = curTime; |
1015 } | 1024 } |
1016 } | 1025 } |
1017 | 1026 |
1018 static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) | 1027 static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) |
1019 { | 1028 { |
1141 } | 1150 } |
1142 } | 1151 } |
1143 | 1152 |
1144 #if !defined (CONFIG_MACOSX_FINDER) || !defined (CONFIG_SDL) | 1153 #if !defined (CONFIG_MACOSX_FINDER) || !defined (CONFIG_SDL) |
1145 //this chunk of code is heavily based off SDL_macosx.m from SDL | 1154 //this chunk of code is heavily based off SDL_macosx.m from SDL |
1146 //it uses an Apple private function to request foreground operation | 1155 //the CPSEnableForegroundOperation that was here before is private and shouldn't be used |
1147 { | 1156 //replaced by a call to the 10.3+ TransformProcessType |
1148 void CPSEnableForegroundOperation(ProcessSerialNumber* psn); | 1157 { |
1149 ProcessSerialNumber myProc, frProc; | 1158 ProcessSerialNumber myProc, frProc; |
1150 Boolean sameProc; | 1159 Boolean sameProc; |
1151 | 1160 |
1152 if (GetFrontProcess(&frProc) == noErr) | 1161 if (GetFrontProcess(&frProc) == noErr) |
1153 { | 1162 { |
1154 if (GetCurrentProcess(&myProc) == noErr) | 1163 if (GetCurrentProcess(&myProc) == noErr) |
1155 { | 1164 { |
1156 if (SameProcess(&frProc, &myProc, &sameProc) == noErr && !sameProc) | 1165 if (SameProcess(&frProc, &myProc, &sameProc) == noErr && !sameProc) |
1157 { | 1166 { |
1158 CPSEnableForegroundOperation(&myProc); | 1167 TransformProcessType(&myProc, kProcessTransformToForegroundApplication); |
1159 } | 1168 } |
1160 SetFrontProcess(&myProc); | 1169 SetFrontProcess(&myProc); |
1161 } | 1170 } |
1162 } | 1171 } |
1163 } | 1172 } |
1284 uint32_t d_width; | 1293 uint32_t d_width; |
1285 uint32_t d_height; | 1294 uint32_t d_height; |
1286 | 1295 |
1287 CGRect tmpBounds; | 1296 CGRect tmpBounds; |
1288 | 1297 |
1289 GetPortBounds( GetWindowPort(theWindow), &winRect ); | 1298 CGContextRef context; |
1299 | |
1300 GetWindowPortBounds(theWindow, &winRect ); | |
1290 | 1301 |
1291 if(vo_keepaspect) | 1302 if(vo_keepaspect) |
1292 { | 1303 { |
1293 aspect( &d_width, &d_height, A_NOZOOM); | 1304 aspect( &d_width, &d_height, A_NOZOOM); |
1294 d_height = ((float)d_width/movie_aspect); | 1305 d_height = ((float)d_width/movie_aspect); |
1315 switch (image_format) | 1326 switch (image_format) |
1316 { | 1327 { |
1317 case IMGFMT_RGB32: | 1328 case IMGFMT_RGB32: |
1318 { | 1329 { |
1319 bounds = CGRectMake(dstRect.left, dstRect.top, dstRect.right-dstRect.left, dstRect.bottom-dstRect.top); | 1330 bounds = CGRectMake(dstRect.left, dstRect.top, dstRect.right-dstRect.left, dstRect.bottom-dstRect.top); |
1320 CreateCGContextForPort (GetWindowPort (theWindow), &context); | |
1321 break; | 1331 break; |
1322 } | 1332 } |
1323 case IMGFMT_YV12: | 1333 case IMGFMT_YV12: |
1324 case IMGFMT_IYUV: | 1334 case IMGFMT_IYUV: |
1325 case IMGFMT_I420: | 1335 case IMGFMT_I420: |
1347 break; | 1357 break; |
1348 } | 1358 } |
1349 | 1359 |
1350 //Clear Background | 1360 //Clear Background |
1351 tmpBounds = CGRectMake( 0, 0, winRect.right, winRect.bottom); | 1361 tmpBounds = CGRectMake( 0, 0, winRect.right, winRect.bottom); |
1352 CreateCGContextForPort(GetWindowPort(theWindow),&context); | 1362 QDBeginCGContext(GetWindowPort(theWindow),&context); |
1353 CGContextFillRect(context, tmpBounds); | 1363 CGContextFillRect(context, tmpBounds); |
1364 QDEndCGContext(GetWindowPort(theWindow),&context); | |
1354 } | 1365 } |
1355 | 1366 |
1356 void window_ontop() | 1367 void window_ontop() |
1357 { | 1368 { |
1358 if(!vo_quartz_fs) | 1369 if(!vo_quartz_fs) |
1365 SetWindowGroupLevel(winGroup, CGWindowLevelForKey(levelList[winLevel])); | 1376 SetWindowGroupLevel(winGroup, CGWindowLevelForKey(levelList[winLevel])); |
1366 } | 1377 } |
1367 | 1378 |
1368 void window_fullscreen() | 1379 void window_fullscreen() |
1369 { | 1380 { |
1370 static Ptr restoreState = NULL; | |
1371 | |
1372 //go fullscreen | 1381 //go fullscreen |
1373 if(vo_fs) | 1382 if(vo_fs) |
1374 { | 1383 { |
1375 if(winLevel != 0) | 1384 if(winLevel != 0) |
1376 { | 1385 { |
1377 if(device_id == 0) | 1386 if(displayId == kCGDirectMainDisplay) |
1378 { | 1387 { |
1379 SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar); | 1388 SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar); |
1380 CGDisplayHideCursor(kCGDirectMainDisplay); | 1389 CGDisplayHideCursor(displayId); |
1381 mouseHide = TRUE; | 1390 mouseHide = TRUE; |
1382 } | 1391 } |
1383 | 1392 |
1384 if(fs_res_x != 0 || fs_res_y != 0) | 1393 if(fs_res_x != 0 || fs_res_y != 0) |
1385 { | 1394 { |
1386 BeginFullScreen( &restoreState, deviceHdl, &fs_res_x, &fs_res_y, NULL, NULL, 0); | 1395 CFDictionaryRef mode; |
1396 size_t desiredBitDepth = 32; | |
1397 boolean_t exactMatch; | |
1387 | 1398 |
1399 originalMode = CGDisplayCurrentMode(displayId); | |
1400 | |
1401 mode = CGDisplayBestModeForParameters(displayId, desiredBitDepth, fs_res_x, fs_res_y, &exactMatch); | |
1402 | |
1403 if (mode != NULL) | |
1404 { | |
1405 if (!exactMatch) | |
1406 { | |
1407 //Warn if the mode doesn't match exactly | |
1408 mp_msg(MSGT_VO, MSGL_WARN, "Quartz warning: did not get exact mode match (got %dx%d) \n", (int) CFDictionaryGetValue(mode, kCGDisplayWidth), (int) CFDictionaryGetValue(mode, kCGDisplayHeight)); | |
1409 } | |
1410 | |
1411 CGDisplayCapture(displayId); | |
1412 CGDisplaySwitchToMode(displayId, mode); | |
1413 } | |
1414 else | |
1415 { | |
1416 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: can't switch to fullscreen \n"); | |
1417 } | |
1418 | |
1388 //Get Main device info/////////////////////////////////////////////////// | 1419 //Get Main device info/////////////////////////////////////////////////// |
1389 deviceRect = (*deviceHdl)->gdRect; | 1420 displayRect = CGDisplayBounds(displayId); |
1390 | |
1391 device_width = deviceRect.right; | |
1392 device_height = deviceRect.bottom; | |
1393 } | 1421 } |
1394 } | 1422 } |
1395 | 1423 |
1396 //save old window size | 1424 //save old window size |
1397 if (!vo_quartz_fs) | 1425 if (!vo_quartz_fs) |
1401 } | 1429 } |
1402 | 1430 |
1403 //go fullscreen | 1431 //go fullscreen |
1404 panscan_calc(); | 1432 panscan_calc(); |
1405 ChangeWindowAttributes(theWindow, kWindowNoShadowAttribute, 0); | 1433 ChangeWindowAttributes(theWindow, kWindowNoShadowAttribute, 0); |
1406 MoveWindow(theWindow, deviceRect.left-(vo_panscan_x >> 1), deviceRect.top-(vo_panscan_y >> 1), 1); | 1434 MoveWindow(theWindow, displayRect.origin.x-(vo_panscan_x >> 1), displayRect.origin.y-(vo_panscan_y >> 1), 1); |
1407 SizeWindow(theWindow, device_width+vo_panscan_x, device_height+vo_panscan_y,1); | 1435 SizeWindow(theWindow, displayRect.size.width+vo_panscan_x, displayRect.size.height+vo_panscan_y,1); |
1408 | 1436 |
1409 vo_quartz_fs = 1; | 1437 vo_quartz_fs = 1; |
1410 } | 1438 } |
1411 else //go back to windowed mode | 1439 else //go back to windowed mode |
1412 { | 1440 { |
1413 vo_quartz_fs = 0; | 1441 vo_quartz_fs = 0; |
1414 if(restoreState != NULL) | 1442 if(originalMode != NULL) |
1415 { | 1443 { |
1416 EndFullScreen(restoreState, 0); | 1444 CGDisplaySwitchToMode(displayId, originalMode); |
1445 CGDisplayRelease(displayId); | |
1417 | 1446 |
1418 //Get Main device info/////////////////////////////////////////////////// | 1447 //Get Main device info/////////////////////////////////////////////////// |
1419 deviceRect = (*deviceHdl)->gdRect; | 1448 displayRect = CGDisplayBounds(displayId); |
1420 | 1449 |
1421 device_width = deviceRect.right; | 1450 originalMode = NULL; |
1422 device_height = deviceRect.bottom; | |
1423 restoreState = NULL; | |
1424 } | 1451 } |
1425 SetSystemUIMode( kUIModeNormal, 0); | 1452 SetSystemUIMode( kUIModeNormal, 0); |
1426 | 1453 |
1427 //show mouse cursor | 1454 //show mouse cursor |
1428 CGDisplayShowCursor(kCGDirectMainDisplay); | 1455 CGDisplayShowCursor(displayId); |
1429 mouseHide = FALSE; | 1456 mouseHide = FALSE; |
1430 | 1457 |
1431 //revert window to previous setting | 1458 //revert window to previous setting |
1432 ChangeWindowAttributes(theWindow, 0, kWindowNoShadowAttribute); | 1459 ChangeWindowAttributes(theWindow, 0, kWindowNoShadowAttribute); |
1433 SizeWindow(theWindow, oldWinRect.right, oldWinRect.bottom,1); | 1460 SizeWindow(theWindow, oldWinRect.right, oldWinRect.bottom,1); |
1445 else | 1472 else |
1446 CheckMenuItem (aspectMenu, 2, 0); | 1473 CheckMenuItem (aspectMenu, 2, 0); |
1447 | 1474 |
1448 if(vo_quartz_fs) | 1475 if(vo_quartz_fs) |
1449 { | 1476 { |
1450 MoveWindow(theWindow, deviceRect.left-(vo_panscan_x >> 1), deviceRect.top-(vo_panscan_y >> 1), 1); | 1477 MoveWindow(theWindow, displayRect.origin.x-(vo_panscan_x >> 1), displayRect.origin.y-(vo_panscan_y >> 1), 1); |
1451 SizeWindow(theWindow, device_width+vo_panscan_x, device_height+vo_panscan_y,1); | 1478 SizeWindow(theWindow, displayRect.size.width+vo_panscan_x, displayRect.size.height+vo_panscan_y,1); |
1452 } | 1479 } |
1453 } | 1480 } |