Changeset 34475 in vbox
- Timestamp:
- Nov 29, 2010 3:40:56 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp
r34471 r34475 156 156 /* Memorize the host position where the cursor was captured: */ 157 157 m_capturedMousePos = QCursor::pos(); 158 159 /* Acquiring visible viewport rectangle in global coodrinates: */ 160 QRect visibleRectangle = m_viewports[m_iMouseCaptureViewIndex]->visibleRegion().boundingRect(); 161 QPoint visibleRectanglePos = m_views[m_iMouseCaptureViewIndex]->mapToGlobal(m_viewports[m_iMouseCaptureViewIndex]->pos()); 162 visibleRectangle.translate(visibleRectanglePos); 163 visibleRectangle = visibleRectangle.intersected(QApplication::desktop()->availableGeometry()); 164 158 165 #ifdef Q_WS_WIN 159 166 /* Move the mouse to the center of the visible area: */ 160 m_lastMousePos = m_views[m_iMouseCaptureViewIndex]->mapToGlobal(m_views[m_iMouseCaptureViewIndex]->visibleRegion().boundingRect().center());167 m_lastMousePos = visibleRectangle.center(); 161 168 QCursor::setPos(m_lastMousePos); 162 169 /* Update mouse clipping: */ … … 164 171 #elif defined (Q_WS_MAC) 165 172 /* Move the mouse to the center of the visible area: */ 166 m_lastMousePos = m_views[m_iMouseCaptureViewIndex]->mapToGlobal(m_views[m_iMouseCaptureViewIndex]->visibleRegion().boundingRect().center());173 m_lastMousePos = visibleRectangle.center(); 167 174 QCursor::setPos(m_lastMousePos); 168 175 /* Grab all mouse events: */ … … 707 714 708 715 # ifdef Q_WS_WIN 709 int iWe = m_viewports[uScreenId]->width() - 1; 710 int iHe = m_viewports[uScreenId]->height() - 1; 716 /* Acquiring visible viewport rectangle in local coordinates: */ 717 QRect viewportRectangle = m_viewports[uScreenId]->visibleRegion().boundingRect(); 718 QPoint viewportRectangleGlobalPos = m_views[uScreenId]->mapToGlobal(m_viewports[uScreenId]->pos()); 719 /* Shift viewport rectangle to global position to bound by available geometry: */ 720 viewportRectangle.translate(viewportRectangleGlobalPos); 721 /* Acquiring viewport rectangle cropped by available geometry: */ 722 viewportRectangle = viewportRectangle.intersected(QApplication::desktop()->availableGeometry()); 723 /* Shift remaining viewport rectangle to local position as relative position is in local coordinates: */ 724 viewportRectangle.translate(-viewportRectangleGlobalPos); 725 726 /* Get boundaries: */ 727 int ix1 = viewportRectangle.left() + 1; 728 int iy1 = viewportRectangle.top() + 1; 729 int ix2 = viewportRectangle.right() - 1; 730 int iy2 = viewportRectangle.bottom() - 1; 731 732 /* Simulate infinite movement: */ 711 733 QPoint p = relativePos; 712 if (relativePos.x() == 0) 713 p.setX(iWe - 1); 714 else if (relativePos.x() == iWe) 715 p.setX(1); 716 if (relativePos.y() == 0 ) 717 p.setY(iHe - 1); 718 else if (relativePos.y() == iHe) 719 p.setY(1); 720 734 if (relativePos.x() == ix1) 735 p.setX(ix2 - 1); 736 else if (relativePos.x() == ix2) 737 p.setX(ix1 + 1); 738 if (relativePos.y() == iy1) 739 p.setY(iy2 - 1); 740 else if (relativePos.y() == iy2) 741 p.setY(iy1 + 1); 721 742 if (p != relativePos) 722 743 { … … 870 891 void UIMouseHandler::updateMouseCursorClipping() 871 892 { 872 /* Check if such view port isregistered: */873 if (!m_view ports.contains(m_iMouseCaptureViewIndex))893 /* Check if such view && viewport are registered: */ 894 if (!m_views.contains(m_iMouseCaptureViewIndex) || !m_viewports.contains(m_iMouseCaptureViewIndex)) 874 895 return; 875 896 876 897 if (uisession()->isMouseCaptured()) 877 898 { 878 QWidget *pMachineViewViewport = m_viewports[m_iMouseCaptureViewIndex]; 879 QRect r = pMachineViewViewport->rect(); 880 r.moveTopLeft(pMachineViewViewport->mapToGlobal(QPoint(0, 0))); 881 RECT rect = { r.left(), r.top(), r.right() + 1, r.bottom() + 1 }; 899 /* Acquiring visible viewport rectangle: */ 900 QRect viewportRectangle = m_viewports[m_iMouseCaptureViewIndex]->visibleRegion().boundingRect(); 901 QPoint viewportRectangleGlobalPos = m_views[m_iMouseCaptureViewIndex]->mapToGlobal(m_viewports[m_iMouseCaptureViewIndex]->pos()); 902 viewportRectangle.translate(viewportRectangleGlobalPos); 903 viewportRectangle = viewportRectangle.intersected(QApplication::desktop()->availableGeometry()); 904 /* Prepare clipping area: */ 905 RECT rect = { viewportRectangle.left() + 1, viewportRectangle.top() + 1, viewportRectangle.right(), viewportRectangle.bottom() }; 882 906 ::ClipCursor(&rect); 883 907 }
Note:
See TracChangeset
for help on using the changeset viewer.