Changeset 26929 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Mar 2, 2010 12:27:24 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 58216
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r26921 r26929 283 283 } 284 284 285 QSize UIMachineView::desktopGeometry() const 286 { 287 QSize geometry; 288 switch (m_desktopGeometryType) 289 { 290 case DesktopGeo_Fixed: 291 case DesktopGeo_Automatic: 292 geometry = QSize(qMax(m_desktopGeometry.width(), m_storedConsoleSize.width()), 293 qMax(m_desktopGeometry.height(), m_storedConsoleSize.height())); 294 break; 295 case DesktopGeo_Any: 296 geometry = QSize(0, 0); 297 break; 298 default: 299 AssertMsgFailed(("Bad geometry type %d!\n", m_desktopGeometryType)); 300 } 301 return geometry; 302 } 303 304 void UIMachineView::setDesktopGeometry(DesktopGeo geometry, int aWidth, int aHeight) 305 { 306 switch (geometry) 307 { 308 case DesktopGeo_Fixed: 309 m_desktopGeometryType = DesktopGeo_Fixed; 310 if (aWidth != 0 && aHeight != 0) 311 m_desktopGeometry = QSize(aWidth, aHeight); 312 else 313 m_desktopGeometry = QSize(0, 0); 314 storeConsoleSize(0, 0); 315 break; 316 case DesktopGeo_Automatic: 317 m_desktopGeometryType = DesktopGeo_Automatic; 318 m_desktopGeometry = QSize(0, 0); 319 storeConsoleSize(0, 0); 320 break; 321 case DesktopGeo_Any: 322 m_desktopGeometryType = DesktopGeo_Any; 323 m_desktopGeometry = QSize(0, 0); 324 break; 325 default: 326 AssertMsgFailed(("Invalid desktop geometry type %d\n", geometry)); 327 m_desktopGeometryType = DesktopGeo_Invalid; 328 } 329 } 330 331 void UIMachineView::storeConsoleSize(int iWidth, int iHeight) 332 { 333 m_storedConsoleSize = QSize(iWidth, iHeight); 334 } 335 336 void UIMachineView::calculateDesktopGeometry() 337 { 338 /* This method should not get called until we have initially set up the m_desktopGeometryType: */ 339 Assert((m_desktopGeometryType != DesktopGeo_Invalid)); 340 /* If we are not doing automatic geometry calculation then there is nothing to do: */ 341 if (DesktopGeo_Automatic == m_desktopGeometryType) 342 { 343 /* Available geometry of the desktop. If the desktop is a single 344 * screen, this will exclude space taken up by desktop taskbars 345 * and things, but this is unfortunately not true for the more 346 * complex case of a desktop spanning multiple screens: */ 347 QRect desktop = availableGeometry(); 348 /* The area taken up by the machine window on the desktop, 349 * including window frame, title and menu bar and whatnot: */ 350 QRect frame = machineWindowWrapper()->machineWindow()->frameGeometry(); 351 /* The area taken up by the machine view, so excluding all decorations: */ 352 QRect window = geometry(); 353 /* To work out how big we can make the console window while still 354 * fitting on the desktop, we calculate desktop - frame + window. 355 * This works because the difference between frame and window 356 * (or at least its width and height) is a constant. */ 357 m_desktopGeometry = QSize(desktop.width() - frame.width() + window.width(), 358 desktop.height() - frame.height() + window.height()); 359 } 360 } 361 285 362 void UIMachineView::updateMouseClipping() 286 363 { … … 312 389 313 390 QSize v = QSize(m_pFrameBuffer->width(), m_pFrameBuffer->height()); 314 /* no scroll bars needed*/391 /* No scroll bars needed: */ 315 392 if (m.expandedTo(v) == m) 316 393 p = m; … … 553 630 } 554 631 555 QSize UIMachineView::desktopGeometry() const556 {557 QSize geometry;558 switch (m_desktopGeometryType)559 {560 case DesktopGeo_Fixed:561 case DesktopGeo_Automatic:562 geometry = QSize(qMax(m_desktopGeometry.width(), m_storedConsoleSize.width()),563 qMax(m_desktopGeometry.height(), m_storedConsoleSize.height()));564 break;565 case DesktopGeo_Any:566 geometry = QSize(0, 0);567 break;568 default:569 AssertMsgFailed(("Bad geometry type %d!\n", m_desktopGeometryType));570 }571 return geometry;572 }573 574 void UIMachineView::setDesktopGeometry(DesktopGeo geometry, int aWidth, int aHeight)575 {576 switch (geometry)577 {578 case DesktopGeo_Fixed:579 m_desktopGeometryType = DesktopGeo_Fixed;580 if (aWidth != 0 && aHeight != 0)581 m_desktopGeometry = QSize(aWidth, aHeight);582 else583 m_desktopGeometry = QSize(0, 0);584 storeConsoleSize(0, 0);585 break;586 case DesktopGeo_Automatic:587 m_desktopGeometryType = DesktopGeo_Automatic;588 m_desktopGeometry = QSize(0, 0);589 storeConsoleSize(0, 0);590 break;591 case DesktopGeo_Any:592 m_desktopGeometryType = DesktopGeo_Any;593 m_desktopGeometry = QSize(0, 0);594 break;595 default:596 AssertMsgFailed(("Invalid desktop geometry type %d\n", geometry));597 m_desktopGeometryType = DesktopGeo_Invalid;598 }599 }600 601 void UIMachineView::calculateDesktopGeometry()602 {603 /* This method should not get called until we have initially set up the m_desktopGeometryType: */604 Assert((m_desktopGeometryType != DesktopGeo_Invalid));605 /* If we are not doing automatic geometry calculation then there is nothing to do: */606 if (DesktopGeo_Automatic == m_desktopGeometryType)607 {608 /* Available geometry of the desktop. If the desktop is a single609 * screen, this will exclude space taken up by desktop taskbars610 * and things, but this is unfortunately not true for the more611 * complex case of a desktop spanning multiple screens: */612 QRect desktop = availableGeometry();613 /* The area taken up by the machine window on the desktop,614 * including window frame, title and menu bar and whatnot: */615 QRect frame = machineWindowWrapper()->machineWindow()->frameGeometry();616 /* The area taken up by the machine view, so excluding all decorations: */617 QRect window = geometry();618 /* To work out how big we can make the console window while still619 * fitting on the desktop, we calculate desktop - frame + window.620 * This works because the difference between frame and window621 * (or at least its width and height) is a constant. */622 m_desktopGeometry = QSize(desktop.width() - frame.width() + window.width(),623 desktop.height() - frame.height() + window.height());624 }625 }626 627 void UIMachineView::storeConsoleSize(int iWidth, int iHeight)628 {629 m_storedConsoleSize = QSize(iWidth, iHeight);630 }631 632 633 632 void UIMachineView::cleanupCommon() 634 633 { … … 671 670 /* Detach framebuffer from Display: */ 672 671 CDisplay display = session().GetConsole().GetDisplay(); 673 display.SetFramebuffer( VBOX_VIDEO_PRIMARY_SCREEN, CFramebuffer(NULL));672 display.SetFramebuffer(m_uScreenId, CFramebuffer(NULL)); 674 673 /* Release the reference: */ 675 674 m_pFrameBuffer->Release(); … … 695 694 else 696 695 { 697 /* Release the host key and all other pressed keys too even when paused (otherwise, we will get stuck 698 * keys in the guest when doing sendChangedKeyStates() on resume because key presses were already 699 * recorded in m_pressedKeys but key releases will most likely not reach us but the new focus window instead): */ 700 releaseAllPressedKeys(true /* fReleaseHostKey */); 696 /* Release the host key and all other pressed keys too even when paused 697 * (otherwise, we will get stuck keys in the guest when doing sendChangedKeyStates() on resume 698 * because key presses were already recorded in m_pressedKeys but key releases will most likely 699 * not reach us but the new focus window instead): */ 700 releaseAllPressedKeys(true /* including host key? */); 701 701 } 702 702 break; … … 708 708 viewport()->repaint(pPaintEvent->x() - contentsX(), pPaintEvent->y() - contentsY(), 709 709 pPaintEvent->width(), pPaintEvent->height()); 710 /* session().GetConsole().GetDisplay().UpdateCompleted(); - the event was acked already */711 710 return true; 712 711 } … … 855 854 { 856 855 /* Process hot keys not processed in keyEvent() (as in case of non-alphanumeric keys): */ 857 machineWindowWrapper()->machineLogic()->actionsPool()->processHotKey(QKeySequence 856 machineWindowWrapper()->machineLogic()->actionsPool()->processHotKey(QKeySequence(pKeyEvent->key())); 858 857 } 859 858 } … … 955 954 * registered in the VM. Only do this if the keyboard/mouse is grabbed (this is when 956 955 * we have a valid event handler): */ 957 setMouseCoalescingEnabled 956 setMouseCoalescingEnabled(false); 958 957 break; 959 958 } … … 1497 1496 if (aWheelDir == Qt::Vertical) 1498 1497 { 1499 /* the absolute value of wheel delta is 120 units per every wheel1500 * move; positive deltas correspond to counterclockwize rotations1501 * (usually up), negative --to clockwize (usually down). */1498 /* The absolute value of wheel delta is 120 units per every wheel move; 1499 * positive deltas correspond to counterclockwize rotations (usually up), 1500 * negative deltas correspond to clockwize (usually down). */ 1502 1501 wheelVertical = - (aWheelDelta / 120); 1503 1502 } … … 1508 1507 { 1509 1508 #ifdef Q_WS_WIN32 1510 /* send pending WM_PAINT events*/1509 /* Send pending WM_PAINT events: */ 1511 1510 ::UpdateWindow(viewport()->winId()); 1512 1511 #endif … … 1639 1638 /* Try to automatically scroll the guest canvas if the 1640 1639 * mouse goes outside its visible part: */ 1641 1642 1640 int dx = 0; 1643 1641 if (aPos.x() > vw) dx = aPos.x() - vw; … … 1649 1647 } 1650 1648 1651 QPoint cpnt = viewportToContents (aPos); 1652 if (cpnt.x() < 0) cpnt.setX (0); 1653 else if (cpnt.x() > cw) cpnt.setX (cw); 1654 if (cpnt.y() < 0) cpnt.setY (0); 1655 else if (cpnt.y() > ch) cpnt.setY (ch); 1649 QPoint cpnt = viewportToContents(aPos); 1650 if (cpnt.x() < 0) cpnt.setX(0); 1651 else if (cpnt.x() > cw) cpnt.setX(cw); 1652 if (cpnt.y() < 0) cpnt.setY(0); 1653 else if (cpnt.y() > ch) cpnt.setY(ch); 1654 1655 // TODO: Where to put that actually? 1656 /* Get & Setup absolute-event shift: */ 1657 CFramebuffer framebuffer; 1658 LONG xShift = 0, yShift = 0; 1659 session().GetConsole().GetDisplay().GetFramebuffer(screenId(), framebuffer, xShift, yShift); 1660 cpnt.setX(cpnt.x() + xShift); 1661 cpnt.setY(cpnt.y() + yShift); 1656 1662 1657 1663 CMouse mouse = session().GetConsole().GetMouse(); 1658 mouse.PutMouseEventAbsolute (cpnt.x(), cpnt.y(), wheelVertical,1659 1664 // AssertMsgFailed(("x=%d, y=%d", cpnt.x(), cpnt.y())); // this shows what absolute coordinates are correct! 1665 mouse.PutMouseEventAbsolute(cpnt.x(), cpnt.y(), wheelVertical, wheelHorizontal, state); 1660 1666 return true; 1661 1667 } … … 1674 1680 m_bIsAutoCaptureDisabled = true; 1675 1681 bool autoConfirmed = false; 1676 bool ok = vboxProblem().confirmInputCapture 1682 bool ok = vboxProblem().confirmInputCapture(&autoConfirmed); 1677 1683 if (autoConfirmed) 1678 1684 m_bIsAutoCaptureDisabled = false; … … 1742 1748 #endif 1743 1749 // { 1744 // /* We have a snapshot for the paused state: */ 1745 // QRect r = pPaintEvent->rect().intersect (viewport()->rect()); 1746 // /* We have to disable paint on screen if we are using the regular painter */ 1747 // bool paintOnScreen = viewport()->testAttribute(Qt::WA_PaintOnScreen); 1748 // viewport()->setAttribute(Qt::WA_PaintOnScreen, false); 1749 // QPainter pnt(viewport()); 1750 // pnt.drawPixmap(r.x(), r.y(), m_pauseShot, r.x() + contentsX(), r.y() + contentsY(), r.width(), r.height()); 1751 // /* Restore the attribute to its previous state */ 1752 // viewport()->setAttribute(Qt::WA_PaintOnScreen, paintOnScreen); 1750 #if 0 // TODO: Paint pause-shot on screen during pause! 1751 /* We have a snapshot for the paused state: */ 1752 QRect r = pPaintEvent->rect().intersect(viewport()->rect()); 1753 /* We have to disable paint on screen if we are using the regular painter: */ 1754 bool paintOnScreen = viewport()->testAttribute(Qt::WA_PaintOnScreen); 1755 viewport()->setAttribute(Qt::WA_PaintOnScreen, false); 1756 QPainter pnt(viewport()); 1757 pnt.drawPixmap(r.x(), r.y(), m_pauseShot, r.x() + contentsX(), r.y() + contentsY(), r.width(), r.height()); 1758 /* Restore the attribute to its previous state: */ 1759 viewport()->setAttribute(Qt::WA_PaintOnScreen, paintOnScreen); 1760 #endif 1753 1761 #ifdef Q_WS_MAC 1754 1762 // updateDockIcon(); … … 2370 2378 QPoint UIMachineView::viewportToContents(const QPoint &vp) const 2371 2379 { 2372 return QPoint 2380 return QPoint(vp.x() + contentsX(), vp.y() + contentsY()); 2373 2381 } 2374 2382 … … 2452 2460 m_capturedMousePos = QCursor::pos(); 2453 2461 #ifdef Q_WS_WIN32 2454 viewport()->setCursor (QCursor(Qt::BlankCursor));2462 viewport()->setCursor(QCursor(Qt::BlankCursor)); 2455 2463 /* Move the mouse to the center of the visible area: */ 2456 QCursor::setPos (mapToGlobal(visibleRegion().boundingRect().center()));2464 QCursor::setPos(mapToGlobal(visibleRegion().boundingRect().center())); 2457 2465 m_lastMousePos = QCursor::pos(); 2458 2466 #elif defined (Q_WS_MAC) 2459 2467 /* Move the mouse to the center of the visible area: */ 2460 2468 m_lastMousePos = mapToGlobal (visibleRegion().boundingRect().center()); 2461 QCursor::setPos 2469 QCursor::setPos(m_lastMousePos); 2462 2470 /* Grab all mouse events: */ 2463 2471 viewport()->grabMouse(); … … 2474 2482 /* Release mouse buttons: */ 2475 2483 CMouse mouse = session().GetConsole().GetMouse(); 2476 mouse.PutMouseEvent(0, 0, 0, 0 /* Horizontal wheel */, 0);2484 mouse.PutMouseEvent(0, 0, 0, 0, 0); 2477 2485 } 2478 2486 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r26921 r26929 118 118 bool isFrameBufferResizeIgnored() const { return m_bIsFrameBufferResizeIgnored; } 119 119 const QPixmap& pauseShot() const { return m_pauseShot; } 120 void calculateDesktopGeometry();121 120 virtual QSize desktopGeometry() const; 121 122 /* Protected setters: */ 122 123 void setDesktopGeometry(DesktopGeo geometry, int iWidth, int iHeight); 123 124 void storeConsoleSize(int iWidth, int iHeight); 124 125 /* Protected setters: */126 125 void setMachineWindowResizeIgnored(bool fIgnore = true) { m_bIsMachineWindowResizeIgnored = fIgnore; } 127 126 void setFrameBufferResizeIgnored(bool fIgnore = true) { m_bIsFrameBufferResizeIgnored = fIgnore; } 128 127 129 128 /* Protected helpers: */ 129 void calculateDesktopGeometry(); 130 130 void updateMouseClipping(); 131 131 void updateSliders();
Note:
See TracChangeset
for help on using the changeset viewer.