Changeset 19703 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp
- Timestamp:
- May 14, 2009 3:58:41 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp
r19701 r19703 169 169 if (DisplayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) 170 170 { 171 Log((" Found primary device. err %d\n", GetLastError ()));171 Log(("ResizeDisplayDevice: Found primary device. err %d\n", GetLastError ())); 172 172 NumDevices++; 173 173 } … … 175 175 { 176 176 177 Log((" Found secondary device. err %d\n", GetLastError ()));177 Log(("ResizeDisplayDevice: Found secondary device. err %d\n", GetLastError ())); 178 178 NumDevices++; 179 179 } … … 184 184 } 185 185 186 Log((" Found total %d devices. err %d\n", NumDevices, GetLastError ()));186 Log(("ResizeDisplayDevice: Found total %d devices. err %d\n", NumDevices, GetLastError ())); 187 187 188 188 if (NumDevices == 0 || Id >= NumDevices) 189 189 { 190 Log(("Re quested identifier %d is invalid. err %d\n", Id, GetLastError ()));190 Log(("ResizeDisplayDevice: Requested identifier %d is invalid. err %d\n", Id, GetLastError ())); 191 191 return FALSE; 192 192 } … … 206 206 while (EnumDisplayDevices (NULL, i, &DisplayDevice, 0)) 207 207 { 208 Log((" [%d(%d)] %s\n", i, DevNum, DisplayDevice.DeviceName));208 Log(("ResizeDisplayDevice: [%d(%d)] %s\n", i, DevNum, DisplayDevice.DeviceName)); 209 209 210 210 BOOL bFetchDevice = FALSE; … … 212 212 if (DisplayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) 213 213 { 214 Log((" Found primary device. err %d\n", GetLastError ()));214 Log(("ResizeDisplayDevice: Found primary device. err %d\n", GetLastError ())); 215 215 DevPrimaryNum = DevNum; 216 216 bFetchDevice = TRUE; … … 219 219 { 220 220 221 Log((" Found secondary device. err %d\n", GetLastError ()));221 Log(("ResizeDisplayDevice: Found secondary device. err %d\n", GetLastError ())); 222 222 bFetchDevice = TRUE; 223 223 } … … 227 227 if (DevNum >= NumDevices) 228 228 { 229 Log((" %d >= %d\n", NumDevices, DevNum));229 Log(("ResizeDisplayDevice: %d >= %d\n", NumDevices, DevNum)); 230 230 return FALSE; 231 231 } … … 238 238 ENUM_REGISTRY_SETTINGS, &paDeviceModes[DevNum])) 239 239 { 240 Log((" EnumDisplaySettings err %d\n", GetLastError ()));240 Log(("ResizeDisplayDevice: EnumDisplaySettings err %d\n", GetLastError ())); 241 241 return FALSE; 242 242 } 243 243 244 Log((" %dx%d at %d,%d\n",244 Log(("ResizeDisplayDevice: %dx%d at %d,%d\n", 245 245 paDeviceModes[DevNum].dmPelsWidth, 246 246 paDeviceModes[DevNum].dmPelsHeight, … … 281 281 && paDeviceModes[Id].dmBitsPerPel == BitsPerPixel) 282 282 { 283 Log((" VBoxDisplayThread : already at desired resolution.\n"));283 Log(("ResizeDisplayDevice: Already at desired resolution.\n")); 284 284 return FALSE; 285 285 } … … 289 289 for (i = 0; i < NumDevices; i++) 290 290 { 291 Log((" [%d]: %d,%d %dx%d\n",291 Log(("ResizeDisplayDevice: [%d]: %d,%d %dx%d\n", 292 292 i, paRects[i].left, paRects[i].top, 293 293 paRects[i].right - paRects[i].left, … … 303 303 tempDevMode.dmSize = sizeof(DEVMODE); 304 304 EnumDisplaySettings(NULL, 0xffffff, &tempDevMode); 305 BOOL bUpdateMonitor = FALSE; 306 LONG status = 0; 305 307 306 308 /* Assign the new rectangles to displays. */ … … 321 323 } 322 324 323 Log(("calling pfnChangeDisplaySettingsEx %x\n", gCtx.pfnChangeDisplaySettingsEx)); 324 325 gCtx.pfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName, 326 &paDeviceModes[i], NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL); 327 328 Log(("ChangeDisplaySettings position err %d\n", GetLastError ())); 325 /* Test if the mode can be set. */ 326 Log(("ResizeDisplayDevice: Testing if the mode can be set ...\n")); 327 SetLastError(0); 328 status = gCtx.pfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName, 329 &paDeviceModes[i], NULL, CDS_TEST, NULL); 330 if (status == DISP_CHANGE_SUCCESSFUL) 331 { 332 Log(("ResizeDisplayDevice: Mode can be set! Calling pfnChangeDisplaySettingsEx %x\n", gCtx.pfnChangeDisplaySettingsEx)); 333 gCtx.pfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName, 334 &paDeviceModes[i], NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL); 335 Log(("ResizeDisplayDevice: ChangeDisplaySettingsEx position err %d\n", GetLastError ())); 336 bUpdateMonitor = TRUE; 337 } 338 else 339 { 340 if (status == DISP_CHANGE_BADMODE) 341 { 342 Log(("ResizeDisplayDevice: Bad mode detected. No changes made.\n")); 343 } 344 else Log(("ResizeDisplayDevice: Mode can NOT be set! Error: %d\n", status)); 345 } 329 346 } 330 347 331 348 /* A second call to ChangeDisplaySettings updates the monitor. */ 332 LONG status = ChangeDisplaySettings(NULL, 0); 333 Log(("ChangeDisplaySettings update status %d\n", status)); 334 if (status == DISP_CHANGE_SUCCESSFUL || status == DISP_CHANGE_BADMODE) 335 { 336 /* Successfully set new video mode or our driver can not set the requested mode. Stop trying. */ 337 return FALSE; 338 } 339 340 /* Retry the request. */ 341 return TRUE; 349 if (bUpdateMonitor) 350 { 351 status = ChangeDisplaySettings(NULL, 0); 352 Log(("ResizeDisplayDevice: ChangeDisplaySettings update status %d\n", status)); 353 if (status == DISP_CHANGE_SUCCESSFUL || status == DISP_CHANGE_BADMODE) 354 { 355 /* Successfully set new video mode or our driver can not set the requested mode. Stop trying. */ 356 return FALSE; 357 } 358 359 /* Retry the request. */ 360 return TRUE; 361 } 362 363 return FALSE; /* Don't retry; maybe something went wrong. */ 342 364 } 343 365
Note:
See TracChangeset
for help on using the changeset viewer.