Changeset 50592 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Feb 25, 2014 7:56:18 PM (11 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/MouseImpl.cpp
r50589 r50592 156 156 * thus to the guest. 157 157 * @note all calls out of this object are made with no locks held! */ 158 HRESULT Mouse:: i_updateVMMDevMouseCaps(uint32_t fCapsAdded,159 158 HRESULT Mouse::updateVMMDevMouseCaps(uint32_t fCapsAdded, 159 uint32_t fCapsRemoved) 160 160 { 161 161 VMMDevMouseInterface *pVMMDev = mParent->getVMMDevMouseInterface(); … … 179 179 * @param absoluteSupported address of result variable 180 180 */ 181 HRESULT Mouse::getAbsoluteSupported(BOOL *aAbsoluteSupported) 182 { 183 *aAbsoluteSupported = i_supportsAbs(); 181 STDMETHODIMP Mouse::COMGETTER(AbsoluteSupported) (BOOL *absoluteSupported) 182 { 183 if (!absoluteSupported) 184 return E_POINTER; 185 186 AutoCaller autoCaller(this); 187 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 188 189 *absoluteSupported = supportsAbs(); 184 190 return S_OK; 185 191 } … … 192 198 * @param relativeSupported address of result variable 193 199 */ 194 HRESULT Mouse::getRelativeSupported(BOOL *aRelativeSupported) 195 { 196 197 *aRelativeSupported = i_supportsRel(); 200 STDMETHODIMP Mouse::COMGETTER(RelativeSupported) (BOOL *relativeSupported) 201 { 202 if (!relativeSupported) 203 return E_POINTER; 204 205 AutoCaller autoCaller(this); 206 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 207 208 *relativeSupported = supportsRel(); 198 209 return S_OK; 199 210 } … … 206 217 * @param multiTouchSupported address of result variable 207 218 */ 208 HRESULT Mouse::getMultiTouchSupported(BOOL *aMultiTouchSupported) 209 { 210 211 *aMultiTouchSupported = i_supportsMT(); 219 STDMETHODIMP Mouse::COMGETTER(MultiTouchSupported) (BOOL *multiTouchSupported) 220 { 221 if (!multiTouchSupported) 222 return E_POINTER; 223 224 AutoCaller autoCaller(this); 225 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 226 227 *multiTouchSupported = supportsMT(); 212 228 return S_OK; 213 229 } … … 220 236 * @param pfNeedsHostCursor address of result variable 221 237 */ 222 HRESULT Mouse::getNeedsHostCursor(BOOL *aNeedsHostCursor) 223 { 224 225 *aNeedsHostCursor = i_guestNeedsHostCursor(); 238 STDMETHODIMP Mouse::COMGETTER(NeedsHostCursor) (BOOL *pfNeedsHostCursor) 239 { 240 if (!pfNeedsHostCursor) 241 return E_POINTER; 242 243 AutoCaller autoCaller(this); 244 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 245 246 *pfNeedsHostCursor = guestNeedsHostCursor(); 226 247 return S_OK; 227 248 } … … 233 254 * held down from the format used by the front-end to the format used by PDM 234 255 * and the emulated pointing devices. */ 235 static uint32_t i_mouseButtonsToPDM(LONG buttonState)256 static uint32_t mouseButtonsToPDM(LONG buttonState) 236 257 { 237 258 uint32_t fButtons = 0; … … 249 270 } 250 271 251 HRESULT Mouse::getEventSource(ComPtr<IEventSource> &aEventSource) 252 { 272 STDMETHODIMP Mouse::COMGETTER(EventSource)(IEventSource ** aEventSource) 273 { 274 CheckComArgOutPointerValid(aEventSource); 275 276 AutoCaller autoCaller(this); 277 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 278 253 279 // no need to lock - lifetime constant 254 mEventSource.queryInterfaceTo(aEventSource.asOutParam()); 280 mEventSource.queryInterfaceTo(aEventSource); 281 255 282 return S_OK; 256 283 } … … 262 289 * @returns COM status code 263 290 */ 264 HRESULT Mouse:: i_reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,265 291 HRESULT Mouse::reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz, 292 int32_t dw, uint32_t fButtons) 266 293 { 267 294 if (dx || dy || dz || dw || fButtons != mfLastButtons) … … 298 325 * @returns COM status code 299 326 */ 300 HRESULT Mouse:: i_reportAbsEventToMouseDev(int32_t x, int32_t y,301 327 HRESULT Mouse::reportAbsEventToMouseDev(int32_t x, int32_t y, 328 int32_t dz, int32_t dw, uint32_t fButtons) 302 329 { 303 330 if ( x < VMMDEV_MOUSE_RANGE_MIN … … 335 362 } 336 363 337 HRESULT Mouse:: i_reportMultiTouchEventToDevice(uint8_t cContacts,338 339 364 HRESULT Mouse::reportMultiTouchEventToDevice(uint8_t cContacts, 365 const uint64_t *pau64Contacts, 366 uint32_t u32ScanTime) 340 367 { 341 368 HRESULT hrc = S_OK; … … 380 407 * @returns COM status code 381 408 */ 382 HRESULT Mouse:: i_reportAbsEventToVMMDev(int32_t x, int32_t y)409 HRESULT Mouse::reportAbsEventToVMMDev(int32_t x, int32_t y) 383 410 { 384 411 VMMDevMouseInterface *pVMMDev = mParent->getVMMDevMouseInterface(); … … 406 433 * @returns COM status code 407 434 */ 408 HRESULT Mouse:: i_reportAbsEvent(int32_t x, int32_t y,409 410 435 HRESULT Mouse::reportAbsEvent(int32_t x, int32_t y, 436 int32_t dz, int32_t dw, uint32_t fButtons, 437 bool fUsesVMMDevEvent) 411 438 { 412 439 HRESULT rc; … … 416 443 LONG cJiggle = 0; 417 444 418 if ( i_vmmdevCanAbs())445 if (vmmdevCanAbs()) 419 446 { 420 447 /* … … 423 450 if (x != mcLastX || y != mcLastY) 424 451 { 425 rc = i_reportAbsEventToVMMDev(x, y);452 rc = reportAbsEventToVMMDev(x, y); 426 453 cJiggle = !fUsesVMMDevEvent; 427 454 } 428 rc = i_reportRelEventToMouseDev(cJiggle, 0, dz, dw, fButtons);455 rc = reportRelEventToMouseDev(cJiggle, 0, dz, dw, fButtons); 429 456 } 430 457 else 431 rc = i_reportAbsEventToMouseDev(x, y, dz, dw, fButtons);458 rc = reportAbsEventToMouseDev(x, y, dz, dw, fButtons); 432 459 433 460 mcLastX = x; … … 436 463 } 437 464 438 void Mouse:: i_fireMouseEvent(bool fAbsolute, LONG x, LONG y, LONG dz, LONG dw,439 465 void Mouse::fireMouseEvent(bool fAbsolute, LONG x, LONG y, LONG dz, LONG dw, 466 LONG fButtons) 440 467 { 441 468 /* If mouse button is pressed, we generate new event, to avoid reusable events coalescing and thus … … 462 489 } 463 490 464 void Mouse:: i_fireMultiTouchEvent(uint8_t cContacts,465 466 491 void Mouse::fireMultiTouchEvent(uint8_t cContacts, 492 const LONG64 *paContacts, 493 uint32_t u32ScanTime) 467 494 { 468 495 com::SafeArray<SHORT> xPositions(cContacts); … … 501 528 * @param fButtons The mouse button state 502 529 */ 503 HRESULT Mouse::putMouseEvent(LONG dx, LONG dy, LONG dz, LONG dw,504 LONG aButtonState)530 STDMETHODIMP Mouse::PutMouseEvent(LONG dx, LONG dy, LONG dz, LONG dw, 531 LONG fButtons) 505 532 { 506 533 HRESULT rc; 507 534 uint32_t fButtonsAdj; 508 535 536 AutoCaller autoCaller(this); 537 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 509 538 LogRel3(("%s: dx=%d, dy=%d, dz=%d, dw=%d\n", __PRETTY_FUNCTION__, 510 539 dx, dy, dz, dw)); 511 540 512 fButtonsAdj = i_mouseButtonsToPDM(aButtonState);541 fButtonsAdj = mouseButtonsToPDM(fButtons); 513 542 /* Make sure that the guest knows that we are sending real movement 514 543 * events to the PS/2 device and not just dummy wake-up ones. */ 515 i_updateVMMDevMouseCaps(0, VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE);516 rc = i_reportRelEventToMouseDev(dx, dy, dz, dw, fButtonsAdj);517 518 i_fireMouseEvent(false, dx, dy, dz, dw, aButtonState);544 updateVMMDevMouseCaps(0, VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE); 545 rc = reportRelEventToMouseDev(dx, dy, dz, dw, fButtonsAdj); 546 547 fireMouseEvent(false, dx, dy, dz, dw, fButtons); 519 548 520 549 return rc; … … 536 565 * @returns COM status value 537 566 */ 538 HRESULT Mouse:: i_convertDisplayRes(LONG x, LONG y, int32_t *pxAdj, int32_t *pyAdj,539 567 HRESULT Mouse::convertDisplayRes(LONG x, LONG y, int32_t *pxAdj, int32_t *pyAdj, 568 bool *pfValid) 540 569 { 541 570 AssertPtrReturn(pxAdj, E_POINTER); … … 600 629 * @param fButtons The mouse button state 601 630 */ 602 HRESULT Mouse::putMouseEventAbsolute(LONG x, LONG y, LONG dz, LONG dw, 603 LONG aButtonState) 604 { 631 STDMETHODIMP Mouse::PutMouseEventAbsolute(LONG x, LONG y, LONG dz, LONG dw, 632 LONG fButtons) 633 { 634 AutoCaller autoCaller(this); 635 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 636 605 637 LogRel3(("%s: x=%d, y=%d, dz=%d, dw=%d, fButtons=0x%x\n", 606 __PRETTY_FUNCTION__, x, y, dz, dw, aButtonState));638 __PRETTY_FUNCTION__, x, y, dz, dw, fButtons)); 607 639 608 640 int32_t xAdj, yAdj; … … 613 645 /** @note Or maybe not... races are pretty inherent in everything done in 614 646 * this object and not really bad as far as I can see. */ 615 HRESULT rc = i_convertDisplayRes(x, y, &xAdj, &yAdj, &fValid);647 HRESULT rc = convertDisplayRes(x, y, &xAdj, &yAdj, &fValid); 616 648 if (FAILED(rc)) return rc; 617 649 618 fButtonsAdj = i_mouseButtonsToPDM(aButtonState);650 fButtonsAdj = mouseButtonsToPDM(fButtons); 619 651 /* If we are doing old-style (IRQ-less) absolute reporting to the VMM 620 652 * device then make sure the guest is aware of it, so that it knows to 621 653 * ignore relative movement on the PS/2 device. */ 622 i_updateVMMDevMouseCaps(VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE, 0);654 updateVMMDevMouseCaps(VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE, 0); 623 655 if (fValid) 624 656 { 625 rc = i_reportAbsEvent(xAdj, yAdj, dz, dw, fButtonsAdj,626 627 628 629 i_fireMouseEvent(true, x, y, dz, dw, aButtonState);657 rc = reportAbsEvent(xAdj, yAdj, dz, dw, fButtonsAdj, 658 RT_BOOL( mfVMMDevGuestCaps 659 & VMMDEV_MOUSE_NEW_PROTOCOL)); 660 661 fireMouseEvent(true, x, y, dz, dw, fButtons); 630 662 } 631 663 … … 642 674 * @param aScanTime Timestamp. 643 675 */ 644 HRESULT Mouse::putEventMultiTouch(LONG aCount, 645 const std::vector<LONG64> &aContacts, 646 ULONG aScanTime) 647 { 648 com::SafeArray <LONG64> arrayContacts(aContacts); 676 STDMETHODIMP Mouse::PutEventMultiTouch(LONG aCount, 677 ComSafeArrayIn(LONG64, aContacts), 678 ULONG aScanTime) 679 { 680 AutoCaller autoCaller(this); 681 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 682 683 com::SafeArray <LONG64> arrayContacts(ComSafeArrayInArg(aContacts)); 649 684 650 685 LogRel3(("%s: aCount %d(actual %d), aScanTime %u\n", … … 657 692 LONG64* paContacts = arrayContacts.raw(); 658 693 659 rc = i_putEventMultiTouch(aCount, paContacts, aScanTime);694 rc = putEventMultiTouch(aCount, paContacts, aScanTime); 660 695 } 661 696 else … … 675 710 * @param aScanTime Timestamp. 676 711 */ 677 HRESULT Mouse::putEventMultiTouchString(LONG aCount,678 const com::Utf8Str &aContacts,679 ULONG aScanTime)712 STDMETHODIMP Mouse::PutEventMultiTouchString(LONG aCount, 713 IN_BSTR aContacts, 714 ULONG aScanTime) 680 715 { 681 716 /** @todo implement: convert the string to LONG64 array and call putEventMultiTouch. */ … … 691 726 692 727 /* Used by PutEventMultiTouch and PutEventMultiTouchString. */ 693 HRESULT Mouse:: i_putEventMultiTouch(LONG aCount,694 695 728 HRESULT Mouse::putEventMultiTouch(LONG aCount, 729 LONG64 *paContacts, 730 ULONG aScanTime) 696 731 { 697 732 if (aCount >= 256) … … 784 819 if (SUCCEEDED(rc)) 785 820 { 786 rc = i_reportMultiTouchEventToDevice(cContacts, cContacts? pau64Contacts: NULL, (uint32_t)aScanTime);821 rc = reportMultiTouchEventToDevice(cContacts, cContacts? pau64Contacts: NULL, (uint32_t)aScanTime); 787 822 788 823 /* Send the original contact information. */ 789 i_fireMultiTouchEvent(cContacts, cContacts? paContacts: NULL, (uint32_t)aScanTime);824 fireMultiTouchEvent(cContacts, cContacts? paContacts: NULL, (uint32_t)aScanTime); 790 825 } 791 826 … … 798 833 /** Does the guest currently rely on the host to draw the mouse cursor or 799 834 * can it switch to doing it itself in software? */ 800 bool Mouse:: i_guestNeedsHostCursor(void)835 bool Mouse::guestNeedsHostCursor(void) 801 836 { 802 837 return RT_BOOL(mfVMMDevGuestCaps & VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR); … … 806 841 /** Check what sort of reporting can be done using the devices currently 807 842 * enabled. Does not consider the VMM device. */ 808 void Mouse:: i_getDeviceCaps(bool *pfAbs, bool *pfRel, bool *pfMT)843 void Mouse::getDeviceCaps(bool *pfAbs, bool *pfRel, bool *pfMT) 809 844 { 810 845 bool fAbsDev = false; … … 834 869 835 870 /** Does the VMM device currently support absolute reporting? */ 836 bool Mouse:: i_vmmdevCanAbs(void)871 bool Mouse::vmmdevCanAbs(void) 837 872 { 838 873 bool fRelDev; 839 874 840 i_getDeviceCaps(NULL, &fRelDev, NULL);875 getDeviceCaps(NULL, &fRelDev, NULL); 841 876 return (mfVMMDevGuestCaps & VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE) 842 877 && fRelDev; … … 845 880 846 881 /** Does the VMM device currently support absolute reporting? */ 847 bool Mouse:: i_deviceCanAbs(void)882 bool Mouse::deviceCanAbs(void) 848 883 { 849 884 bool fAbsDev; 850 885 851 i_getDeviceCaps(&fAbsDev, NULL, NULL);886 getDeviceCaps(&fAbsDev, NULL, NULL); 852 887 return fAbsDev; 853 888 } … … 855 890 856 891 /** Can we currently send relative events to the guest? */ 857 bool Mouse:: i_supportsRel(void)892 bool Mouse::supportsRel(void) 858 893 { 859 894 bool fRelDev; 860 895 861 i_getDeviceCaps(NULL, &fRelDev, NULL);896 getDeviceCaps(NULL, &fRelDev, NULL); 862 897 return fRelDev; 863 898 } … … 865 900 866 901 /** Can we currently send absolute events to the guest? */ 867 bool Mouse:: i_supportsAbs(void)902 bool Mouse::supportsAbs(void) 868 903 { 869 904 bool fAbsDev; 870 905 871 i_getDeviceCaps(&fAbsDev, NULL, NULL);872 return fAbsDev || i_vmmdevCanAbs();906 getDeviceCaps(&fAbsDev, NULL, NULL); 907 return fAbsDev || vmmdevCanAbs(); 873 908 } 874 909 875 910 876 911 /** Can we currently send absolute events to the guest? */ 877 bool Mouse:: i_supportsMT(void)912 bool Mouse::supportsMT(void) 878 913 { 879 914 bool fMTDev; 880 915 881 i_getDeviceCaps(NULL, NULL, &fMTDev);916 getDeviceCaps(NULL, NULL, &fMTDev); 882 917 return fMTDev; 883 918 } … … 887 922 * enabled (including the VMM device) and notify the guest and the front-end. 888 923 */ 889 void Mouse:: i_sendMouseCapsNotifications(void)924 void Mouse::sendMouseCapsNotifications(void) 890 925 { 891 926 bool fAbsDev, fRelDev, fMTDev, fCanAbs, fNeedsHostCursor; … … 894 929 AutoReadLock aLock(this COMMA_LOCKVAL_SRC_POS); 895 930 896 i_getDeviceCaps(&fAbsDev, &fRelDev, &fMTDev);897 fCanAbs = i_supportsAbs();898 fNeedsHostCursor = i_guestNeedsHostCursor();931 getDeviceCaps(&fAbsDev, &fRelDev, &fMTDev); 932 fCanAbs = supportsAbs(); 933 fNeedsHostCursor = guestNeedsHostCursor(); 899 934 } 900 935 if (fAbsDev) 901 i_updateVMMDevMouseCaps(VMMDEV_MOUSE_HOST_HAS_ABS_DEV, 0);936 updateVMMDevMouseCaps(VMMDEV_MOUSE_HOST_HAS_ABS_DEV, 0); 902 937 else 903 i_updateVMMDevMouseCaps(0, VMMDEV_MOUSE_HOST_HAS_ABS_DEV);938 updateVMMDevMouseCaps(0, VMMDEV_MOUSE_HOST_HAS_ABS_DEV); 904 939 /** @todo this call takes the Console lock in order to update the cached 905 940 * callback data atomically. However I can't see any sign that the cached … … 913 948 * A virtual device is notifying us about its current state and capabilities 914 949 */ 915 DECLCALLBACK(void) Mouse:: i_mouseReportModes(PPDMIMOUSECONNECTOR pInterface, bool fRel, bool fAbs, bool fMT)950 DECLCALLBACK(void) Mouse::mouseReportModes(PPDMIMOUSECONNECTOR pInterface, bool fRel, bool fAbs, bool fMT) 916 951 { 917 952 PDRVMAINMOUSE pDrv = RT_FROM_MEMBER(pInterface, DRVMAINMOUSE, IConnector); … … 929 964 pDrv->u32DevCaps &= ~MOUSE_DEVCAP_MULTI_TOUCH; 930 965 931 pDrv->pMouse-> i_sendMouseCapsNotifications();966 pDrv->pMouse->sendMouseCapsNotifications(); 932 967 } 933 968 … … 936 971 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 937 972 */ 938 DECLCALLBACK(void *) Mouse:: i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID)973 DECLCALLBACK(void *) Mouse::drvQueryInterface(PPDMIBASE pInterface, const char *pszIID) 939 974 { 940 975 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); … … 953 988 * @param pDrvIns The driver instance data. 954 989 */ 955 DECLCALLBACK(void) Mouse:: i_drvDestruct(PPDMDRVINS pDrvIns)990 DECLCALLBACK(void) Mouse::drvDestruct(PPDMDRVINS pDrvIns) 956 991 { 957 992 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns); … … 977 1012 * @copydoc FNPDMDRVCONSTRUCT 978 1013 */ 979 DECLCALLBACK(int) Mouse:: i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)1014 DECLCALLBACK(int) Mouse::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags) 980 1015 { 981 1016 PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns); … … 995 1030 * IBase. 996 1031 */ 997 pDrvIns->IBase.pfnQueryInterface = Mouse:: i_drvQueryInterface;998 999 pThis->IConnector.pfnReportModes = Mouse:: i_mouseReportModes;1032 pDrvIns->IBase.pfnQueryInterface = Mouse::drvQueryInterface; 1033 1034 pThis->IConnector.pfnReportModes = Mouse::mouseReportModes; 1000 1035 1001 1036 /* … … 1062 1097 sizeof(DRVMAINMOUSE), 1063 1098 /* pfnConstruct */ 1064 Mouse:: i_drvConstruct,1099 Mouse::drvConstruct, 1065 1100 /* pfnDestruct */ 1066 Mouse:: i_drvDestruct,1101 Mouse::drvDestruct, 1067 1102 /* pfnRelocate */ 1068 1103 NULL, -
trunk/src/VBox/Main/src-client/VMMDevInterface.cpp
r50589 r50592 339 339 Mouse *pMouse = pConsole->getMouse(); 340 340 if (pMouse) /** @todo and if not? Can that actually happen? */ 341 pMouse-> i_onVMMDevGuestCapsChange(fNewCaps & VMMDEV_MOUSE_GUEST_MASK);341 pMouse->onVMMDevGuestCapsChange(fNewCaps & VMMDEV_MOUSE_GUEST_MASK); 342 342 } 343 343 -
trunk/src/VBox/Main/src-client/xpcom/module.cpp
r50589 r50592 78 78 NS_DECL_CLASSINFO(Keyboard) 79 79 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Keyboard, IKeyboard) 80 NS_DECL_CLASSINFO(Mouse) 81 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Mouse, IMouse) 80 82 NS_DECL_CLASSINFO(Display) 81 83 NS_IMPL_THREADSAFE_ISUPPORTS2_CI(Display, IDisplay, IEventListener)
Note:
See TracChangeset
for help on using the changeset viewer.