Changeset 38590 in vbox
- Timestamp:
- Aug 31, 2011 7:36:39 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 73785
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/MouseImpl.cpp
r38271 r38590 480 480 * validity value to false if the pair is not on an active screen and to true 481 481 * otherwise. 482 * @note since guests with recent versions of X.Org use a different method 483 * to everyone else to map the valuator value to a screen pixel (they 484 * multiply by the screen dimension, do a floating point divide by 485 * the valuator maximum and round the result, while everyone else 486 * does truncating integer operations) we adjust the value we send 487 * so that it maps to the right pixel both when the result is rounded 488 * and when it is truncated. 482 489 * 483 490 * @returns COM status value … … 491 498 Display *pDisplay = mParent->getDisplay(); 492 499 ComAssertRet(pDisplay, E_FAIL); 500 /** The amount to add to the result (multiplied by the screen width/height) 501 * to compensate for differences in guest methods for mapping back to 502 * pixels */ 503 enum { ADJUST_RANGE = - 3 * MOUSE_RANGE / 4 }; 493 504 494 505 if (pfValid) … … 503 514 return rc; 504 515 505 *pcX = displayWidth ? (x * MOUSE_RANGE - MOUSE_RANGE / 2) / (LONG) displayWidth: 0;506 *pcY = displayHeight ? (y * MOUSE_RANGE - MOUSE_RANGE / 2) / (LONG) displayHeight: 0;516 *pcX = displayWidth ? (x * MOUSE_RANGE + ADJUST_RANGE) / (LONG) displayWidth: 0; 517 *pcY = displayHeight ? (y * MOUSE_RANGE + ADJUST_RANGE) / (LONG) displayHeight: 0; 507 518 } 508 519 else … … 511 522 /* Takes the display lock */ 512 523 pDisplay->getFramebufferDimensions(&x1, &y1, &x2, &y2); 513 *pcX = x1 < x2 ? ((x - x1) * MOUSE_RANGE - MOUSE_RANGE / 2) / (x2 - x1) : 0;514 *pcY = y1 < y2 ? ((y - y1) * MOUSE_RANGE - MOUSE_RANGE / 2) / (y2 - y1) : 0;524 *pcX = x1 < x2 ? ((x - x1) * MOUSE_RANGE + ADJUST_RANGE) / (x2 - x1) : 0; 525 *pcY = y1 < y2 ? ((y - y1) * MOUSE_RANGE + ADJUST_RANGE) / (y2 - y1) : 0; 515 526 if ( *pcX < MOUSE_RANGE_LOWER || *pcX > MOUSE_RANGE_UPPER 516 527 || *pcY < MOUSE_RANGE_LOWER || *pcY > MOUSE_RANGE_UPPER)
Note:
See TracChangeset
for help on using the changeset viewer.