Changeset 10859 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Jul 24, 2008 4:43:29 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 33675
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp
r10834 r10859 54 54 * Displays the program usage message. 55 55 * 56 * @param u64Which 57 * 56 * @param u64Which 57 * 58 58 * @{ 59 */ 59 */ 60 60 61 61 /** Helper function */ … … 190 190 paNewRects[iResized].right += NewWidth - (paNewRects[iResized].right - paNewRects[iResized].left); 191 191 paNewRects[iResized].bottom += NewHeight - (paNewRects[iResized].bottom - paNewRects[iResized].top); 192 193 /* Verify all pairs of originally adjacent rectangles for all 4 directions. 192 193 /* Verify all pairs of originally adjacent rectangles for all 4 directions. 194 194 * If the pair has a "good" delta (that is the first rectangle intersects the second) 195 195 * at a direction and the second rectangle is not primary one (which can not be moved), 196 196 * move the second rectangle to make it adjacent to the first one. 197 197 */ 198 198 199 199 /* X positive. */ 200 200 unsigned iRect; … … 204 204 unsigned iNextRect = nextAdjacentRectXP (paRects, nRects, iRect); 205 205 Log(("next %d -> %d\n", iRect, iNextRect)); 206 206 207 207 if (iNextRect == ~0 || iNextRect == iPrimary) 208 208 { 209 209 continue; 210 210 } 211 211 212 212 /* Check whether there is an X intesection between these adjacent rects in the new rectangles 213 213 * and fix the intersection if delta is "good". 214 214 */ 215 215 int delta = paNewRects[iRect].right - paNewRects[iNextRect].left; 216 216 217 217 if (delta > 0) 218 218 { … … 220 220 paNewRects[iRect].right, paNewRects[iNextRect].left, 221 221 delta)); 222 222 223 223 paNewRects[iNextRect].left += delta; 224 224 paNewRects[iNextRect].right += delta; 225 225 } 226 226 } 227 227 228 228 /* X negative. */ 229 229 for (iRect = 0; iRect < nRects; iRect++) … … 232 232 unsigned iNextRect = nextAdjacentRectXN (paRects, nRects, iRect); 233 233 Log(("next %d -> %d\n", iRect, iNextRect)); 234 234 235 235 if (iNextRect == ~0 || iNextRect == iPrimary) 236 236 { 237 237 continue; 238 238 } 239 239 240 240 /* Check whether there is an X intesection between these adjacent rects in the new rectangles 241 241 * and fix the intersection if delta is "good". 242 242 */ 243 243 int delta = paNewRects[iRect].left - paNewRects[iNextRect].right; 244 244 245 245 if (delta < 0) 246 246 { … … 248 248 paNewRects[iRect].left, paNewRects[iNextRect].right, 249 249 delta)); 250 250 251 251 paNewRects[iNextRect].left += delta; 252 252 paNewRects[iNextRect].right += delta; 253 253 } 254 254 } 255 255 256 256 /* Y positive (in the computer sence, top->down). */ 257 257 for (iRect = 0; iRect < nRects; iRect++) … … 260 260 unsigned iNextRect = nextAdjacentRectYP (paRects, nRects, iRect); 261 261 Log(("next %d -> %d\n", iRect, iNextRect)); 262 262 263 263 if (iNextRect == ~0 || iNextRect == iPrimary) 264 264 { 265 265 continue; 266 266 } 267 267 268 268 /* Check whether there is an Y intesection between these adjacent rects in the new rectangles 269 269 * and fix the intersection if delta is "good". 270 270 */ 271 271 int delta = paNewRects[iRect].bottom - paNewRects[iNextRect].top; 272 272 273 273 if (delta > 0) 274 274 { … … 276 276 paNewRects[iRect].bottom, paNewRects[iNextRect].top, 277 277 delta)); 278 278 279 279 paNewRects[iNextRect].top += delta; 280 280 paNewRects[iNextRect].bottom += delta; 281 281 } 282 282 } 283 283 284 284 /* Y negative (in the computer sence, down->top). */ 285 285 for (iRect = 0; iRect < nRects; iRect++) … … 288 288 unsigned iNextRect = nextAdjacentRectYN (paRects, nRects, iRect); 289 289 Log(("next %d -> %d\n", iRect, iNextRect)); 290 290 291 291 if (iNextRect == ~0 || iNextRect == iPrimary) 292 292 { 293 293 continue; 294 294 } 295 295 296 296 /* Check whether there is an Y intesection between these adjacent rects in the new rectangles 297 297 * and fix the intersection if delta is "good". 298 298 */ 299 299 int delta = paNewRects[iRect].top - paNewRects[iNextRect].bottom; 300 300 301 301 if (delta < 0) 302 302 { … … 304 304 paNewRects[iRect].top, paNewRects[iNextRect].bottom, 305 305 delta)); 306 306 307 307 paNewRects[iNextRect].top += delta; 308 308 paNewRects[iNextRect].bottom += delta; 309 309 } 310 310 } 311 311 312 312 memcpy (paRects, paNewRects, sizeof (RECTL) * nRects); 313 313 return; … … 318 318 { 319 319 BOOL fModeReset = (Width == 0 && Height == 0 && BitsPerPixel == 0); 320 320 321 321 DISPLAY_DEVICE DisplayDevice; 322 322 323 323 ZeroMemory(&DisplayDevice, sizeof(DisplayDevice)); 324 324 DisplayDevice.cb = sizeof(DisplayDevice); 325 325 326 326 /* Find out how many display devices the system has */ 327 327 DWORD NumDevices = 0; 328 328 DWORD i = 0; 329 329 while (EnumDisplayDevices (NULL, i, &DisplayDevice, 0)) 330 { 330 { 331 331 Log(("[%d] %s\n", i, DisplayDevice.DeviceName)); 332 332 … … 338 338 else if (!(DisplayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER)) 339 339 { 340 340 341 341 Log(("Found secondary device. err %d\n", GetLastError ())); 342 342 NumDevices++; 343 343 } 344 344 345 345 ZeroMemory(&DisplayDevice, sizeof(DisplayDevice)); 346 346 DisplayDevice.cb = sizeof(DisplayDevice); 347 347 i++; 348 348 } 349 349 350 350 Log(("Found total %d devices. err %d\n", NumDevices, GetLastError ())); 351 351 352 352 if (NumDevices == 0 || Id >= NumDevices) 353 353 { … … 355 355 return FALSE; 356 356 } 357 357 358 358 DISPLAY_DEVICE *paDisplayDevices = (DISPLAY_DEVICE *)alloca (sizeof (DISPLAY_DEVICE) * NumDevices); 359 359 DEVMODE *paDeviceModes = (DEVMODE *)alloca (sizeof (DEVMODE) * NumDevices); 360 360 RECTL *paRects = (RECTL *)alloca (sizeof (RECTL) * NumDevices); 361 361 362 362 /* Fetch information about current devices and modes. */ 363 363 DWORD DevNum = 0; 364 364 DWORD DevPrimaryNum = 0; 365 365 366 366 ZeroMemory(&DisplayDevice, sizeof(DISPLAY_DEVICE)); 367 367 DisplayDevice.cb = sizeof(DISPLAY_DEVICE); 368 368 369 369 i = 0; 370 370 while (EnumDisplayDevices (NULL, i, &DisplayDevice, 0)) 371 { 371 { 372 372 Log(("[%d(%d)] %s\n", i, DevNum, DisplayDevice.DeviceName)); 373 373 374 374 BOOL bFetchDevice = FALSE; 375 375 … … 382 382 else if (!(DisplayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER)) 383 383 { 384 384 385 385 Log(("Found secondary device. err %d\n", GetLastError ())); 386 386 bFetchDevice = TRUE; 387 387 } 388 388 389 389 if (bFetchDevice) 390 390 { … … 394 394 return FALSE; 395 395 } 396 396 397 397 paDisplayDevices[DevNum] = DisplayDevice; 398 398 399 399 ZeroMemory(&paDeviceModes[DevNum], sizeof(DEVMODE)); 400 400 paDeviceModes[DevNum].dmSize = sizeof(DEVMODE); … … 405 405 return FALSE; 406 406 } 407 407 408 408 Log(("%dx%d at %d,%d\n", 409 409 paDeviceModes[DevNum].dmPelsWidth, … … 411 411 paDeviceModes[DevNum].dmPosition.x, 412 412 paDeviceModes[DevNum].dmPosition.y)); 413 413 414 414 paRects[DevNum].left = paDeviceModes[DevNum].dmPosition.x; 415 415 paRects[DevNum].top = paDeviceModes[DevNum].dmPosition.y; … … 418 418 DevNum++; 419 419 } 420 420 421 421 ZeroMemory(&DisplayDevice, sizeof(DISPLAY_DEVICE)); 422 422 DisplayDevice.cb = sizeof(DISPLAY_DEVICE); 423 423 i++; 424 424 } 425 425 426 426 if (Width == 0) 427 427 { … … 454 454 } 455 455 #endif /* Log */ 456 456 457 457 /* Without this, Windows will not ask the miniport for its 458 458 * mode table but uses an internal cache instead. … … 470 470 paDeviceModes[i].dmPelsWidth = paRects[i].right - paRects[i].left; 471 471 paDeviceModes[i].dmPelsHeight = paRects[i].bottom - paRects[i].top; 472 472 473 473 paDeviceModes[i].dmFields = DM_POSITION | DM_PELSHEIGHT | DM_PELSWIDTH; 474 474 475 475 if ( i == Id 476 476 && BitsPerPixel != 0) … … 479 479 paDeviceModes[i].dmBitsPerPel = BitsPerPixel; 480 480 } 481 Log(("calling pfnChangeDisplaySettingsEx %x\n", gpfnChangeDisplaySettingsEx)); 482 gpfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName, 483 &paDeviceModes[i], NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL); 481 Log(("calling pfnChangeDisplaySettingsEx %x\n", gpfnChangeDisplaySettingsEx)); 482 gpfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName, 483 &paDeviceModes[i], NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL); 484 484 Log(("ChangeDisplaySettings position err %d\n", GetLastError ())); 485 485 } 486 486 487 487 /* A second call to ChangeDisplaySettings updates the monitor. */ 488 LONG status = ChangeDisplaySettings(NULL, 0); 488 LONG status = ChangeDisplaySettings(NULL, 0); 489 489 Log(("ChangeDisplaySettings update status %d\n", status)); 490 490 if (status == DISP_CHANGE_SUCCESSFUL || status == DISP_CHANGE_BADMODE) … … 522 522 *(uintptr_t *)&gpfnChangeDisplaySettingsEx = (uintptr_t)GetProcAddress(hUser, "ChangeDisplaySettingsExA"); 523 523 Log(("VBoxService: pChangeDisplaySettingsEx = %p\n", gpfnChangeDisplaySettingsEx)); 524 524 525 525 if (gpfnChangeDisplaySettingsEx) 526 526 { 527 527 /* The screen index is 0 based in the ResizeDisplayDevice call. */ 528 528 scr = scr > 0? scr - 1: 0; 529 529 530 530 /* Horizontal resolution must be a multiple of 8, round down. */ 531 531 xres &= ~0x7; … … 891 891 * Here we actually retrieve the value from the host. 892 892 */ 893 void *pvBuf = NULL; 893 894 const char *pszName = argv[0]; 894 895 char *pszValue = NULL; … … 903 904 bool finish = false; 904 905 /* We leave a bit of space here in case the maximum values are raised. */ 905 void *pvBuf = NULL;906 906 uint32_t cbBuf = MAX_VALUE_LEN + MAX_FLAGS_LEN + 1024; 907 907 for (unsigned i = 0; (i < 10) && !finish; ++i) … … 910 910 if (NULL == pvTmpBuf) 911 911 { 912 RTMemFree(pvBuf);913 912 rc = VERR_NO_MEMORY; 914 913 VBoxControlError("Out of memory\n"); … … 937 936 if (VERR_NOT_FOUND == rc) 938 937 RTPrintf("No value set!\n"); 939 if (RT_SUCCESS(rc)) 938 else if (RT_SUCCESS(rc)) 939 { 940 940 RTPrintf("Value: %S\n", pszValue); 941 if (RT_SUCCESS(rc) && verbose) 942 { 943 RTPrintf("Timestamp: %lld ns\n", u64Timestamp); 944 RTPrintf("Flags: %S\n", pszFlags); 941 if (verbose) 942 { 943 RTPrintf("Timestamp: %lld ns\n", u64Timestamp); 944 RTPrintf("Flags: %S\n", pszFlags); 945 } 945 946 } 946 947 947 948 if (u32ClientId != 0) 948 949 VbglR3GuestPropDisconnect(u32ClientId); 950 RTMemFree(pvBuf); 949 951 return RT_SUCCESS(rc) ? 0 : 1; 950 952 } … … 1112 1114 onlyinfo = true; 1113 1115 dohelp = true; 1114 done = true; 1116 done = true; 1115 1117 } 1116 1118 else
Note:
See TracChangeset
for help on using the changeset viewer.