Changeset 77724 in vbox for trunk/src/VBox
- Timestamp:
- Mar 15, 2019 1:21:41 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp
r77703 r77724 25 25 #include "UIActionPool.h" 26 26 #include "UIActionPoolRuntime.h" 27 #include "UIConsoleEventHandler.h" 27 28 #include "UIFrameBuffer.h" 28 29 #include "UISession.h" … … 273 274 virtual void viewportScrolled(int, int) {} 274 275 #endif /* VBOX_WITH_VIDEOHWACCEL */ 276 277 protected slots: 278 279 /** Handles guest request to change the cursor position to @a uX * @a uY. 280 * @param fContainsData Brings whether the @a uX and @a uY values are valid and could be used by the GUI now. */ 281 void sltCursorPositionChange(bool fContainsData, unsigned long uX, unsigned long uY); 275 282 276 283 protected: … … 388 395 /** Identifier returned by AttachFramebuffer. Used in DetachFramebuffer. */ 389 396 QUuid m_uFramebufferId; 397 398 /** Holds whether cursor position is valid. */ 399 bool m_fCursorPositionValid; 400 /** Holds the last cursor rectangle. */ 401 QRect m_cursorRectangle; 390 402 }; 391 403 … … 530 542 , m_dDevicePixelRatioActual(1.0) 531 543 , m_fUseUnscaledHiDPIOutput(false) 544 , m_fCursorPositionValid(false) 532 545 { 533 546 /* Update coordinate-system: */ … … 1290 1303 } 1291 1304 1305 void UIFrameBufferPrivate::sltCursorPositionChange(bool fContainsData, unsigned long uX, unsigned long uY) 1306 { 1307 /* Remember whether cursor position is valid: */ 1308 m_fCursorPositionValid = fContainsData; 1309 1310 /* Do we have view and valid cursor position? */ 1311 if (m_pMachineView && m_fCursorPositionValid) 1312 { 1313 /* Acquire cursor position and size: */ 1314 QPoint cursorPosition = QPoint(uX, uY); 1315 QSize cursorSize = m_pMachineView->uisession()->cursorSize(); 1316 1317 /* Apply the scale-factor if necessary: */ 1318 cursorPosition *= scaleFactor(); 1319 cursorSize *= scaleFactor(); 1320 1321 /* Take the device-pixel-ratio into account: */ 1322 if (!useUnscaledHiDPIOutput()) 1323 { 1324 cursorPosition *= devicePixelRatioActual(); 1325 cursorSize *= devicePixelRatioActual(); 1326 } 1327 cursorPosition /= devicePixelRatio(); 1328 cursorSize /= devicePixelRatio(); 1329 1330 /* Call for a viewport update, we need to update cumulative 1331 * region containing previous and current cursor rectagles. */ 1332 const QRect cursorRectangle = QRect(cursorPosition, cursorSize); 1333 m_pMachineView->viewport()->update(QRegion(m_cursorRectangle) + cursorRectangle); 1334 1335 /* Remember current cursor rectangle: */ 1336 m_cursorRectangle = cursorRectangle; 1337 } 1338 } 1339 1292 1340 void UIFrameBufferPrivate::prepareConnections() 1293 1341 { … … 1305 1353 m_pMachineView, SLOT(sltHandle3DOverlayVisibilityChange(bool)), 1306 1354 Qt::QueuedConnection); 1355 1356 /* Attach GUI connections: */ 1357 connect(gConsoleEvents, &UIConsoleEventHandler::sigCursorPositionChange, 1358 this, &UIFrameBufferPrivate::sltCursorPositionChange); 1307 1359 } 1308 1360 … … 1318 1370 disconnect(this, SIGNAL(sigNotifyAbout3DOverlayVisibilityChange(bool)), 1319 1371 m_pMachineView, SLOT(sltHandle3DOverlayVisibilityChange(bool))); 1372 1373 /* Detach GUI connections: */ 1374 disconnect(gConsoleEvents, &UIConsoleEventHandler::sigCursorPositionChange, 1375 this, &UIFrameBufferPrivate::sltCursorPositionChange); 1320 1376 } 1321 1377 … … 1407 1463 pSourceImage = 0; 1408 1464 } 1465 1466 /* Paint cursor if it has valid shape and position: */ 1467 if (m_pMachineView->uisession()->isValidPointerShapePresent() && m_fCursorPositionValid) 1468 { 1469 /* Acquire session cursor pixmap: */ 1470 QPixmap cursorPixmap = m_pMachineView->uisession()->cursorPixmap(); 1471 1472 /* Take the device-pixel-ratio into account: */ 1473 cursorPixmap.setDevicePixelRatio(devicePixelRatio()); 1474 1475 /* Draw sub-pixmap: */ 1476 painter.drawPixmap(m_cursorRectangle.topLeft(), cursorPixmap); 1477 } 1409 1478 } 1410 1479 … … 1497 1566 pSourceImage = 0; 1498 1567 } 1568 1569 /* Paint cursor if it has valid shape and position: */ 1570 if (m_pMachineView->uisession()->isValidPointerShapePresent() && m_fCursorPositionValid) 1571 { 1572 /* Acquire session cursor pixmap: */ 1573 QPixmap cursorPixmap = m_pMachineView->uisession()->cursorPixmap(); 1574 1575 /* Take the device-pixel-ratio into account: */ 1576 cursorPixmap.setDevicePixelRatio(devicePixelRatio()); 1577 1578 /* Draw sub-pixmap: */ 1579 painter.drawPixmap(m_cursorRectangle.topLeft(), cursorPixmap); 1580 } 1499 1581 } 1500 1582 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r76613 r77724 628 628 /* Notify listeners about mouse capability changed: */ 629 629 emit sigMousePointerShapeChange(); 630 631 630 } 632 631 … … 1831 1830 1832 1831 #endif 1832 1833 /* Cache cursor pixmap data: */ 1834 m_cursorPixmap = m_cursor.pixmap(); 1835 m_cursorSize = m_cursorPixmap.size(); 1833 1836 } 1834 1837 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r76581 r77724 27 27 #include <QEvent> 28 28 #include <QMap> 29 #include <QPixmap> 29 30 30 31 /* GUI includes: */ … … 132 133 WId mainMachineWindowId() const; 133 134 UIMachineWindow *activeMachineWindow() const; 135 136 /** Returns currently cached mouse cursor. */ 134 137 QCursor cursor() const { return m_cursor; } 138 /** Returns currently cached mouse cursor pixmap. */ 139 QPixmap cursorPixmap() const { return m_cursorPixmap; } 140 /** Returns currently cached mouse cursor size. */ 141 QSize cursorSize() const { return m_cursorSize; } 135 142 136 143 /** @name Branding stuff. … … 476 483 KMachineState m_machineStatePrevious; 477 484 KMachineState m_machineState; 478 QCursor m_cursor; 485 486 /** Holds cached mouse cursor. */ 487 QCursor m_cursor; 488 /** Holds cached mouse cursor pixmap. */ 489 QPixmap m_cursorPixmap; 490 /** Holds cached mouse cursor size. */ 491 QSize m_cursorSize; 479 492 480 493 /** @name Branding variables.
Note:
See TracChangeset
for help on using the changeset viewer.