Changeset 68367 in vbox for trunk/src/VBox
- Timestamp:
- Aug 10, 2017 12:53:22 PM (7 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxTray
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp
r64878 r68367 591 591 * because we do not have XPDM display driver any more, i.e. escape requests are handled by cdd 592 592 * that knows nothing about us */ 593 DWORD VBoxDispIfInit(PVBOXDISPIF pIf) 594 { 595 pIf->enmMode = VBOXDISPIF_MODE_XPDM; 593 DWORD VBoxDispIfInit(PVBOXDISPIF pDispIf) 594 { 595 VBoxDispIfSwitchMode(pDispIf, VBOXDISPIF_MODE_XPDM, NULL); 596 596 597 return NO_ERROR; 597 598 } -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp
r63100 r68367 52 52 static VBOXDISPLAYCONTEXT g_Ctx = { 0 }; 53 53 54 #ifdef VBOX_WITH_WDDM55 54 typedef enum 56 55 { … … 61 60 62 61 static VBOXDISPLAY_DRIVER_TYPE getVBoxDisplayDriverType (VBOXDISPLAYCONTEXT *pCtx); 63 #endif64 62 65 63 static DECLCALLBACK(int) VBoxDisplayInit(const PVBOXSERVICEENV pEnv, void **ppInstance) … … 104 102 LogFlowFunc(("WDDM driver is installed, switching display driver if to WDDM mode\n")); 105 103 /* This is hacky, but the most easiest way. */ 106 VBOXDISPIF_MODE enmMode = (OSinfo.dwMajorVersion > 6 || OSinfo.dwMinorVersion > 0) ? VBOXDISPIF_MODE_WDDM_W7 : VBOXDISPIF_MODE_WDDM;104 VBOXDISPIF_MODE enmMode = (OSinfo.dwMajorVersion == 6 && OSinfo.dwMinorVersion == 0) ? VBOXDISPIF_MODE_WDDM : VBOXDISPIF_MODE_WDDM_W7; 107 105 DWORD dwErr = VBoxDispIfSwitchMode(const_cast<PVBOXDISPIF>(&pEnv->dispIf), enmMode, NULL /* old mode, we don't care about it */); 108 106 if (dwErr == NO_ERROR) … … 159 157 } 160 158 161 #ifdef VBOX_WITH_WDDM162 159 static VBOXDISPLAY_DRIVER_TYPE getVBoxDisplayDriverType(PVBOXDISPLAYCONTEXT pCtx) 163 #else164 static bool isVBoxDisplayDriverActive(PVBOXDISPLAYCONTEXT pCtx)165 #endif166 160 { 167 #ifdef VBOX_WITH_WDDM168 161 VBOXDISPLAY_DRIVER_TYPE enmType = VBOXDISPLAY_DRIVER_TYPE_UNKNOWN; 169 #else 170 bool result = false; 171 #endif 172 173 if( pCtx->pfnEnumDisplayDevices ) 162 163 if (pCtx->pfnEnumDisplayDevices) 174 164 { 175 165 INT devNum = 0; … … 178 168 dispDevice.cb = sizeof(DISPLAY_DEVICE); 179 169 180 LogFlowFunc((" isVBoxDisplayDriverActive: Checking for active VBox display driver (W2K+) ...\n"));170 LogFlowFunc(("getVBoxDisplayDriverType: Checking for active VBox display driver (W2K+) ...\n")); 181 171 182 172 while (EnumDisplayDevices(NULL, … … 185 175 0)) 186 176 { 187 LogFlowFunc((" isVBoxDisplayDriverActive: DevNum:%d\nName:%s\nString:%s\nID:%s\nKey:%s\nFlags=%08X\n\n",177 LogFlowFunc(("getVBoxDisplayDriverType: DevNum:%d\nName:%s\nString:%s\nID:%s\nKey:%s\nFlags=%08X\n\n", 188 178 devNum, 189 179 &dispDevice.DeviceName[0], … … 195 185 if (dispDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) 196 186 { 197 LogFlowFunc(("isVBoxDisplayDriverActive: Primary device\n")); 198 187 LogFlowFunc(("getVBoxDisplayDriverType: Primary device\n")); 188 189 /* WDDM driver can now have multiple incarnations, 190 * if the driver name contains VirtualBox, and does NOT match the XPDM name, 191 * assume it to be WDDM */ 199 192 if (strcmp(&dispDevice.DeviceString[0], "VirtualBox Graphics Adapter") == 0) 200 #ifndef VBOX_WITH_WDDM201 result = true;202 #else203 193 enmType = VBOXDISPLAY_DRIVER_TYPE_XPDM; 204 /* WDDM driver can now have multiple incarnations,205 * if the driver name contains VirtualBox, and does NOT match the XPDM name,206 * assume it to be WDDM */207 194 else if (strstr(&dispDevice.DeviceString[0], "VirtualBox")) 208 195 enmType = VBOXDISPLAY_DRIVER_TYPE_WDDM; 209 #endif 196 210 197 break; 211 198 } … … 220 207 else /* This must be NT 4 or something really old, so don't use EnumDisplayDevices() here ... */ 221 208 { 222 LogFlowFunc((" isVBoxDisplayDriverActive: Checking for active VBox display driver (NT or older) ...\n"));209 LogFlowFunc(("getVBoxDisplayDriverType: Checking for active VBox display driver (NT or older) ...\n")); 223 210 224 211 DEVMODE tempDevMode; … … 229 216 /* Check for the short name, because all long stuff would be truncated */ 230 217 if (strcmp((char*)&tempDevMode.dmDeviceName[0], "VBoxDisp") == 0) 231 #ifndef VBOX_WITH_WDDM232 result = true;233 #else234 218 enmType = VBOXDISPLAY_DRIVER_TYPE_XPDM; 235 #endif 236 } 237 238 #ifndef VBOX_WITH_WDDM 239 return result; 240 #else 219 } 220 241 221 return enmType; 242 #endif243 222 } 244 223 … … 792 771 break; 793 772 794 /*LogFlowFunc(("checking event\n"));*/795 796 773 /* did we get the right event? */ 797 774 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST) … … 857 834 LogFlowFunc(("VMMDevReq_GetDisplayChangeRequest2: %dx%dx%d at %d\n", displayChangeRequest.xres, displayChangeRequest.yres, displayChangeRequest.bpp, displayChangeRequest.display)); 858 835 859 /* 860 * Only try to change video mode if the active display driver is VBox additions. 861 */ 862 #ifdef VBOX_WITH_WDDM 836 /* Only try to change video mode if the active display driver is VBox additions. */ 837 863 838 VBOXDISPLAY_DRIVER_TYPE enmDriverType = getVBoxDisplayDriverType (pCtx); 864 839 865 if (enmDriverType == VBOXDISPLAY_DRIVER_TYPE_WDDM) 866 LogFlowFunc(("Detected WDDM Driver\n")); 867 868 if (enmDriverType != VBOXDISPLAY_DRIVER_TYPE_UNKNOWN) 869 #else 870 if (isVBoxDisplayDriverActive (pCtx)) 871 #endif 840 if (enmDriverType == VBOXDISPLAY_DRIVER_TYPE_UNKNOWN) 872 841 { 873 LogFlowFunc(("Display driver is active!\n")); 874 875 if (pCtx->pfnChangeDisplaySettingsEx != 0) 842 LogFlowFunc(("vboxDisplayDriver is not active\n")); 843 break; 844 } 845 846 if (pCtx->pfnChangeDisplaySettingsEx != 0) 847 { 848 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 if (!ResizeDisplayDevice(pCtx, 860 displayChangeRequest.display, 861 displayChangeRequest.xres, 862 displayChangeRequest.yres, 863 displayChangeRequest.bpp, 864 displayChangeRequest.fEnabled, 865 displayChangeRequest.cxOrigin, 866 displayChangeRequest.cyOrigin, 867 displayChangeRequest.fChangeOrigin, 868 fExtDispSup 869 )) 876 870 { 877 LogFlowFunc((" Detected W2K or later\n"));878 /* W2K or later. */879 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",880 displayChangeRequest.display, 881 displayChangeRequest.xres,882 displayChangeRequest.yres,883 displayChangeRequest.bpp,884 displayChangeRequest.fEnabled,885 displayChangeRequest.cxOrigin, 886 displayChangeRequest.cyOrigin,887 displayChangeRequest.fChangeOrigin));888 if (!ResizeDisplayDevice(pCtx,889 displayChangeRequest.display,890 displayChangeRequest.xres, 891 displayChangeRequest.yres,892 displayChangeRequest.bpp,893 displayChangeRequest.fEnabled,894 displayChangeRequest.cxOrigin,895 displayChangeRequest.cyOrigin,896 displayChangeRequest.fChangeOrigin, 897 fExtDispSup898 ))871 LogFlowFunc(("ResizeDipspalyDevice return 0\n")); 872 break; 873 } 874 875 } 876 else 877 { 878 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) 899 893 { 900 LogFlowFunc(("ResizeDipspalyDevice return 0\n")); 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")); 901 916 break; 902 917 } 903 918 904 } 905 else 906 { 907 LogFlowFunc(("Detected NT\n")); 908 909 /* Single monitor NT. */ 910 DEVMODE devMode; 911 RT_ZERO(devMode); 912 devMode.dmSize = sizeof(DEVMODE); 913 914 /* get the current screen setup */ 915 if (EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &devMode)) 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) 916 939 { 917 LogFlowFunc(("Current mode: %d x %d x %d at %d,%d\n", 918 devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel, devMode.dmPosition.x, devMode.dmPosition.y)); 919 920 /* Check whether a mode reset or a change is requested. */ 921 if (displayChangeRequest.xres || displayChangeRequest.yres || displayChangeRequest.bpp) 940 LogFlowFunc(("error from ChangeDisplaySettings: %d\n", status)); 941 942 if (status == DISP_CHANGE_BADMODE) 922 943 { 923 /* A change is requested. 924 * Set values which are not to be changed to the current values. 925 */ 926 if (!displayChangeRequest.xres) 927 displayChangeRequest.xres = devMode.dmPelsWidth; 928 if (!displayChangeRequest.yres) 929 displayChangeRequest.yres = devMode.dmPelsHeight; 930 if (!displayChangeRequest.bpp) 931 displayChangeRequest.bpp = devMode.dmBitsPerPel; 932 } 933 else 934 { 935 /* All zero values means a forced mode reset. Do nothing. */ 936 LogFlowFunc(("Forced mode reset\n")); 937 } 938 939 /* Verify that the mode is indeed changed. */ 940 if ( devMode.dmPelsWidth == displayChangeRequest.xres 941 && devMode.dmPelsHeight == displayChangeRequest.yres 942 && devMode.dmBitsPerPel == displayChangeRequest.bpp) 943 { 944 LogFlowFunc(("already at desired resolution\n")); 945 break; 946 } 947 948 // without this, Windows will not ask the miniport for its 949 // mode table but uses an internal cache instead 950 DEVMODE tempDevMode = {0}; 951 tempDevMode.dmSize = sizeof(DEVMODE); 952 EnumDisplaySettings(NULL, 0xffffff, &tempDevMode); 953 954 /* adjust the values that are supposed to change */ 955 if (displayChangeRequest.xres) 956 devMode.dmPelsWidth = displayChangeRequest.xres; 957 if (displayChangeRequest.yres) 958 devMode.dmPelsHeight = displayChangeRequest.yres; 959 if (displayChangeRequest.bpp) 960 devMode.dmBitsPerPel = displayChangeRequest.bpp; 961 962 LogFlowFunc(("setting new mode %d x %d, %d BPP\n", 963 devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel)); 964 965 /* set the new mode */ 966 LONG status = ChangeDisplaySettings(&devMode, CDS_UPDATEREGISTRY); 967 if (status != DISP_CHANGE_SUCCESSFUL) 968 { 969 LogFlowFunc(("error from ChangeDisplaySettings: %d\n", status)); 970 971 if (status == DISP_CHANGE_BADMODE) 972 { 973 /* Our driver can not set the requested mode. Stop trying. */ 974 break; 975 } 976 } 977 else 978 { 979 /* Successfully set new video mode. */ 944 /* Our driver can not set the requested mode. Stop trying. */ 980 945 break; 981 946 } … … 983 948 else 984 949 { 985 LogFlowFunc(("error from EnumDisplaySettings: %d\n", GetLastError ()));950 /* Successfully set new video mode. */ 986 951 break; 987 952 } 988 953 } 954 else 955 { 956 LogFlowFunc(("error from EnumDisplaySettings: %d\n", GetLastError ())); 957 break; 958 } 989 959 } 990 else 991 { 992 LogFlowFunc(("vboxDisplayDriver is not active\n")); 993 } 994 960 995 961 /* Retry the change a bit later. */ 996 962 RTThreadSleep(1000);
Note:
See TracChangeset
for help on using the changeset viewer.