VirtualBox

Changeset 98037 in vbox


Ignore:
Timestamp:
Jan 10, 2023 11:04:46 AM (23 months ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Get rid of friend classes, part #1 (general interfaces).

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  
    27702770}
    27712771
     2772#ifdef VBOX_WITH_DEBUGGER_GUI
     2773void 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
    27722783void UIMachineLogic::updateMenuDevicesStorage(QMenu *pMenu)
    27732784{
     
    33633374    }
    33643375}
    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 }
    33743376#endif /* VBOX_WITH_DEBUGGER_GUI */
    33753377
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r97514 r98037  
    156156    void typeHostKeyComboPressRelease(bool fToggleSequence);
    157157
     158#ifdef VBOX_WITH_DEBUGGER_GUI
     159    /** Adjusts relative position for debugger window. */
     160    void dbgAdjustRelativePos();
     161#endif /* VBOX_WITH_DEBUGGER_GUI */
     162
    158163protected slots:
    159164
     
    421426    bool dbgCreated();
    422427    void dbgDestroy();
    423     void dbgAdjustRelativePos();
    424428    /* The handle to the debugger GUI: */
    425429    PDBGGUI m_pDbgGui;
     
    459463    QVector<X11ScreenSaverInhibitMethod*> m_methods;
    460464#endif
    461     /* Friend classes: */
    462     friend class UIMachineWindow;
    463465};
    464466
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r97998 r98037  
    261261}
    262262
     263UISession *UIMachineView::uisession() const
     264{
     265    return machineWindow()->uisession();
     266}
     267
     268UIMachineLogic *UIMachineView::machineLogic() const
     269{
     270    return machineWindow()->machineLogic();
     271}
     272
     273int UIMachineView::contentsWidth() const
     274{
     275    return frameBuffer()->width();
     276}
     277
     278int UIMachineView::contentsHeight() const
     279{
     280    return frameBuffer()->height();
     281}
     282
     283int UIMachineView::contentsX() const
     284{
     285    return horizontalScrollBar()->value();
     286}
     287
     288int UIMachineView::contentsY() const
     289{
     290    return verticalScrollBar()->value();
     291}
     292
     293int UIMachineView::visibleWidth() const
     294{
     295    return horizontalScrollBar()->pageStep();
     296}
     297
     298int UIMachineView::visibleHeight() const
     299{
     300    return verticalScrollBar()->pageStep();
     301}
     302
     303QPoint 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
     324void UIMachineView::scrollBy(int iDx, int iDy)
     325{
     326    horizontalScrollBar()->setValue(horizontalScrollBar()->value() + iDx);
     327    verticalScrollBar()->setValue(verticalScrollBar()->value() + iDy);
     328}
     329
     330UIVisualStateType UIMachineView::visualStateType() const
     331{
     332    return machineLogic()->visualStateType();
     333}
     334
    263335double UIMachineView::aspectRatio() const
    264336{
     
    266338}
    267339
     340void 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
     359QSize 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
    268365void UIMachineView::updateViewport()
    269366{
    270367    display().ViewportChanged(screenId(), contentsX(), contentsY(), visibleWidth(), visibleHeight());
     368}
     369
     370#ifdef VBOX_WITH_DRAG_AND_DROP
     371int 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
     396int 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
     421int 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
     441bool 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
     572void 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
     673void 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
     728void UIMachineView::sltHandleSetVisibleRegion(QRegion region)
     729{
     730    /* Used only in seamless-mode. */
     731    Q_UNUSED(region);
    271732}
    272733
     
    505966}
    506967
    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     else
    553     {
    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-widget
    569          * 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_MAC
    582     /* 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 update
    590      * 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 us
    596      * whether a resize was due to the system or user interaction we currently
    597      * do not store hints for these systems except when we explicitly send them
    598      * 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-ratio
    635      * 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 
    669968void UIMachineView::sltDesktopResized()
    670969{
     
    11201419}
    11211420
    1122 UISession* UIMachineView::uisession() const
    1123 {
    1124     return machineWindow()->uisession();
    1125 }
    1126 
    11271421CSession& UIMachineView::session() const
    11281422{
     
    11531447{
    11541448    return machineWindow()->actionPool();
    1155 }
    1156 
    1157 UIMachineLogic* UIMachineView::machineLogic() const
    1158 {
    1159     return machineWindow()->machineLogic();
    11601449}
    11611450
     
    11911480    /* Return the resulting size-hint: */
    11921481    return QSize(size.width() + frameWidth() * 2, size.height() + frameWidth() * 2);
    1193 }
    1194 
    1195 int UIMachineView::contentsX() const
    1196 {
    1197     return horizontalScrollBar()->value();
    1198 }
    1199 
    1200 int UIMachineView::contentsY() const
    1201 {
    1202     return verticalScrollBar()->value();
    1203 }
    1204 
    1205 int UIMachineView::contentsWidth() const
    1206 {
    1207     return frameBuffer()->width();
    1208 }
    1209 
    1210 int UIMachineView::contentsHeight() const
    1211 {
    1212     return frameBuffer()->height();
    1213 }
    1214 
    1215 int UIMachineView::visibleWidth() const
    1216 {
    1217     return horizontalScrollBar()->pageStep();
    1218 }
    1219 
    1220 int UIMachineView::visibleHeight() const
    1221 {
    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)));
    12481482}
    12491483
     
    15021736    horizontalScrollBar()->setPageStep(curViewportSize.width());
    15031737    verticalScrollBar()->setPageStep(curViewportSize.height());
    1504 }
    1505 
    1506 QPoint UIMachineView::viewportToContents(const QPoint &vp) const
    1507 {
    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);
    15311738}
    15321739
     
    16091816}
    16101817#endif /* VBOX_WS_MAC */
    1611 
    1612 UIVisualStateType UIMachineView::visualStateType() const
    1613 {
    1614     return machineLogic()->visualStateType();
    1615 }
    16161818
    16171819bool UIMachineView::isFullscreenOrSeamless() const
     
    18992101}
    19002102
    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_GH
    1908     else if (!m_fIsDraggingFromGuest)
    1909     {
    1910         /// @todo Add guest->guest DnD functionality here by getting
    1911         //       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 # else
    1919     rc = VERR_NOT_SUPPORTED;
    1920 # endif
    1921 
    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_GH
    1933     else if (!m_fIsDraggingFromGuest)
    1934         rc = VERR_WRONG_ORDER;
    1935     else
    1936     {
    1937         /// @todo Add guest->guest DnD functionality here by getting
    1938         //       the source of guest B (when copying from B to A).
    1939         rc = m_pDnDHandler->dragStart(screenId());
    1940 
    1941         m_fIsDraggingFromGuest = false;
    1942     }
    1943 # else
    1944     rc = VERR_NOT_SUPPORTED;
    1945 # endif
    1946 
    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_GH
    1958     else if (!m_fIsDraggingFromGuest)
    1959         rc = VERR_WRONG_ORDER;
    1960     else
    1961         rc = m_pDnDHandler->dragStop(screenId());
    1962 # else
    1963     rc = VERR_NOT_SUPPORTED;
    1964 # endif
    1965 
    1966     DNDDEBUG(("DnD: dragStop ended with rc=%Rrc\n", rc));
    1967     return rc;
    1968 }
    1969 
    19702103void UIMachineView::dropEvent(QDropEvent *pEvent)
    19712104{
     
    19952128
    19962129#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 using
    2014         // own native keyboard filter installed through cocoa API, to be reworked.
    2015         // S.a. registerForNativeEvents call in UIKeyboardHandler implementation.
    2016 #if 0
    2017         /* 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 #endif
    2037         /* 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 sequence
    2075             // causing QAbstractNativeEventFilter to receive Windows native events
    2076             // 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 possibility
    2079             // to distinguish copies except the fact that synthetic event always have
    2080             // time set to 0 (actually that field was not initialized at all, we had
    2081             // 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 # else
    2120 
    2121 #  warning "port me!"
    2122 
    2123 # endif
    2124 
    2125     /* Filter nothing by default: */
    2126     return false;
    2127 }
    21282130
    21292131QSize UIMachineView::scaledForward(QSize size) const
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r97978 r98037  
    109109    virtual void applyMachineViewScaleFactor();
    110110
     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
    111146    /* Framebuffer aspect ratio: */
    112147    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();
    113159
    114160    /** Updates console's display viewport.
    115161      * @remarks Used to update 3D-service overlay viewport as well. */
    116162    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
     180public 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);
    117196
    118197protected slots:
     
    137216    void sltHandleActionTriggerViewScreenResize(int iScreen, const QSize &size);
    138217
    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 
    148218    /* Watch dog for desktop resizes: */
    149219    void sltDesktopResized();
     
    195265    virtual void cleanupNativeFilters();
    196266    //virtual void saveMachineViewSettings() {}
    197 
    198     /** Returns the session UI reference. */
    199     UISession* uisession() const;
    200267
    201268    /** Returns the session reference. */
     
    211278
    212279    /* Protected getters: */
    213     UIMachineWindow* machineWindow() const { return m_pMachineWindow; }
    214280    UIActionPool* actionPool() const;
    215     UIMachineLogic* machineLogic() const;
    216281    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 wish
    227      * to handle for @a maximumGuestSize() to read.  Should be called if anything
    228      * 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 to
    232      * handle.  This may safely be called from another thread (called by
    233      * UIFramebuffer on EMT).
    234      * @sa m_u64MaximumGuestSize. */
    235     QSize maximumGuestSize();
    236282
    237283    /** Retrieves the last guest-screen size-hint from extra-data. */
     
    262308    void updateScaledPausePixmap();
    263309
    264     /** Returns cached mouse cursor. */
    265     QCursor cursor() const { return m_cursor; }
    266 
    267310    /** The available area on the current screen for application windows. */
    268311    virtual QRect workingArea() const = 0;
     
    271314    virtual QSize calculateMaxGuestSize() const = 0;
    272315    virtual void updateSliders();
    273     QPoint viewportToContents(const QPoint &vp) const;
    274     void scrollBy(int dx, int dy);
    275316    static void dimImage(QImage &img);
    276317    void scrollContentsBy(int dx, int dy);
     
    280321    CGImageRef frameBuffertoCGImageRef(UIFrameBuffer *pFrameBuffer);
    281322#endif /* VBOX_WS_MAC */
    282     /** What view mode (normal, fullscreen etc.) are we in? */
    283     UIVisualStateType visualStateType() const;
    284323    /** Is this a fullscreen-type view? */
    285324    bool isFullscreenOrSeamless() const;
     
    337376
    338377    /**
    339      * Guest -> Host: Checks for a pending drag and drop event within the guest
    340      *                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. This
    346      *                internally either uses Qt's abstract QDrag methods or some other
    347      *                OS-dependent implementation.
    348      */
    349     int dragStart(void);
    350 
    351     /**
    352      * Guest -> Host: Aborts (and resets) the current (pending) guest to host
    353      *                drag and drop operation.
    354      */
    355     int dragStop(void);
    356 
    357     /**
    358378     * Host -> Guest: Issued when the host drops data into the guest (VM) window.
    359379     *
     
    362382    void dropEvent(QDropEvent *pEvent);
    363383#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);
    367384
    368385    /** Scales passed size forward. */
     
    427444    /** Holds the native event filter instance. */
    428445    UINativeEventFilter *m_pNativeEventFilter;
    429     /** Allows the native event filter to redirect
    430       * 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;
    440446};
    441447
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r97849 r98037  
    265265}
    266266#endif /* VBOX_WITH_MASKED_SEAMLESS */
     267
     268void 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}
    267310
    268311void UIMachineWindow::retranslateUi()
     
    588631}
    589632
    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_MAC
    614         /* 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 
    633633#ifdef VBOX_WITH_DEBUGGER_GUI
    634634void UIMachineWindow::updateDbgWindows()
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h

    r96407 r98037  
    122122#endif /* VBOX_WITH_MASKED_SEAMLESS */
    123123
     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
    124130protected slots:
    125131
     
    139145    /* Constructor: */
    140146    UIMachineWindow(UIMachineLogic *pMachineLogic, ulong uScreenId);
    141 
    142     /* Show stuff: */
    143     virtual void showInNecessaryMode() = 0;
    144147
    145148    /* Translate stuff: */
     
    191194
    192195    /* Update stuff: */
    193     virtual void updateAppearanceOf(int iElement);
    194196#ifdef VBOX_WITH_DEBUGGER_GUI
    195197    void updateDbgWindows();
     
    223225    QSpacerItem *m_pLeftSpacer;
    224226    QSpacerItem *m_pRightSpacer;
    225 
    226     /* Friend classes: */
    227     friend class UIMachineLogic;
    228     friend class UIMachineLogicFullscreen;
    229     friend class UIMachineLogicSeamless;
    230227};
    231228
    232229#endif /* !FEQT_INCLUDED_SRC_runtime_UIMachineWindow_h */
    233 
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette