Changeset 68375 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp
- Timestamp:
- Aug 10, 2017 4:13:36 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp
r68367 r68375 445 445 } 446 446 447 static void ResizeDisplayDeviceNT4(DWORD dwNewXRes, DWORD dwNewYRes, DWORD dwNewBpp) 448 { 449 DEVMODE devMode; 450 451 RT_ZERO(devMode); 452 devMode.dmSize = sizeof(DEVMODE); 453 454 /* get the current screen setup */ 455 if (!EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &devMode)) 456 { 457 LogFlowFunc(("error from EnumDisplaySettings: %d\n", GetLastError())); 458 return; 459 } 460 461 LogFlowFunc(("Current mode: %d x %d x %d at %d,%d\n", 462 devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel, devMode.dmPosition.x, devMode.dmPosition.y)); 463 464 /* Check whether a mode reset or a change is requested. */ 465 if (dwNewXRes || dwNewYRes || dwNewBpp) 466 { 467 /* A change is requested. 468 * Set values which are not to be changed to the current values. 469 */ 470 if (!dwNewXRes) 471 dwNewXRes = devMode.dmPelsWidth; 472 if (!dwNewYRes) 473 dwNewYRes = devMode.dmPelsHeight; 474 if (!dwNewBpp) 475 dwNewBpp = devMode.dmBitsPerPel; 476 } 477 else 478 { 479 /* All zero values means a forced mode reset. Do nothing. */ 480 LogFlowFunc(("Forced mode reset\n")); 481 } 482 483 /* Verify that the mode is indeed changed. */ 484 if (devMode.dmPelsWidth == dwNewXRes 485 && devMode.dmPelsHeight == dwNewYRes 486 && devMode.dmBitsPerPel == dwNewBpp) 487 { 488 LogFlowFunc(("already at desired resolution\n")); 489 return; 490 } 491 492 // without this, Windows will not ask the miniport for its 493 // mode table but uses an internal cache instead 494 DEVMODE tempDevMode = { 0 }; 495 tempDevMode.dmSize = sizeof(DEVMODE); 496 EnumDisplaySettings(NULL, 0xffffff, &tempDevMode); 497 498 /* adjust the values that are supposed to change */ 499 if (dwNewXRes) 500 devMode.dmPelsWidth = dwNewXRes; 501 if (dwNewYRes) 502 devMode.dmPelsHeight = dwNewYRes; 503 if (dwNewBpp) 504 devMode.dmBitsPerPel = dwNewBpp; 505 506 LogFlowFunc(("setting new mode %d x %d, %d BPP\n", 507 devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel)); 508 509 /* set the new mode */ 510 LONG status = ChangeDisplaySettings(&devMode, CDS_UPDATEREGISTRY); 511 if (status != DISP_CHANGE_SUCCESSFUL) 512 { 513 LogFlowFunc(("error from ChangeDisplaySettings: %d\n", status)); 514 515 if (status == DISP_CHANGE_BADMODE) 516 { 517 /* Our driver can not set the requested mode. Stop trying. */ 518 return; 519 } 520 } 521 } 522 447 523 /* Returns TRUE to try again. */ 448 524 /** @todo r=andy Why not using the VMMDevDisplayChangeRequestEx structure for all those parameters here? */ … … 746 822 int rc = VINF_SUCCESS; 747 823 748 for (;;)824 while (*pfShutdown == false) 749 825 { 750 826 BOOL fExtDispSup = TRUE; … … 830 906 { 831 907 /* Try to set the requested video mode. Repeat until it is successful or is rejected by the driver. */ 908 LogFlowFunc(("DisplayChangeReqEx parameters aDisplay=%d x xRes=%d x yRes=%d x bpp=%d x SecondayMonEnb=%d x NewOriginX=%d x NewOriginY=%d x ChangeOrigin=%d\n", 909 displayChangeRequest.display, 910 displayChangeRequest.xres, 911 displayChangeRequest.yres, 912 displayChangeRequest.bpp, 913 displayChangeRequest.fEnabled, 914 displayChangeRequest.cxOrigin, 915 displayChangeRequest.cyOrigin, 916 displayChangeRequest.fChangeOrigin)); 917 832 918 for (;;) 833 919 { 834 LogFlowFunc(("VMMDevReq_GetDisplayChangeRequest2: %dx%dx%d at %d\n", displayChangeRequest.xres, displayChangeRequest.yres, displayChangeRequest.bpp, displayChangeRequest.display));835 836 /* Only try to change video mode if the active display driver is VBox additions. */837 838 920 VBOXDISPLAY_DRIVER_TYPE enmDriverType = getVBoxDisplayDriverType (pCtx); 839 921 … … 847 929 { 848 930 LogFlowFunc(("Detected W2K or later\n")); 849 /* W2K or later. */850 LogFlowFunc(("DisplayChangeReqEx parameters aDisplay=%d x xRes=%d x yRes=%d x bpp=%d x SecondayMonEnb=%d x NewOriginX=%d x NewOriginY=%d x ChangeOrigin=%d\n",851 displayChangeRequest.display,852 displayChangeRequest.xres,853 displayChangeRequest.yres,854 displayChangeRequest.bpp,855 displayChangeRequest.fEnabled,856 displayChangeRequest.cxOrigin,857 displayChangeRequest.cyOrigin,858 displayChangeRequest.fChangeOrigin));859 931 if (!ResizeDisplayDevice(pCtx, 860 932 displayChangeRequest.display, … … 877 949 { 878 950 LogFlowFunc(("Detected NT\n")); 879 880 /* Single monitor NT. */ 881 DEVMODE devMode; 882 RT_ZERO(devMode); 883 devMode.dmSize = sizeof(DEVMODE); 884 885 /* get the current screen setup */ 886 if (EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &devMode)) 887 { 888 LogFlowFunc(("Current mode: %d x %d x %d at %d,%d\n", 889 devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel, devMode.dmPosition.x, devMode.dmPosition.y)); 890 891 /* Check whether a mode reset or a change is requested. */ 892 if (displayChangeRequest.xres || displayChangeRequest.yres || displayChangeRequest.bpp) 893 { 894 /* A change is requested. 895 * Set values which are not to be changed to the current values. 896 */ 897 if (!displayChangeRequest.xres) 898 displayChangeRequest.xres = devMode.dmPelsWidth; 899 if (!displayChangeRequest.yres) 900 displayChangeRequest.yres = devMode.dmPelsHeight; 901 if (!displayChangeRequest.bpp) 902 displayChangeRequest.bpp = devMode.dmBitsPerPel; 903 } 904 else 905 { 906 /* All zero values means a forced mode reset. Do nothing. */ 907 LogFlowFunc(("Forced mode reset\n")); 908 } 909 910 /* Verify that the mode is indeed changed. */ 911 if ( devMode.dmPelsWidth == displayChangeRequest.xres 912 && devMode.dmPelsHeight == displayChangeRequest.yres 913 && devMode.dmBitsPerPel == displayChangeRequest.bpp) 914 { 915 LogFlowFunc(("already at desired resolution\n")); 916 break; 917 } 918 919 // without this, Windows will not ask the miniport for its 920 // mode table but uses an internal cache instead 921 DEVMODE tempDevMode = {0}; 922 tempDevMode.dmSize = sizeof(DEVMODE); 923 EnumDisplaySettings(NULL, 0xffffff, &tempDevMode); 924 925 /* adjust the values that are supposed to change */ 926 if (displayChangeRequest.xres) 927 devMode.dmPelsWidth = displayChangeRequest.xres; 928 if (displayChangeRequest.yres) 929 devMode.dmPelsHeight = displayChangeRequest.yres; 930 if (displayChangeRequest.bpp) 931 devMode.dmBitsPerPel = displayChangeRequest.bpp; 932 933 LogFlowFunc(("setting new mode %d x %d, %d BPP\n", 934 devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel)); 935 936 /* set the new mode */ 937 LONG status = ChangeDisplaySettings(&devMode, CDS_UPDATEREGISTRY); 938 if (status != DISP_CHANGE_SUCCESSFUL) 939 { 940 LogFlowFunc(("error from ChangeDisplaySettings: %d\n", status)); 941 942 if (status == DISP_CHANGE_BADMODE) 943 { 944 /* Our driver can not set the requested mode. Stop trying. */ 945 break; 946 } 947 } 948 else 949 { 950 /* Successfully set new video mode. */ 951 break; 952 } 953 } 954 else 955 { 956 LogFlowFunc(("error from EnumDisplaySettings: %d\n", GetLastError ())); 957 break; 958 } 951 ResizeDisplayDeviceNT4( 952 displayChangeRequest.xres, 953 displayChangeRequest.yres, 954 displayChangeRequest.bpp); 955 break; 959 956 } 960 957 … … 963 960 } 964 961 } 965 else 966 { 967 /* sleep a bit to not eat too much CPU while retrying */ 968 RTThreadSleep(50); 969 } 970 } 971 972 /* are we supposed to stop? */ 973 if (*pfShutdown) 974 break; 962 } // if (fDisplayChangeQueried) 975 963 976 964 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED) … … 994 982 /* sleep a bit to not eat too much CPU in case the above call always fails */ 995 983 RTThreadSleep(10); 996 997 if (*pfShutdown)998 break;999 984 } 1000 985 }
Note:
See TracChangeset
for help on using the changeset viewer.