Changeset 98037 in vbox
- Timestamp:
- Jan 10, 2023 11:04:46 AM (23 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r97551 r98037 2770 2770 } 2771 2771 2772 #ifdef VBOX_WITH_DEBUGGER_GUI 2773 void UIMachineLogic::dbgAdjustRelativePos() 2774 { 2775 if (m_pDbgGui) 2776 { 2777 const QRect rct = activeMachineWindow()->frameGeometry(); 2778 m_pDbgGuiVT->pfnAdjustRelativePos(m_pDbgGui, rct.x(), rct.y(), rct.width(), rct.height()); 2779 } 2780 } 2781 #endif /* VBOX_WITH_DEBUGGER_GUI */ 2782 2772 2783 void UIMachineLogic::updateMenuDevicesStorage(QMenu *pMenu) 2773 2784 { … … 3363 3374 } 3364 3375 } 3365 3366 void UIMachineLogic::dbgAdjustRelativePos()3367 {3368 if (m_pDbgGui)3369 {3370 QRect rct = activeMachineWindow()->frameGeometry();3371 m_pDbgGuiVT->pfnAdjustRelativePos(m_pDbgGui, rct.x(), rct.y(), rct.width(), rct.height());3372 }3373 }3374 3376 #endif /* VBOX_WITH_DEBUGGER_GUI */ 3375 3377 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r97514 r98037 156 156 void typeHostKeyComboPressRelease(bool fToggleSequence); 157 157 158 #ifdef VBOX_WITH_DEBUGGER_GUI 159 /** Adjusts relative position for debugger window. */ 160 void dbgAdjustRelativePos(); 161 #endif /* VBOX_WITH_DEBUGGER_GUI */ 162 158 163 protected slots: 159 164 … … 421 426 bool dbgCreated(); 422 427 void dbgDestroy(); 423 void dbgAdjustRelativePos();424 428 /* The handle to the debugger GUI: */ 425 429 PDBGGUI m_pDbgGui; … … 459 463 QVector<X11ScreenSaverInhibitMethod*> m_methods; 460 464 #endif 461 /* Friend classes: */462 friend class UIMachineWindow;463 465 }; 464 466 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r97998 r98037 261 261 } 262 262 263 UISession *UIMachineView::uisession() const 264 { 265 return machineWindow()->uisession(); 266 } 267 268 UIMachineLogic *UIMachineView::machineLogic() const 269 { 270 return machineWindow()->machineLogic(); 271 } 272 273 int UIMachineView::contentsWidth() const 274 { 275 return frameBuffer()->width(); 276 } 277 278 int UIMachineView::contentsHeight() const 279 { 280 return frameBuffer()->height(); 281 } 282 283 int UIMachineView::contentsX() const 284 { 285 return horizontalScrollBar()->value(); 286 } 287 288 int UIMachineView::contentsY() const 289 { 290 return verticalScrollBar()->value(); 291 } 292 293 int UIMachineView::visibleWidth() const 294 { 295 return horizontalScrollBar()->pageStep(); 296 } 297 298 int UIMachineView::visibleHeight() const 299 { 300 return verticalScrollBar()->pageStep(); 301 } 302 303 QPoint UIMachineView::viewportToContents(const QPoint &viewportPoint) const 304 { 305 /* Get physical contents shifts of scroll-bars: */ 306 int iContentsX = contentsX(); 307 int iContentsY = contentsY(); 308 309 /* Take the device-pixel-ratio into account: */ 310 const double dDevicePixelRatioFormal = frameBuffer()->devicePixelRatio(); 311 const double dDevicePixelRatioActual = frameBuffer()->devicePixelRatioActual(); 312 if (!frameBuffer()->useUnscaledHiDPIOutput()) 313 { 314 iContentsX *= dDevicePixelRatioActual; 315 iContentsY *= dDevicePixelRatioActual; 316 } 317 iContentsX /= dDevicePixelRatioFormal; 318 iContentsY /= dDevicePixelRatioFormal; 319 320 /* Return point shifted according scroll-bars: */ 321 return QPoint(viewportPoint.x() + iContentsX, viewportPoint.y() + iContentsY); 322 } 323 324 void UIMachineView::scrollBy(int iDx, int iDy) 325 { 326 horizontalScrollBar()->setValue(horizontalScrollBar()->value() + iDx); 327 verticalScrollBar()->setValue(verticalScrollBar()->value() + iDy); 328 } 329 330 UIVisualStateType UIMachineView::visualStateType() const 331 { 332 return machineLogic()->visualStateType(); 333 } 334 263 335 double UIMachineView::aspectRatio() const 264 336 { … … 266 338 } 267 339 340 void UIMachineView::setMaximumGuestSize(const QSize &minimumSizeHint /* = QSize() */) 341 { 342 QSize maxSize; 343 switch (m_enmMaximumGuestScreenSizePolicy) 344 { 345 case MaximumGuestScreenSizePolicy_Fixed: 346 maxSize = m_fixedMaxGuestSize; 347 break; 348 case MaximumGuestScreenSizePolicy_Automatic: 349 maxSize = calculateMaxGuestSize().expandedTo(minimumSizeHint); 350 break; 351 case MaximumGuestScreenSizePolicy_Any: 352 /* (0, 0) means any of course. */ 353 maxSize = QSize(0, 0); 354 } 355 ASMAtomicWriteU64(&m_u64MaximumGuestSize, 356 RT_MAKE_U64(maxSize.height(), maxSize.width())); 357 } 358 359 QSize UIMachineView::maximumGuestSize() 360 { 361 uint64_t u64Size = ASMAtomicReadU64(&m_u64MaximumGuestSize); 362 return QSize(int(RT_HI_U32(u64Size)), int(RT_LO_U32(u64Size))); 363 } 364 268 365 void UIMachineView::updateViewport() 269 366 { 270 367 display().ViewportChanged(screenId(), contentsX(), contentsY(), visibleWidth(), visibleHeight()); 368 } 369 370 #ifdef VBOX_WITH_DRAG_AND_DROP 371 int UIMachineView::dragCheckPending() 372 { 373 int rc; 374 375 if (!dragAndDropIsActive()) 376 rc = VERR_ACCESS_DENIED; 377 # ifdef VBOX_WITH_DRAG_AND_DROP_GH 378 else if (!m_fIsDraggingFromGuest) 379 { 380 /// @todo Add guest->guest DnD functionality here by getting 381 // the source of guest B (when copying from B to A). 382 rc = m_pDnDHandler->dragCheckPending(screenId()); 383 if (RT_SUCCESS(rc)) 384 m_fIsDraggingFromGuest = true; 385 } 386 else /* Already dragging, so report success. */ 387 rc = VINF_SUCCESS; 388 # else 389 rc = VERR_NOT_SUPPORTED; 390 # endif 391 392 DNDDEBUG(("DnD: dragCheckPending ended with rc=%Rrc\n", rc)); 393 return rc; 394 } 395 396 int UIMachineView::dragStart() 397 { 398 int rc; 399 400 if (!dragAndDropIsActive()) 401 rc = VERR_ACCESS_DENIED; 402 # ifdef VBOX_WITH_DRAG_AND_DROP_GH 403 else if (!m_fIsDraggingFromGuest) 404 rc = VERR_WRONG_ORDER; 405 else 406 { 407 /// @todo Add guest->guest DnD functionality here by getting 408 // the source of guest B (when copying from B to A). 409 rc = m_pDnDHandler->dragStart(screenId()); 410 411 m_fIsDraggingFromGuest = false; 412 } 413 # else 414 rc = VERR_NOT_SUPPORTED; 415 # endif 416 417 DNDDEBUG(("DnD: dragStart ended with rc=%Rrc\n", rc)); 418 return rc; 419 } 420 421 int UIMachineView::dragStop() 422 { 423 int rc; 424 425 if (!dragAndDropIsActive()) 426 rc = VERR_ACCESS_DENIED; 427 # ifdef VBOX_WITH_DRAG_AND_DROP_GH 428 else if (!m_fIsDraggingFromGuest) 429 rc = VERR_WRONG_ORDER; 430 else 431 rc = m_pDnDHandler->dragStop(screenId()); 432 # else 433 rc = VERR_NOT_SUPPORTED; 434 # endif 435 436 DNDDEBUG(("DnD: dragStop ended with rc=%Rrc\n", rc)); 437 return rc; 438 } 439 #endif /* VBOX_WITH_DRAG_AND_DROP */ 440 441 bool UIMachineView::nativeEventPreprocessor(const QByteArray &eventType, void *pMessage) 442 { 443 /* Check if some event should be filtered out. 444 * Returning @c true means filtering-out, 445 * Returning @c false means passing event to Qt. */ 446 447 # if defined(VBOX_WS_MAC) 448 449 /* Make sure it's generic NSEvent: */ 450 if (eventType != "mac_generic_NSEvent") 451 return false; 452 EventRef event = static_cast<EventRef>(darwinCocoaToCarbonEvent(pMessage)); 453 454 switch (::GetEventClass(event)) 455 { 456 // Keep in mind that this stuff should not be enabled while we are still using 457 // own native keyboard filter installed through cocoa API, to be reworked. 458 // S.a. registerForNativeEvents call in UIKeyboardHandler implementation. 459 #if 0 460 /* Watch for keyboard-events: */ 461 case kEventClassKeyboard: 462 { 463 switch (::GetEventKind(event)) 464 { 465 /* Watch for key-events: */ 466 case kEventRawKeyDown: 467 case kEventRawKeyRepeat: 468 case kEventRawKeyUp: 469 case kEventRawKeyModifiersChanged: 470 { 471 /* Delegate key-event handling to the keyboard-handler: */ 472 return machineLogic()->keyboardHandler()->nativeEventFilter(pMessage, screenId()); 473 } 474 default: 475 break; 476 } 477 break; 478 } 479 #endif 480 /* Watch for mouse-events: */ 481 case kEventClassMouse: 482 { 483 switch (::GetEventKind(event)) 484 { 485 /* Watch for button-events: */ 486 case kEventMouseDown: 487 case kEventMouseUp: 488 { 489 /* Delegate button-event handling to the mouse-handler: */ 490 return machineLogic()->mouseHandler()->nativeEventFilter(pMessage, screenId()); 491 } 492 default: 493 break; 494 } 495 break; 496 } 497 default: 498 break; 499 } 500 501 # elif defined(VBOX_WS_WIN) 502 503 /* Make sure it's generic MSG event: */ 504 if (eventType != "windows_generic_MSG") 505 return false; 506 MSG *pEvent = static_cast<MSG*>(pMessage); 507 508 switch (pEvent->message) 509 { 510 /* Watch for key-events: */ 511 case WM_KEYDOWN: 512 case WM_SYSKEYDOWN: 513 case WM_KEYUP: 514 case WM_SYSKEYUP: 515 { 516 // WORKAROUND: 517 // There is an issue in the Windows Qt5 event processing sequence 518 // causing QAbstractNativeEventFilter to receive Windows native events 519 // coming not just to the top-level window but to actual target as well. 520 // They are calling one - "global event" and another one - "context event". 521 // That way native events are always duplicated with almost no possibility 522 // to distinguish copies except the fact that synthetic event always have 523 // time set to 0 (actually that field was not initialized at all, we had 524 // fixed that in our private Qt tool). We should skip such events instantly. 525 if (pEvent->time == 0) 526 return false; 527 528 /* Delegate key-event handling to the keyboard-handler: */ 529 return machineLogic()->keyboardHandler()->nativeEventFilter(pMessage, screenId()); 530 } 531 default: 532 break; 533 } 534 535 # elif defined(VBOX_WS_X11) 536 537 /* Make sure it's generic XCB event: */ 538 if (eventType != "xcb_generic_event_t") 539 return false; 540 xcb_generic_event_t *pEvent = static_cast<xcb_generic_event_t*>(pMessage); 541 542 switch (pEvent->response_type & ~0x80) 543 { 544 /* Watch for key-events: */ 545 case XCB_KEY_PRESS: 546 case XCB_KEY_RELEASE: 547 { 548 /* Delegate key-event handling to the keyboard-handler: */ 549 return machineLogic()->keyboardHandler()->nativeEventFilter(pMessage, screenId()); 550 } 551 /* Watch for button-events: */ 552 case XCB_BUTTON_PRESS: 553 case XCB_BUTTON_RELEASE: 554 { 555 /* Delegate button-event handling to the mouse-handler: */ 556 return machineLogic()->mouseHandler()->nativeEventFilter(pMessage, screenId()); 557 } 558 default: 559 break; 560 } 561 562 # else 563 564 # warning "port me!" 565 566 # endif 567 568 /* Filter nothing by default: */ 569 return false; 570 } 571 572 void UIMachineView::sltHandleNotifyChange(int iWidth, int iHeight) 573 { 574 /* Sanity check: */ 575 if (!frameBuffer()) 576 return; 577 578 LogRel2(("GUI: UIMachineView::sltHandleNotifyChange: Screen=%d, Size=%dx%d\n", 579 (unsigned long)m_uScreenId, iWidth, iHeight)); 580 581 /* Some situations require frame-buffer resize-events to be ignored at all, 582 * leaving machine-window, machine-view and frame-buffer sizes preserved: */ 583 if (uisession()->isGuestResizeIgnored()) 584 return; 585 586 /* In some situations especially in some VM states, guest-screen is not drawable: */ 587 if (uisession()->isGuestScreenUnDrawable()) 588 return; 589 590 /* Get old frame-buffer size: */ 591 const QSize frameBufferSizeOld = QSize(frameBuffer()->width(), 592 frameBuffer()->height()); 593 594 /* Perform frame-buffer mode-change: */ 595 frameBuffer()->handleNotifyChange(iWidth, iHeight); 596 597 /* Get new frame-buffer size: */ 598 const QSize frameBufferSizeNew = QSize(frameBuffer()->width(), 599 frameBuffer()->height()); 600 601 /* For 'scale' mode: */ 602 if (visualStateType() == UIVisualStateType_Scale) 603 { 604 /* Assign new frame-buffer logical-size: */ 605 QSize scaledSize = size(); 606 const double dDevicePixelRatioFormal = frameBuffer()->devicePixelRatio(); 607 const double dDevicePixelRatioActual = frameBuffer()->devicePixelRatioActual(); 608 scaledSize *= dDevicePixelRatioFormal; 609 if (!frameBuffer()->useUnscaledHiDPIOutput()) 610 scaledSize /= dDevicePixelRatioActual; 611 frameBuffer()->setScaledSize(scaledSize); 612 613 /* Forget the last full-screen size: */ 614 uisession()->setLastFullScreenSize(screenId(), QSize(-1, -1)); 615 } 616 /* For other than 'scale' mode: */ 617 else 618 { 619 /* Adjust maximum-size restriction for machine-view: */ 620 setMaximumSize(sizeHint()); 621 622 /* Disable the resize hint override hack and forget the last full-screen size: */ 623 m_sizeHintOverride = QSize(-1, -1); 624 if (visualStateType() == UIVisualStateType_Normal) 625 uisession()->setLastFullScreenSize(screenId(), QSize(-1, -1)); 626 627 /* Force machine-window update own layout: */ 628 QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest); 629 630 /* Update machine-view sliders: */ 631 updateSliders(); 632 633 /* By some reason Win host forgets to update machine-window central-widget 634 * after main-layout was updated, let's do it for all the hosts: */ 635 machineWindow()->centralWidget()->update(); 636 637 /* Normalize 'normal' machine-window geometry if necessary: */ 638 if (visualStateType() == UIVisualStateType_Normal && 639 frameBufferSizeNew != frameBufferSizeOld) 640 machineWindow()->normalizeGeometry(true /* adjust position */, machineWindow()->shouldResizeToGuestDisplay()); 641 } 642 643 /* Perform frame-buffer rescaling: */ 644 frameBuffer()->performRescale(); 645 646 #ifdef VBOX_WS_MAC 647 /* Update MacOS X dock icon size: */ 648 machineLogic()->updateDockIconSize(screenId(), frameBufferSizeNew.width(), frameBufferSizeNew.height()); 649 #endif /* VBOX_WS_MAC */ 650 651 /* Notify frame-buffer resize: */ 652 emit sigFrameBufferResize(); 653 654 /* Ask for just required guest display update (it will also update 655 * the viewport through IFramebuffer::NotifyUpdate): */ 656 display().InvalidateAndUpdateScreen(m_uScreenId); 657 658 /* If we are in normal or scaled mode and if GA are active, 659 * remember the guest-screen size to be able to restore it when necessary: */ 660 /* As machines with Linux/Solaris and VMSVGA are not able to tell us 661 * whether a resize was due to the system or user interaction we currently 662 * do not store hints for these systems except when we explicitly send them 663 * ourselves. Windows guests should use VBoxVGA controllers, not VMSVGA. */ 664 if ( !isFullscreenOrSeamless() 665 && uisession()->isGuestSupportsGraphics() 666 && (machine().GetGraphicsAdapter().GetGraphicsControllerType() != KGraphicsControllerType_VMSVGA)) 667 setStoredGuestScreenSizeHint(frameBufferSizeNew); 668 669 LogRel2(("GUI: UIMachineView::sltHandleNotifyChange: Complete for Screen=%d, Size=%dx%d\n", 670 (unsigned long)m_uScreenId, frameBufferSizeNew.width(), frameBufferSizeNew.height())); 671 } 672 673 void UIMachineView::sltHandleNotifyUpdate(int iX, int iY, int iWidth, int iHeight) 674 { 675 /* Sanity check: */ 676 if (!frameBuffer()) 677 return; 678 679 /* Prepare corresponding viewport part: */ 680 QRect rect(iX, iY, iWidth, iHeight); 681 682 /* Take the scaling into account: */ 683 const double dScaleFactor = frameBuffer()->scaleFactor(); 684 const QSize scaledSize = frameBuffer()->scaledSize(); 685 if (scaledSize.isValid()) 686 { 687 /* Calculate corresponding scale-factors: */ 688 const double xScaleFactor = visualStateType() == UIVisualStateType_Scale ? 689 (double)scaledSize.width() / frameBuffer()->width() : dScaleFactor; 690 const double yScaleFactor = visualStateType() == UIVisualStateType_Scale ? 691 (double)scaledSize.height() / frameBuffer()->height() : dScaleFactor; 692 /* Adjust corresponding viewport part: */ 693 rect.moveTo((int)floor((double)rect.x() * xScaleFactor) - 1, 694 (int)floor((double)rect.y() * yScaleFactor) - 1); 695 rect.setSize(QSize((int)ceil((double)rect.width() * xScaleFactor) + 2, 696 (int)ceil((double)rect.height() * yScaleFactor) + 2)); 697 } 698 699 /* Shift has to be scaled by the device-pixel-ratio 700 * but not scaled by the scale-factor. */ 701 rect.translate(-contentsX(), -contentsY()); 702 703 /* Take the device-pixel-ratio into account: */ 704 const double dDevicePixelRatioFormal = frameBuffer()->devicePixelRatio(); 705 const double dDevicePixelRatioActual = frameBuffer()->devicePixelRatioActual(); 706 if (!frameBuffer()->useUnscaledHiDPIOutput() && dDevicePixelRatioActual != 1.0) 707 { 708 rect.moveTo((int)floor((double)rect.x() * dDevicePixelRatioActual) - 1, 709 (int)floor((double)rect.y() * dDevicePixelRatioActual) - 1); 710 rect.setSize(QSize((int)ceil((double)rect.width() * dDevicePixelRatioActual) + 2, 711 (int)ceil((double)rect.height() * dDevicePixelRatioActual) + 2)); 712 } 713 if (dDevicePixelRatioFormal != 1.0) 714 { 715 rect.moveTo((int)floor((double)rect.x() / dDevicePixelRatioFormal) - 1, 716 (int)floor((double)rect.y() / dDevicePixelRatioFormal) - 1); 717 rect.setSize(QSize((int)ceil((double)rect.width() / dDevicePixelRatioFormal) + 2, 718 (int)ceil((double)rect.height() / dDevicePixelRatioFormal) + 2)); 719 } 720 721 /* Limit the resulting part by the viewport rectangle: */ 722 rect &= viewport()->rect(); 723 724 /* Update corresponding viewport part: */ 725 viewport()->update(rect); 726 } 727 728 void UIMachineView::sltHandleSetVisibleRegion(QRegion region) 729 { 730 /* Used only in seamless-mode. */ 731 Q_UNUSED(region); 271 732 } 272 733 … … 505 966 } 506 967 507 void UIMachineView::sltHandleNotifyChange(int iWidth, int iHeight)508 {509 /* Sanity check: */510 if (!frameBuffer())511 return;512 513 LogRel2(("GUI: UIMachineView::sltHandleNotifyChange: Screen=%d, Size=%dx%d\n",514 (unsigned long)m_uScreenId, iWidth, iHeight));515 516 /* Some situations require frame-buffer resize-events to be ignored at all,517 * leaving machine-window, machine-view and frame-buffer sizes preserved: */518 if (uisession()->isGuestResizeIgnored())519 return;520 521 /* In some situations especially in some VM states, guest-screen is not drawable: */522 if (uisession()->isGuestScreenUnDrawable())523 return;524 525 /* Get old frame-buffer size: */526 const QSize frameBufferSizeOld = QSize(frameBuffer()->width(),527 frameBuffer()->height());528 529 /* Perform frame-buffer mode-change: */530 frameBuffer()->handleNotifyChange(iWidth, iHeight);531 532 /* Get new frame-buffer size: */533 const QSize frameBufferSizeNew = QSize(frameBuffer()->width(),534 frameBuffer()->height());535 536 /* For 'scale' mode: */537 if (visualStateType() == UIVisualStateType_Scale)538 {539 /* Assign new frame-buffer logical-size: */540 QSize scaledSize = size();541 const double dDevicePixelRatioFormal = frameBuffer()->devicePixelRatio();542 const double dDevicePixelRatioActual = frameBuffer()->devicePixelRatioActual();543 scaledSize *= dDevicePixelRatioFormal;544 if (!frameBuffer()->useUnscaledHiDPIOutput())545 scaledSize /= dDevicePixelRatioActual;546 frameBuffer()->setScaledSize(scaledSize);547 548 /* Forget the last full-screen size: */549 uisession()->setLastFullScreenSize(screenId(), QSize(-1, -1));550 }551 /* For other than 'scale' mode: */552 else553 {554 /* Adjust maximum-size restriction for machine-view: */555 setMaximumSize(sizeHint());556 557 /* Disable the resize hint override hack and forget the last full-screen size: */558 m_sizeHintOverride = QSize(-1, -1);559 if (visualStateType() == UIVisualStateType_Normal)560 uisession()->setLastFullScreenSize(screenId(), QSize(-1, -1));561 562 /* Force machine-window update own layout: */563 QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest);564 565 /* Update machine-view sliders: */566 updateSliders();567 568 /* By some reason Win host forgets to update machine-window central-widget569 * after main-layout was updated, let's do it for all the hosts: */570 machineWindow()->centralWidget()->update();571 572 /* Normalize 'normal' machine-window geometry if necessary: */573 if (visualStateType() == UIVisualStateType_Normal &&574 frameBufferSizeNew != frameBufferSizeOld)575 machineWindow()->normalizeGeometry(true /* adjust position */, machineWindow()->shouldResizeToGuestDisplay());576 }577 578 /* Perform frame-buffer rescaling: */579 frameBuffer()->performRescale();580 581 #ifdef VBOX_WS_MAC582 /* Update MacOS X dock icon size: */583 machineLogic()->updateDockIconSize(screenId(), frameBufferSizeNew.width(), frameBufferSizeNew.height());584 #endif /* VBOX_WS_MAC */585 586 /* Notify frame-buffer resize: */587 emit sigFrameBufferResize();588 589 /* Ask for just required guest display update (it will also update590 * the viewport through IFramebuffer::NotifyUpdate): */591 display().InvalidateAndUpdateScreen(m_uScreenId);592 593 /* If we are in normal or scaled mode and if GA are active,594 * remember the guest-screen size to be able to restore it when necessary: */595 /* As machines with Linux/Solaris and VMSVGA are not able to tell us596 * whether a resize was due to the system or user interaction we currently597 * do not store hints for these systems except when we explicitly send them598 * ourselves. Windows guests should use VBoxVGA controllers, not VMSVGA. */599 if ( !isFullscreenOrSeamless()600 && uisession()->isGuestSupportsGraphics()601 && (machine().GetGraphicsAdapter().GetGraphicsControllerType() != KGraphicsControllerType_VMSVGA))602 setStoredGuestScreenSizeHint(frameBufferSizeNew);603 604 LogRel2(("GUI: UIMachineView::sltHandleNotifyChange: Complete for Screen=%d, Size=%dx%d\n",605 (unsigned long)m_uScreenId, frameBufferSizeNew.width(), frameBufferSizeNew.height()));606 }607 608 void UIMachineView::sltHandleNotifyUpdate(int iX, int iY, int iWidth, int iHeight)609 {610 /* Sanity check: */611 if (!frameBuffer())612 return;613 614 /* Prepare corresponding viewport part: */615 QRect rect(iX, iY, iWidth, iHeight);616 617 /* Take the scaling into account: */618 const double dScaleFactor = frameBuffer()->scaleFactor();619 const QSize scaledSize = frameBuffer()->scaledSize();620 if (scaledSize.isValid())621 {622 /* Calculate corresponding scale-factors: */623 const double xScaleFactor = visualStateType() == UIVisualStateType_Scale ?624 (double)scaledSize.width() / frameBuffer()->width() : dScaleFactor;625 const double yScaleFactor = visualStateType() == UIVisualStateType_Scale ?626 (double)scaledSize.height() / frameBuffer()->height() : dScaleFactor;627 /* Adjust corresponding viewport part: */628 rect.moveTo((int)floor((double)rect.x() * xScaleFactor) - 1,629 (int)floor((double)rect.y() * yScaleFactor) - 1);630 rect.setSize(QSize((int)ceil((double)rect.width() * xScaleFactor) + 2,631 (int)ceil((double)rect.height() * yScaleFactor) + 2));632 }633 634 /* Shift has to be scaled by the device-pixel-ratio635 * but not scaled by the scale-factor. */636 rect.translate(-contentsX(), -contentsY());637 638 /* Take the device-pixel-ratio into account: */639 const double dDevicePixelRatioFormal = frameBuffer()->devicePixelRatio();640 const double dDevicePixelRatioActual = frameBuffer()->devicePixelRatioActual();641 if (!frameBuffer()->useUnscaledHiDPIOutput() && dDevicePixelRatioActual != 1.0)642 {643 rect.moveTo((int)floor((double)rect.x() * dDevicePixelRatioActual) - 1,644 (int)floor((double)rect.y() * dDevicePixelRatioActual) - 1);645 rect.setSize(QSize((int)ceil((double)rect.width() * dDevicePixelRatioActual) + 2,646 (int)ceil((double)rect.height() * dDevicePixelRatioActual) + 2));647 }648 if (dDevicePixelRatioFormal != 1.0)649 {650 rect.moveTo((int)floor((double)rect.x() / dDevicePixelRatioFormal) - 1,651 (int)floor((double)rect.y() / dDevicePixelRatioFormal) - 1);652 rect.setSize(QSize((int)ceil((double)rect.width() / dDevicePixelRatioFormal) + 2,653 (int)ceil((double)rect.height() / dDevicePixelRatioFormal) + 2));654 }655 656 /* Limit the resulting part by the viewport rectangle: */657 rect &= viewport()->rect();658 659 /* Update corresponding viewport part: */660 viewport()->update(rect);661 }662 663 void UIMachineView::sltHandleSetVisibleRegion(QRegion region)664 {665 /* Used only in seamless-mode. */666 Q_UNUSED(region);667 }668 669 968 void UIMachineView::sltDesktopResized() 670 969 { … … 1120 1419 } 1121 1420 1122 UISession* UIMachineView::uisession() const1123 {1124 return machineWindow()->uisession();1125 }1126 1127 1421 CSession& UIMachineView::session() const 1128 1422 { … … 1153 1447 { 1154 1448 return machineWindow()->actionPool(); 1155 }1156 1157 UIMachineLogic* UIMachineView::machineLogic() const1158 {1159 return machineWindow()->machineLogic();1160 1449 } 1161 1450 … … 1191 1480 /* Return the resulting size-hint: */ 1192 1481 return QSize(size.width() + frameWidth() * 2, size.height() + frameWidth() * 2); 1193 }1194 1195 int UIMachineView::contentsX() const1196 {1197 return horizontalScrollBar()->value();1198 }1199 1200 int UIMachineView::contentsY() const1201 {1202 return verticalScrollBar()->value();1203 }1204 1205 int UIMachineView::contentsWidth() const1206 {1207 return frameBuffer()->width();1208 }1209 1210 int UIMachineView::contentsHeight() const1211 {1212 return frameBuffer()->height();1213 }1214 1215 int UIMachineView::visibleWidth() const1216 {1217 return horizontalScrollBar()->pageStep();1218 }1219 1220 int UIMachineView::visibleHeight() const1221 {1222 return verticalScrollBar()->pageStep();1223 }1224 1225 void UIMachineView::setMaximumGuestSize(const QSize &minimumSizeHint /* = QSize() */)1226 {1227 QSize maxSize;1228 switch (m_enmMaximumGuestScreenSizePolicy)1229 {1230 case MaximumGuestScreenSizePolicy_Fixed:1231 maxSize = m_fixedMaxGuestSize;1232 break;1233 case MaximumGuestScreenSizePolicy_Automatic:1234 maxSize = calculateMaxGuestSize().expandedTo(minimumSizeHint);1235 break;1236 case MaximumGuestScreenSizePolicy_Any:1237 /* (0, 0) means any of course. */1238 maxSize = QSize(0, 0);1239 }1240 ASMAtomicWriteU64(&m_u64MaximumGuestSize,1241 RT_MAKE_U64(maxSize.height(), maxSize.width()));1242 }1243 1244 QSize UIMachineView::maximumGuestSize()1245 {1246 uint64_t u64Size = ASMAtomicReadU64(&m_u64MaximumGuestSize);1247 return QSize(int(RT_HI_U32(u64Size)), int(RT_LO_U32(u64Size)));1248 1482 } 1249 1483 … … 1502 1736 horizontalScrollBar()->setPageStep(curViewportSize.width()); 1503 1737 verticalScrollBar()->setPageStep(curViewportSize.height()); 1504 }1505 1506 QPoint UIMachineView::viewportToContents(const QPoint &vp) const1507 {1508 /* Get physical contents shifts of scroll-bars: */1509 int iContentsX = contentsX();1510 int iContentsY = contentsY();1511 1512 /* Take the device-pixel-ratio into account: */1513 const double dDevicePixelRatioFormal = frameBuffer()->devicePixelRatio();1514 const double dDevicePixelRatioActual = frameBuffer()->devicePixelRatioActual();1515 if (!frameBuffer()->useUnscaledHiDPIOutput())1516 {1517 iContentsX *= dDevicePixelRatioActual;1518 iContentsY *= dDevicePixelRatioActual;1519 }1520 iContentsX /= dDevicePixelRatioFormal;1521 iContentsY /= dDevicePixelRatioFormal;1522 1523 /* Return point shifted according scroll-bars: */1524 return QPoint(vp.x() + iContentsX, vp.y() + iContentsY);1525 }1526 1527 void UIMachineView::scrollBy(int dx, int dy)1528 {1529 horizontalScrollBar()->setValue(horizontalScrollBar()->value() + dx);1530 verticalScrollBar()->setValue(verticalScrollBar()->value() + dy);1531 1738 } 1532 1739 … … 1609 1816 } 1610 1817 #endif /* VBOX_WS_MAC */ 1611 1612 UIVisualStateType UIMachineView::visualStateType() const1613 {1614 return machineLogic()->visualStateType();1615 }1616 1818 1617 1819 bool UIMachineView::isFullscreenOrSeamless() const … … 1899 2101 } 1900 2102 1901 int UIMachineView::dragCheckPending(void)1902 {1903 int rc;1904 1905 if (!dragAndDropIsActive())1906 rc = VERR_ACCESS_DENIED;1907 # ifdef VBOX_WITH_DRAG_AND_DROP_GH1908 else if (!m_fIsDraggingFromGuest)1909 {1910 /// @todo Add guest->guest DnD functionality here by getting1911 // the source of guest B (when copying from B to A).1912 rc = m_pDnDHandler->dragCheckPending(screenId());1913 if (RT_SUCCESS(rc))1914 m_fIsDraggingFromGuest = true;1915 }1916 else /* Already dragging, so report success. */1917 rc = VINF_SUCCESS;1918 # else1919 rc = VERR_NOT_SUPPORTED;1920 # endif1921 1922 DNDDEBUG(("DnD: dragCheckPending ended with rc=%Rrc\n", rc));1923 return rc;1924 }1925 1926 int UIMachineView::dragStart(void)1927 {1928 int rc;1929 1930 if (!dragAndDropIsActive())1931 rc = VERR_ACCESS_DENIED;1932 # ifdef VBOX_WITH_DRAG_AND_DROP_GH1933 else if (!m_fIsDraggingFromGuest)1934 rc = VERR_WRONG_ORDER;1935 else1936 {1937 /// @todo Add guest->guest DnD functionality here by getting1938 // the source of guest B (when copying from B to A).1939 rc = m_pDnDHandler->dragStart(screenId());1940 1941 m_fIsDraggingFromGuest = false;1942 }1943 # else1944 rc = VERR_NOT_SUPPORTED;1945 # endif1946 1947 DNDDEBUG(("DnD: dragStart ended with rc=%Rrc\n", rc));1948 return rc;1949 }1950 1951 int UIMachineView::dragStop(void)1952 {1953 int rc;1954 1955 if (!dragAndDropIsActive())1956 rc = VERR_ACCESS_DENIED;1957 # ifdef VBOX_WITH_DRAG_AND_DROP_GH1958 else if (!m_fIsDraggingFromGuest)1959 rc = VERR_WRONG_ORDER;1960 else1961 rc = m_pDnDHandler->dragStop(screenId());1962 # else1963 rc = VERR_NOT_SUPPORTED;1964 # endif1965 1966 DNDDEBUG(("DnD: dragStop ended with rc=%Rrc\n", rc));1967 return rc;1968 }1969 1970 2103 void UIMachineView::dropEvent(QDropEvent *pEvent) 1971 2104 { … … 1995 2128 1996 2129 #endif /* VBOX_WITH_DRAG_AND_DROP */ 1997 1998 bool UIMachineView::nativeEventPreprocessor(const QByteArray &eventType, void *pMessage)1999 {2000 /* Check if some event should be filtered out.2001 * Returning @c true means filtering-out,2002 * Returning @c false means passing event to Qt. */2003 2004 # if defined(VBOX_WS_MAC)2005 2006 /* Make sure it's generic NSEvent: */2007 if (eventType != "mac_generic_NSEvent")2008 return false;2009 EventRef event = static_cast<EventRef>(darwinCocoaToCarbonEvent(pMessage));2010 2011 switch (::GetEventClass(event))2012 {2013 // Keep in mind that this stuff should not be enabled while we are still using2014 // own native keyboard filter installed through cocoa API, to be reworked.2015 // S.a. registerForNativeEvents call in UIKeyboardHandler implementation.2016 #if 02017 /* Watch for keyboard-events: */2018 case kEventClassKeyboard:2019 {2020 switch (::GetEventKind(event))2021 {2022 /* Watch for key-events: */2023 case kEventRawKeyDown:2024 case kEventRawKeyRepeat:2025 case kEventRawKeyUp:2026 case kEventRawKeyModifiersChanged:2027 {2028 /* Delegate key-event handling to the keyboard-handler: */2029 return machineLogic()->keyboardHandler()->nativeEventFilter(pMessage, screenId());2030 }2031 default:2032 break;2033 }2034 break;2035 }2036 #endif2037 /* Watch for mouse-events: */2038 case kEventClassMouse:2039 {2040 switch (::GetEventKind(event))2041 {2042 /* Watch for button-events: */2043 case kEventMouseDown:2044 case kEventMouseUp:2045 {2046 /* Delegate button-event handling to the mouse-handler: */2047 return machineLogic()->mouseHandler()->nativeEventFilter(pMessage, screenId());2048 }2049 default:2050 break;2051 }2052 break;2053 }2054 default:2055 break;2056 }2057 2058 # elif defined(VBOX_WS_WIN)2059 2060 /* Make sure it's generic MSG event: */2061 if (eventType != "windows_generic_MSG")2062 return false;2063 MSG *pEvent = static_cast<MSG*>(pMessage);2064 2065 switch (pEvent->message)2066 {2067 /* Watch for key-events: */2068 case WM_KEYDOWN:2069 case WM_SYSKEYDOWN:2070 case WM_KEYUP:2071 case WM_SYSKEYUP:2072 {2073 // WORKAROUND:2074 // There is an issue in the Windows Qt5 event processing sequence2075 // causing QAbstractNativeEventFilter to receive Windows native events2076 // coming not just to the top-level window but to actual target as well.2077 // They are calling one - "global event" and another one - "context event".2078 // That way native events are always duplicated with almost no possibility2079 // to distinguish copies except the fact that synthetic event always have2080 // time set to 0 (actually that field was not initialized at all, we had2081 // fixed that in our private Qt tool). We should skip such events instantly.2082 if (pEvent->time == 0)2083 return false;2084 2085 /* Delegate key-event handling to the keyboard-handler: */2086 return machineLogic()->keyboardHandler()->nativeEventFilter(pMessage, screenId());2087 }2088 default:2089 break;2090 }2091 2092 # elif defined(VBOX_WS_X11)2093 2094 /* Make sure it's generic XCB event: */2095 if (eventType != "xcb_generic_event_t")2096 return false;2097 xcb_generic_event_t *pEvent = static_cast<xcb_generic_event_t*>(pMessage);2098 2099 switch (pEvent->response_type & ~0x80)2100 {2101 /* Watch for key-events: */2102 case XCB_KEY_PRESS:2103 case XCB_KEY_RELEASE:2104 {2105 /* Delegate key-event handling to the keyboard-handler: */2106 return machineLogic()->keyboardHandler()->nativeEventFilter(pMessage, screenId());2107 }2108 /* Watch for button-events: */2109 case XCB_BUTTON_PRESS:2110 case XCB_BUTTON_RELEASE:2111 {2112 /* Delegate button-event handling to the mouse-handler: */2113 return machineLogic()->mouseHandler()->nativeEventFilter(pMessage, screenId());2114 }2115 default:2116 break;2117 }2118 2119 # else2120 2121 # warning "port me!"2122 2123 # endif2124 2125 /* Filter nothing by default: */2126 return false;2127 }2128 2130 2129 2131 QSize UIMachineView::scaledForward(QSize size) const -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r97978 r98037 109 109 virtual void applyMachineViewScaleFactor(); 110 110 111 /** Returns screen ID for this view. */ 112 ulong screenId() const { return m_uScreenId; } 113 114 /** Returns the session UI reference. */ 115 UISession *uisession() const; 116 /** Returns the machine-logic reference. */ 117 UIMachineLogic *machineLogic() const; 118 /** Returns the machine-window reference. */ 119 UIMachineWindow *machineWindow() const { return m_pMachineWindow; } 120 /** Returns view's frame-buffer reference. */ 121 UIFrameBuffer *frameBuffer() const { return m_pFrameBuffer; } 122 123 /** Returns actual contents width. */ 124 int contentsWidth() const; 125 /** Returns actual contents height. */ 126 int contentsHeight() const; 127 /** Returns actual contents x origin. */ 128 int contentsX() const; 129 /** Returns actual contents y origin. */ 130 int contentsY() const; 131 /** Returns visible contents width. */ 132 int visibleWidth() const; 133 /** Returns visible contents height. */ 134 int visibleHeight() const; 135 /** Translates viewport point to contents point. */ 136 QPoint viewportToContents(const QPoint &viewportPoint) const; 137 /** Scrolls contents by @a iDx x iDy pixels. */ 138 void scrollBy(int iDx, int iDy); 139 140 /** What view mode (normal, fullscreen etc.) are we in? */ 141 UIVisualStateType visualStateType() const; 142 143 /** Returns cached mouse cursor. */ 144 QCursor cursor() const { return m_cursor; } 145 111 146 /* Framebuffer aspect ratio: */ 112 147 double aspectRatio() const; 148 149 /** Atomically store the maximum guest resolution which we currently wish 150 * to handle for @a maximumGuestSize() to read. Should be called if anything 151 * happens (e.g. a screen hotplug) which might cause the value to change. 152 * @sa m_u64MaximumGuestSize. */ 153 void setMaximumGuestSize(const QSize &minimumSizeHint = QSize()); 154 /** Atomically read the maximum guest resolution which we currently wish to 155 * handle. This may safely be called from another thread (called by 156 * UIFramebuffer on EMT). 157 * @sa m_u64MaximumGuestSize. */ 158 QSize maximumGuestSize(); 113 159 114 160 /** Updates console's display viewport. 115 161 * @remarks Used to update 3D-service overlay viewport as well. */ 116 162 void updateViewport(); 163 164 #ifdef VBOX_WITH_DRAG_AND_DROP 165 /** Checks for a pending drag and drop event within the guest and 166 * (optionally) starts a drag and drop operation on the host. */ 167 int dragCheckPending(); 168 /** Starts a drag and drop operation from guest to the host. 169 * This internally either uses Qt's abstract QDrag methods 170 * or some other OS-dependent implementation. */ 171 int dragStart(); 172 /** Aborts (and resets) the current (pending) 173 * guest to host drag and drop operation. */ 174 int dragStop(); 175 #endif /* VBOX_WITH_DRAG_AND_DROP */ 176 177 /** Performs pre-processing of all the native events. */ 178 virtual bool nativeEventPreprocessor(const QByteArray &eventType, void *pMessage); 179 180 public slots: 181 182 /** Handles NotifyChange event received from frame-buffer. 183 * @todo To make it right, this have to be protected, but 184 * connection should be moved from frame-buffer to this class. */ 185 virtual void sltHandleNotifyChange(int iWidth, int iHeight); 186 187 /** Handles NotifyUpdate event received from frame-buffer. 188 * @todo To make it right, this have to be protected, but 189 * connection should be moved from frame-buffer to this class. */ 190 virtual void sltHandleNotifyUpdate(int iX, int iY, int iWidth, int iHeight); 191 192 /** Handles SetVisibleRegion event received from frame-buffer. 193 * @todo To make it right, this have to be protected, but 194 * connection should be moved from frame-buffer to this class. */ 195 virtual void sltHandleSetVisibleRegion(QRegion region); 117 196 118 197 protected slots: … … 137 216 void sltHandleActionTriggerViewScreenResize(int iScreen, const QSize &size); 138 217 139 /* Handler: Frame-buffer NotifyChange stuff: */140 virtual void sltHandleNotifyChange(int iWidth, int iHeight);141 142 /* Handler: Frame-buffer NotifyUpdate stuff: */143 virtual void sltHandleNotifyUpdate(int iX, int iY, int iWidth, int iHeight);144 145 /* Handler: Frame-buffer SetVisibleRegion stuff: */146 virtual void sltHandleSetVisibleRegion(QRegion region);147 148 218 /* Watch dog for desktop resizes: */ 149 219 void sltDesktopResized(); … … 195 265 virtual void cleanupNativeFilters(); 196 266 //virtual void saveMachineViewSettings() {} 197 198 /** Returns the session UI reference. */199 UISession* uisession() const;200 267 201 268 /** Returns the session reference. */ … … 211 278 212 279 /* Protected getters: */ 213 UIMachineWindow* machineWindow() const { return m_pMachineWindow; }214 280 UIActionPool* actionPool() const; 215 UIMachineLogic* machineLogic() const;216 281 QSize sizeHint() const; 217 int contentsX() const;218 int contentsY() const;219 int contentsWidth() const;220 int contentsHeight() const;221 int visibleWidth() const;222 int visibleHeight() const;223 ulong screenId() const { return m_uScreenId; }224 UIFrameBuffer* frameBuffer() const { return m_pFrameBuffer; }225 226 /** Atomically store the maximum guest resolution which we currently wish227 * to handle for @a maximumGuestSize() to read. Should be called if anything228 * happens (e.g. a screen hotplug) which might cause the value to change.229 * @sa m_u64MaximumGuestSize. */230 void setMaximumGuestSize(const QSize &minimumSizeHint = QSize());231 /** Atomically read the maximum guest resolution which we currently wish to232 * handle. This may safely be called from another thread (called by233 * UIFramebuffer on EMT).234 * @sa m_u64MaximumGuestSize. */235 QSize maximumGuestSize();236 282 237 283 /** Retrieves the last guest-screen size-hint from extra-data. */ … … 262 308 void updateScaledPausePixmap(); 263 309 264 /** Returns cached mouse cursor. */265 QCursor cursor() const { return m_cursor; }266 267 310 /** The available area on the current screen for application windows. */ 268 311 virtual QRect workingArea() const = 0; … … 271 314 virtual QSize calculateMaxGuestSize() const = 0; 272 315 virtual void updateSliders(); 273 QPoint viewportToContents(const QPoint &vp) const;274 void scrollBy(int dx, int dy);275 316 static void dimImage(QImage &img); 276 317 void scrollContentsBy(int dx, int dy); … … 280 321 CGImageRef frameBuffertoCGImageRef(UIFrameBuffer *pFrameBuffer); 281 322 #endif /* VBOX_WS_MAC */ 282 /** What view mode (normal, fullscreen etc.) are we in? */283 UIVisualStateType visualStateType() const;284 323 /** Is this a fullscreen-type view? */ 285 324 bool isFullscreenOrSeamless() const; … … 337 376 338 377 /** 339 * Guest -> Host: Checks for a pending drag and drop event within the guest340 * and (optionally) starts a drag and drop operation on the host.341 */342 int dragCheckPending(void);343 344 /**345 * Guest -> Host: Starts a drag and drop operation from guest to the host. This346 * internally either uses Qt's abstract QDrag methods or some other347 * OS-dependent implementation.348 */349 int dragStart(void);350 351 /**352 * Guest -> Host: Aborts (and resets) the current (pending) guest to host353 * drag and drop operation.354 */355 int dragStop(void);356 357 /**358 378 * Host -> Guest: Issued when the host drops data into the guest (VM) window. 359 379 * … … 362 382 void dropEvent(QDropEvent *pEvent); 363 383 #endif /* VBOX_WITH_DRAG_AND_DROP */ 364 365 /** Qt5: Performs pre-processing of all the native events. */366 virtual bool nativeEventPreprocessor(const QByteArray &eventType, void *pMessage);367 384 368 385 /** Scales passed size forward. */ … … 427 444 /** Holds the native event filter instance. */ 428 445 UINativeEventFilter *m_pNativeEventFilter; 429 /** Allows the native event filter to redirect430 * events directly to nativeEventPreprocessor(). */431 friend class UINativeEventFilter;432 433 /* Friend classes: */434 friend class UIKeyboardHandler;435 friend class UIMouseHandler;436 friend class UIMachineLogic;437 friend class UIFrameBuffer;438 friend class UIFrameBufferPrivate;439 friend class VBoxOverlayFrameBuffer;440 446 }; 441 447 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r97849 r98037 265 265 } 266 266 #endif /* VBOX_WITH_MASKED_SEAMLESS */ 267 268 void UIMachineWindow::updateAppearanceOf(int iElement) 269 { 270 /* Update window title: */ 271 if (iElement & UIVisualElement_WindowTitle) 272 { 273 /* Make sure machine state is one of valid: */ 274 const KMachineState enmState = uisession()->machineState(); 275 if (enmState == KMachineState_Null) 276 return; 277 278 /* Prepare full name: */ 279 QString strMachineName = machineName(); 280 281 /* Append snapshot name: */ 282 if (machine().GetSnapshotCount() > 0) 283 { 284 const CSnapshot comSnapshot = machine().GetCurrentSnapshot(); 285 strMachineName += " (" + comSnapshot.GetName() + ")"; 286 } 287 288 /* Append state name: */ 289 strMachineName += " [" + gpConverter->toString(enmState) + "]"; 290 291 #ifndef VBOX_WS_MAC 292 /* Append user product name (besides macOS): */ 293 const QString strUserProductName = uisession()->machineWindowNamePostfix(); 294 strMachineName += " - " + (strUserProductName.isEmpty() ? defaultWindowTitle() : strUserProductName); 295 #endif /* !VBOX_WS_MAC */ 296 297 /* Check if we can get graphics adapter: */ 298 CGraphicsAdapter comAdapter = machine().GetGraphicsAdapter(); 299 if (machine().isOk() && comAdapter.isNotNull()) 300 { 301 /* Append screen number only if there are more than one present: */ 302 if (comAdapter.GetMonitorCount() > 1) 303 strMachineName += QString(" : %1").arg(m_uScreenId + 1); 304 } 305 306 /* Assign title finally: */ 307 setWindowTitle(strMachineName); 308 } 309 } 267 310 268 311 void UIMachineWindow::retranslateUi() … … 588 631 } 589 632 590 void UIMachineWindow::updateAppearanceOf(int iElement)591 {592 /* Update window title: */593 if (iElement & UIVisualElement_WindowTitle)594 {595 /* Make sure machine state is one of valid: */596 const KMachineState enmState = uisession()->machineState();597 if (enmState == KMachineState_Null)598 return;599 600 /* Prepare full name: */601 QString strMachineName = machineName();602 603 /* Append snapshot name: */604 if (machine().GetSnapshotCount() > 0)605 {606 const CSnapshot comSnapshot = machine().GetCurrentSnapshot();607 strMachineName += " (" + comSnapshot.GetName() + ")";608 }609 610 /* Append state name: */611 strMachineName += " [" + gpConverter->toString(enmState) + "]";612 613 #ifndef VBOX_WS_MAC614 /* Append user product name (besides macOS): */615 const QString strUserProductName = uisession()->machineWindowNamePostfix();616 strMachineName += " - " + (strUserProductName.isEmpty() ? defaultWindowTitle() : strUserProductName);617 #endif /* !VBOX_WS_MAC */618 619 /* Check if we can get graphics adapter: */620 CGraphicsAdapter comAdapter = machine().GetGraphicsAdapter();621 if (machine().isOk() && comAdapter.isNotNull())622 {623 /* Append screen number only if there are more than one present: */624 if (comAdapter.GetMonitorCount() > 1)625 strMachineName += QString(" : %1").arg(m_uScreenId + 1);626 }627 628 /* Assign title finally: */629 setWindowTitle(strMachineName);630 }631 }632 633 633 #ifdef VBOX_WITH_DEBUGGER_GUI 634 634 void UIMachineWindow::updateDbgWindows() -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h
r96407 r98037 122 122 #endif /* VBOX_WITH_MASKED_SEAMLESS */ 123 123 124 /** Makes sure window is exposed in required mode/state. */ 125 virtual void showInNecessaryMode() = 0; 126 127 /** Updates appearance for specified @a iElement. */ 128 virtual void updateAppearanceOf(int iElement); 129 124 130 protected slots: 125 131 … … 139 145 /* Constructor: */ 140 146 UIMachineWindow(UIMachineLogic *pMachineLogic, ulong uScreenId); 141 142 /* Show stuff: */143 virtual void showInNecessaryMode() = 0;144 147 145 148 /* Translate stuff: */ … … 191 194 192 195 /* Update stuff: */ 193 virtual void updateAppearanceOf(int iElement);194 196 #ifdef VBOX_WITH_DEBUGGER_GUI 195 197 void updateDbgWindows(); … … 223 225 QSpacerItem *m_pLeftSpacer; 224 226 QSpacerItem *m_pRightSpacer; 225 226 /* Friend classes: */227 friend class UIMachineLogic;228 friend class UIMachineLogicFullscreen;229 friend class UIMachineLogicSeamless;230 227 }; 231 228 232 229 #endif /* !FEQT_INCLUDED_SRC_runtime_UIMachineWindow_h */ 233
Note:
See TracChangeset
for help on using the changeset viewer.