VirtualBox

Changeset 27236 in vbox for trunk/src


Ignore:
Timestamp:
Mar 9, 2010 10:48:51 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4: New running VM core: unifying common code for normal, fullscreen, seamless machine-views.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r27233 r27236  
    423423#endif
    424424
    425 void UIMachineView::updateSliders()
    426 {
    427     QSize p = viewport()->size();
    428     QSize m = maximumViewportSize();
    429 
    430     QSize v = QSize(m_pFrameBuffer->width(), m_pFrameBuffer->height());
    431     /* No scroll bars needed: */
    432     if (m.expandedTo(v) == m)
    433         p = m;
    434 
    435     horizontalScrollBar()->setRange(0, v.width() - p.width());
    436     verticalScrollBar()->setRange(0, v.height() - p.height());
    437     horizontalScrollBar()->setPageStep(p.width());
    438     verticalScrollBar()->setPageStep(p.height());
    439 }
    440 
    441425void UIMachineView::prepareFrameBuffer()
    442426{
     
    688672            }
    689673            break;
     674        }
     675
     676        case VBoxDefs::ResizeEventType:
     677        {
     678            /* Some situations require framebuffer resize events to be ignored,
     679             * leaving machine window & machine view & framebuffer sizes preserved: */
     680            if (uisession()->isGuestResizeIgnored())
     681                return true;
     682
     683            /* We are starting to perform machine view resize: */
     684            bool oldIgnoreMainwndResize = isMachineWindowResizeIgnored();
     685            setMachineWindowResizeIgnored(true);
     686
     687            /* Get guest resize-event: */
     688            UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);
     689
     690            /* Perform framebuffer resize: */
     691            frameBuffer()->resizeEvent(pResizeEvent);
     692
     693            /* Reapply maximum size restriction for machine view: */
     694            setMaximumSize(sizeHint());
     695
     696            /* Store the new size to prevent unwanted resize hints being sent back: */
     697            storeConsoleSize(pResizeEvent->width(), pResizeEvent->height());
     698
     699            /* Perform machine-view resize: */
     700            resize(pResizeEvent->width(), pResizeEvent->height());
     701
     702            /* Let our toplevel widget calculate its sizeHint properly. */
     703#ifdef Q_WS_X11
     704            /* We use processEvents rather than sendPostedEvents & set the time out value to max cause on X11 otherwise
     705             * the layout isn't calculated correctly. Dosn't find the bug in Qt, but this could be triggered through
     706             * the async nature of the X11 window event system. */
     707            QCoreApplication::processEvents(QEventLoop::AllEvents, INT_MAX);
     708#else /* Q_WS_X11 */
     709            QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest);
     710#endif /* Q_WS_X11 */
     711
     712#ifdef Q_WS_MAC
     713            // TODO_NEW_CORE
     714//            mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height());
     715#endif /* Q_WS_MAC */
     716
     717            /* Update mouse cursor shape: */
     718            updateMouseCursorShape();
     719#ifdef Q_WS_WIN32
     720            updateMouseCursorClipping();
     721#endif
     722
     723            /* May be we have to restrict minimum size? */
     724            maybeRestrictMinimumSize();
     725
     726            /* Update machine-view sliders: */
     727            updateSliders();
     728
     729            /* Normalize geometry: */
     730            normalizeGeometry(true /* adjustPosition */);
     731
     732            /* Report to the VM thread that we finished resizing */
     733            session().GetConsole().GetDisplay().ResizeCompleted(screenId());
     734
     735            /* We are finishing to perform machine-view resize: */
     736            setMachineWindowResizeIgnored(oldIgnoreMainwndResize);
     737
     738            /* Make sure that all posted signals are processed: */
     739            qApp->processEvents();
     740
     741            /* We also recalculate the desktop geometry if this is determined
     742             * automatically.  In fact, we only need this on the first resize,
     743             * but it is done every time to keep the code simpler. */
     744            calculateDesktopGeometry();
     745
     746            /* Emit a signal about guest was resized: */
     747            emit resizeHintDone();
     748
     749            return true;
    690750        }
    691751
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r27227 r27236  
    7171
    7272    /* Public members: */
    73     virtual void normalizeGeometry(bool /* bAdjustPosition = false */) {}
     73    virtual void normalizeGeometry(bool /* bAdjustPosition = false */) = 0;
    7474
    7575signals:
     
    125125    void updateMouseCursorClipping();
    126126#endif
    127     void updateSliders();
     127    virtual QRect availableGeometry() = 0;
     128    virtual void maybeRestrictMinimumSize() = 0;
     129    virtual void updateSliders() =  0;
    128130
    129131#ifdef Q_WS_MAC
     
    208210    void releaseAllPressedKeys(bool aReleaseHostKey = true);
    209211    void sendChangedKeyStates();
    210 
    211     virtual QRect availableGeometry() = 0;
    212212
    213213    static void dimImage(QImage &img);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp

    r27235 r27236  
    148148    switch (pEvent->type())
    149149    {
    150         case VBoxDefs::ResizeEventType:
    151         {
    152             /* Some situations require framebuffer resize events to be ignored,
    153              * leaving machine window & machine view & framebuffer sizes preserved: */
    154             if (uisession()->isGuestResizeIgnored())
    155                 return true;
    156 
    157             /* We are starting to perform machine view resize: */
    158             bool oldIgnoreMainwndResize = isMachineWindowResizeIgnored();
    159             setMachineWindowResizeIgnored(true);
    160 
    161             /* Get guest resize-event: */
    162             UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);
    163 
    164             /* Perform framebuffer resize: */
    165             frameBuffer()->resizeEvent(pResizeEvent);
    166 
    167             /* Reapply maximum size restriction for machine view: */
    168             setMaximumSize(sizeHint());
    169 
    170             /* Store the new size to prevent unwanted resize hints being sent back: */
    171             storeConsoleSize(pResizeEvent->width(), pResizeEvent->height());
    172 
    173             /* Perform machine view resize: */
    174             resize(pResizeEvent->width(), pResizeEvent->height());
    175 
    176             /* Let our toplevel widget calculate its sizeHint properly. */
    177 #ifdef Q_WS_X11
    178             /* We use processEvents rather than sendPostedEvents & set the time out value to max cause on X11 otherwise
    179              * the layout isn't calculated correctly. Dosn't find the bug in Qt, but this could be triggered through
    180              * the async nature of the X11 window event system. */
    181             QCoreApplication::processEvents(QEventLoop::AllEvents, INT_MAX);
    182 #else /* Q_WS_X11 */
    183             QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest);
    184 #endif /* Q_WS_X11 */
    185 
    186 #ifdef Q_WS_MAC
    187             // TODO_NEW_CORE
    188 //            mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height());
    189 #endif /* Q_WS_MAC */
    190 
    191             /* Update mouse cursor shape: */
    192             updateMouseCursorShape();
    193 #ifdef Q_WS_WIN32
    194             updateMouseCursorClipping();
    195 #endif
    196 
    197             /* May be we have to restrict minimum size? */
    198             maybeRestrictMinimumSize();
    199 
    200             /* Report to the VM thread that we finished resizing */
    201             session().GetConsole().GetDisplay().ResizeCompleted(screenId());
    202 
    203             /* We are finishing to perform machine view resize: */
    204             setMachineWindowResizeIgnored(oldIgnoreMainwndResize);
    205 
    206             /* Make sure that all posted signals are processed: */
    207             qApp->processEvents();
    208 
    209             /* We also recalculate the desktop geometry if this is determined automatically.
    210              * In fact, we only need this on the first resize,
    211              * but it is done every time to keep the code simpler. */
    212             calculateDesktopGeometry();
    213 
    214             /* Emit a signal about guest was resized: */
    215             emit resizeHintDone();
    216 
    217             return true;
    218         }
    219 
    220150        case QEvent::KeyPress:
    221151        case QEvent::KeyRelease:
    222152        {
     153            /* Get key-event: */
    223154            QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent);
    224155
     156            /* Process Host+Home for menu popup: */
    225157            if (isHostKeyPressed() && pEvent->type() == QEvent::KeyPress)
    226158            {
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h

    r27124 r27236  
    7777
    7878    /* Private helpers: */
     79    void normalizeGeometry(bool /* fAdjustPosition */) {}
    7980    QRect availableGeometry();
    8081    void maybeRestrictMinimumSize();
     82    void updateSliders() {}
    8183
    8284    /* Private members: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp

    r27235 r27236  
    2626#include <QDesktopWidget>
    2727#include <QMenuBar>
     28#include <QScrollBar>
    2829#include <QTimer>
    2930
     
    9091}
    9192
    92 void UIMachineViewNormal::sltAdditionsStateChanged()
    93 {
    94     /* Check if we should restrict minimum size: */
    95     maybeRestrictMinimumSize();
    96 }
    97 
    9893void UIMachineViewNormal::sltPerformGuestResize(const QSize &toSize)
    9994{
     
    132127}
    133128
    134 /* If the desktop geometry is set automatically, this will update it: */
     129void UIMachineViewNormal::sltAdditionsStateChanged()
     130{
     131    /* Check if we should restrict minimum size: */
     132    maybeRestrictMinimumSize();
     133}
     134
    135135void UIMachineViewNormal::sltDesktopResized()
    136136{
     137    /* If the desktop geometry is set automatically, this will update it: */
    137138    calculateDesktopGeometry();
    138139}
     
    142143    switch (pEvent->type())
    143144    {
    144         case VBoxDefs::ResizeEventType:
    145         {
    146             /* Some situations require framebuffer resize events to be ignored,
    147              * leaving machine window & machine view & framebuffer sizes preserved: */
    148             if (uisession()->isGuestResizeIgnored())
    149                 return true;
    150 
    151             /* We are starting to perform machine view resize: */
    152             bool oldIgnoreMainwndResize = isMachineWindowResizeIgnored();
    153             setMachineWindowResizeIgnored(true);
    154 
    155             /* Get guest resize-event: */
    156             UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);
    157 
    158             /* Perform framebuffer resize: */
    159             frameBuffer()->resizeEvent(pResizeEvent);
    160 
    161             /* Reapply maximum size restriction for machine view: */
    162             setMaximumSize(sizeHint());
    163 
    164             /* Store the new size to prevent unwanted resize hints being sent back. */
    165             storeConsoleSize(pResizeEvent->width(), pResizeEvent->height());
    166 
    167             /* Resize the guest canvas: */
    168             resize(pResizeEvent->width(), pResizeEvent->height());
    169 
    170             /* Let our toplevel widget calculate its sizeHint properly. */
    171 #ifdef Q_WS_X11
    172             /* We use processEvents rather than sendPostedEvents & set the time out value to max cause on X11 otherwise
    173              * the layout isn't calculated correctly. Dosn't find the bug in Qt, but this could be triggered through
    174              * the async nature of the X11 window event system. */
    175             QCoreApplication::processEvents(QEventLoop::AllEvents, INT_MAX);
    176 #else /* Q_WS_X11 */
    177             QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest);
    178 #endif /* Q_WS_X11 */
    179 
    180 #ifdef Q_WS_MAC
    181             // TODO_NEW_CORE
    182 //            mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height());
    183 #endif /* Q_WS_MAC */
    184 
    185             /* Update mouse cursor shape: */
    186             updateMouseCursorShape();
    187 #ifdef Q_WS_WIN32
    188             updateMouseCursorClipping();
    189 #endif
    190 
    191             /* May be we have to restrict minimum size? */
    192             maybeRestrictMinimumSize();
    193 
    194             /* Update machine view sliders: */
    195             updateSliders();
    196 
    197             /* Normalize geometry: */
    198             normalizeGeometry(true /* adjustPosition */);
    199 
    200             /* Report to the VM thread that we finished resizing */
    201             session().GetConsole().GetDisplay().ResizeCompleted(screenId());
    202 
    203             /* We are finishing to perform machine view resize: */
    204             setMachineWindowResizeIgnored(oldIgnoreMainwndResize);
    205 
    206             /* Make sure that all posted signals are processed: */
    207             qApp->processEvents();
    208 
    209             /* We also recalculate the desktop geometry if this is determined
    210              * automatically.  In fact, we only need this on the first resize,
    211              * but it is done every time to keep the code simpler. */
    212             calculateDesktopGeometry();
    213 
    214             /* Emit a signal about guest was resized: */
    215             emit resizeHintDone();
    216 
    217             return true;
    218         }
    219 
    220145        case QEvent::KeyPress:
    221146        case QEvent::KeyRelease:
    222147        {
     148            /* Get key-event: */
    223149            QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent);
    224150
     151            /* Process Host+Home as menu-bar activator: */
    225152            if (isHostKeyPressed() && pEvent->type() == QEvent::KeyPress)
    226153            {
    227                 /* Process Host+Home as menu-bar activator: */
    228154                if (pKeyEvent->key() == Qt::Key_Home)
    229155                {
     
    411337}
    412338
     339void UIMachineViewNormal::updateSliders()
     340{
     341    QSize p = viewport()->size();
     342    QSize m = maximumViewportSize();
     343
     344    QSize v = QSize(frameBuffer()->width(), frameBuffer()->height());
     345    /* No scroll bars needed: */
     346    if (m.expandedTo(v) == m)
     347        p = m;
     348
     349    horizontalScrollBar()->setRange(0, v.width() - p.width());
     350    verticalScrollBar()->setRange(0, v.height() - p.height());
     351    horizontalScrollBar()->setPageStep(p.width());
     352    verticalScrollBar()->setPageStep(p.height());
     353}
     354
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h

    r27124 r27236  
    7878    QRect availableGeometry();
    7979    void maybeRestrictMinimumSize();
     80    void updateSliders();
    8081
    8182    /* Private members: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp

    r27235 r27236  
    147147    switch (pEvent->type())
    148148    {
    149         case VBoxDefs::ResizeEventType:
    150         {
    151             /* Some situations require framebuffer resize events to be ignored,
    152              * leaving machine window & machine view & framebuffer sizes preserved: */
    153             if (uisession()->isGuestResizeIgnored())
    154                 return true;
    155 
    156             /* We are starting to perform machine view resize: */
    157             bool oldIgnoreMainwndResize = isMachineWindowResizeIgnored();
    158             setMachineWindowResizeIgnored(true);
    159 
    160             /* Get guest resize-event: */
    161             UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);
    162 
    163             /* Perform framebuffer resize: */
    164             frameBuffer()->resizeEvent(pResizeEvent);
    165 
    166             /* Reapply maximum size restriction for machine view: */
    167             setMaximumSize(sizeHint());
    168 
    169             /* Store the new size to prevent unwanted resize hints being sent back: */
    170             storeConsoleSize(pResizeEvent->width(), pResizeEvent->height());
    171 
    172             /* Perform machine view resize: */
    173             resize(pResizeEvent->width(), pResizeEvent->height());
    174 
    175             /* Let our toplevel widget calculate its sizeHint properly. */
    176 #ifdef Q_WS_X11
    177             /* We use processEvents rather than sendPostedEvents & set the time out value to max cause on X11 otherwise
    178              * the layout isn't calculated correctly. Dosn't find the bug in Qt, but this could be triggered through
    179              * the async nature of the X11 window event system. */
    180             QCoreApplication::processEvents(QEventLoop::AllEvents, INT_MAX);
    181 #else /* Q_WS_X11 */
    182             QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest);
    183 #endif /* Q_WS_X11 */
    184 
    185 #ifdef Q_WS_MAC
    186             // TODO_NEW_CORE
    187             //mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height());
    188 #endif /* Q_WS_MAC */
    189 
    190             /* Update mouse cursor shape: */
    191             updateMouseCursorShape();
    192 #ifdef Q_WS_WIN32
    193             updateMouseCursorClipping();
    194 #endif
    195 
    196             /* Report to the VM thread that we finished resizing: */
    197             session().GetConsole().GetDisplay().ResizeCompleted(screenId());
    198 
    199             /* We are finishing to perform machine view resize: */
    200             setMachineWindowResizeIgnored(oldIgnoreMainwndResize);
    201 
    202             /* Make sure that all posted signals are processed: */
    203             qApp->processEvents();
    204 
    205             /* We also recalculate the desktop geometry if this is determined automatically.
    206              * In fact, we only need this on the first resize,
    207              * but it is done every time to keep the code simpler. */
    208             calculateDesktopGeometry();
    209 
    210             /* Emit a signal about guest was resized: */
    211             emit resizeHintDone();
    212 
    213             return true;
    214         }
    215 
    216149        case VBoxDefs::SetRegionEventType:
    217150        {
     151            /* Get region-update event: */
    218152            UISetRegionEvent *pSetRegionEvent = static_cast<UISetRegionEvent*>(pEvent);
     153
     154            /* Apply new region: */
    219155            if (pSetRegionEvent->region() != m_lastVisibleRegion)
    220156            {
     
    228164        case QEvent::KeyRelease:
    229165        {
     166            /* Get key-event: */
    230167            QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent);
    231168
     169            /* Process Host+Home for menu popup: */
    232170            if (isHostKeyPressed() && pEvent->type() == QEvent::KeyPress)
    233171            {
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.h

    r27124 r27236  
    7474
    7575    /* Private helpers: */
     76    void normalizeGeometry(bool /* fAdjustPosition */) {}
    7677    QRect availableGeometry();
     78    void maybeRestrictMinimumSize() {}
     79    void updateSliders() {}
    7780
    7881    /* Private variables: */
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