VirtualBox

Changeset 27052 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 4, 2010 6:44:12 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4: New running VM core: seamless reworked to use 'maximized' state; some fullscreen functionality merged into seamless.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless
Files:
3 edited

Legend:

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

    r27012 r27052  
    2525#include <QApplication>
    2626#include <QDesktopWidget>
     27#include <QTimer>
    2728#ifdef Q_WS_MAC
    2829#include <QMenuBar>
     
    5152#endif
    5253                    , uMonitor)
     54    , m_fIsInitialResizeEventProcessed(false)
     55    , m_fShouldWeDoResize(false)
    5356{
    5457    /* Prepare frame buffer: */
    5558    prepareFrameBuffer();
    5659
    57     /* Prepare backup inforrmation: */
    58     prepareBackup();
    59 
    6060    /* Prepare common things: */
    6161    prepareCommon();
     
    7373    loadMachineViewSettings();
    7474
    75     /* Prepare seamless mode: */
     75    /* Prepare seamless view: */
    7676    prepareSeamless();
    7777
     
    9595}
    9696
     97void UIMachineViewSeamless::sltPerformGuestResize()
     98{
     99    /* Get machine window: */
     100    QIMainDialog *pMainDialog = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ?
     101                                qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow()) : 0;
     102
     103    /* Get the available size for the guest display. We assume here that the centralWidget()
     104     * contains only this machine view and gives it all available space: */
     105    QSize newSize(pMainDialog ? pMainDialog->centralWidget()->size() : QSize());
     106    AssertMsg(newSize.isValid(), ("Size should be valid!\n"));
     107
     108    /* Do not send the same hints as we already have: */
     109    if ((newSize.width() == storedConsoleSize().width()) && (newSize.height() == storedConsoleSize().height()))
     110        return;
     111
     112    /* If we awaiting resize: */
     113    if (m_fShouldWeDoResize)
     114    {
     115        /* Remember the new size: */
     116        storeConsoleSize(newSize.width(), newSize.height());
     117
     118        /* Send new size-hint to the guest: */
     119        session().GetConsole().GetDisplay().SetVideoModeHint(newSize.width(), newSize.height(), 0, screenId());
     120    }
     121
     122    /* We had requested resize now, rejecting other accident requests: */
     123    m_fShouldWeDoResize = false;
     124}
     125
    97126void UIMachineViewSeamless::sltAdditionsStateChanged()
    98127{
     
    100129}
    101130
    102 /* If the desktop geometry is set automatically, this will update it: */
    103131void UIMachineViewSeamless::sltDesktopResized()
    104132{
    105133    // TODO: Try to resize framebuffer according new desktop size, exit seamless if resize is failed!
     134
     135    /* If the desktop geometry is set automatically, this will update it: */
     136    calculateDesktopGeometry();
    106137}
    107138
     
    117148                return true;
    118149
     150            /* We are starting to perform machine view resize: */
     151            bool oldIgnoreMainwndResize = isMachineWindowResizeIgnored();
     152            setMachineWindowResizeIgnored(true);
     153
    119154            /* Get guest resize-event: */
    120155            UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);
     
    125160            /* Reapply maximum size restriction for machine view: */
    126161            setMaximumSize(sizeHint());
     162
     163            /* Store the new size to prevent unwanted resize hints being sent back: */
     164            storeConsoleSize(pResizeEvent->width(), pResizeEvent->height());
    127165
    128166            /* Perform machine view resize: */
     
    143181            //mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height());
    144182#endif /* Q_WS_MAC */
    145 
    146             /* Update machine view sliders: */
    147             updateSliders();
    148183
    149184            /* Unfortunately restoreOverrideCursor() is broken in Qt 4.4.0 if WA_PaintOnScreen widgets are present.
     
    165200            session().GetConsole().GetDisplay().ResizeCompleted(screenId());
    166201
     202            /* We are finishing to perform machine view resize: */
     203            setMachineWindowResizeIgnored(oldIgnoreMainwndResize);
     204
    167205            /* Make sure that all posted signals are processed: */
    168206            qApp->processEvents();
     207
     208            /* We also recalculate the desktop geometry if this is determined automatically.
     209             * In fact, we only need this on the first resize,
     210             * but it is done every time to keep the code simpler. */
     211            calculateDesktopGeometry();
    169212
    170213            /* Emit a signal about guest was resized: */
     
    210253bool UIMachineViewSeamless::eventFilter(QObject *pWatched, QEvent *pEvent)
    211254{
     255    QIMainDialog *pMainDialog = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ?
     256        qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow()) : 0;
     257    if (pWatched != 0 && pWatched == pMainDialog)
     258    {
     259        switch (pEvent->type())
     260        {
     261            case QEvent::Resize:
     262            {
     263                /* Ignore initial resize event: */
     264                if (!m_fIsInitialResizeEventProcessed)
     265                {
     266                    m_fIsInitialResizeEventProcessed = true;
     267                    break;
     268                }
     269
     270                /* Set the "guest needs to resize" hint.
     271                 * This hint is acted upon when (and only when) the autoresize property is "true": */
     272                m_fShouldWeDoResize = uisession()->isGuestSupportsGraphics();
     273                if (!isMachineWindowResizeIgnored() && uisession()->isGuestSupportsGraphics())
     274                    QTimer::singleShot(0, this, SLOT(sltPerformGuestResize()));
     275                break;
     276            }
     277            default:
     278                break;
     279        }
     280    }
    212281#ifdef Q_WS_MAC // TODO: Is it really needed?
    213282    QMenuBar *pMenuBar = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ?
     
    242311}
    243312
    244 void UIMachineViewSeamless::prepareBackup()
    245 {
     313void UIMachineViewSeamless::prepareCommon()
     314{
     315    /* Base class common settings: */
     316    UIMachineView::prepareCommon();
     317
    246318    /* Store old machine view size before bramebuffer resized: */
    247319    m_normalSize = QSize(frameBuffer()->width(), frameBuffer()->height());
     320
     321    /* Minimum size is ignored: */
     322    setMinimumSize(0, 0);
     323    /* No scrollbars: */
     324    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     325    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    248326}
    249327
     
    254332
    255333#ifdef Q_WS_MAC // TODO: Is it really needed? See UIMachineViewSeamless::eventFilter(...);
    256     /* Menu bar filters: */
     334    /* Menu bar filter: */
    257335    qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow())->menuBar()->installEventFilter(this);
    258336#endif
     
    275353void UIMachineViewSeamless::prepareSeamless()
    276354{
     355    /* Set seamless feature flag to the guest: */
    277356    session().GetConsole().GetDisplay().SetSeamlessMode(true);
    278     session().GetConsole().GetDisplay().SetVideoModeHint(machineWindowWrapper()->machineWindow()->width(),
    279                                                          machineWindowWrapper()->machineWindow()->height(), 0, screenId());
    280357}
    281358
    282359void UIMachineViewSeamless::cleanupSeamless()
    283360{
    284     /* Send normal size-hint to the guest: */
     361    /* Reset seamless feature flag of the guest: */
    285362    session().GetConsole().GetDisplay().SetSeamlessMode(false);
    286     session().GetConsole().GetDisplay().SetVideoModeHint(m_normalSize.width(), m_normalSize.height(), 0, screenId());
    287363}
    288364
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.h

    r27028 r27052  
    4444private slots:
    4545
     46    /* Slot to perform guest resize: */
     47    void sltPerformGuestResize();
     48
    4649    /* Console callback handlers: */
    4750    void sltAdditionsStateChanged();
     
    5760
    5861    /* Prepare helpers: */
    59     void prepareBackup();
     62    void prepareCommon();
    6063    void prepareFilters();
    6164    void prepareConnections();
     
    6871    //void prepareConnections() {}
    6972    //void cleanupFilters() {}
    70     //void prepareBackup() {}
     73    //void cleanupCommon();
    7174
    7275    /* Private helpers: */
     
    7477
    7578    /* Private variables: */
     79    bool m_fIsInitialResizeEventProcessed : 1;
     80    bool m_fShouldWeDoResize : 1;
    7681    QRegion m_lastVisibleRegion;
    7782    QSize m_normalSize;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp

    r27039 r27052  
    7878
    7979    /* Show window: */
    80     show();
     80    showMaximized();
    8181}
    8282
     
    157157void UIMachineWindowSeamless::prepareSeamless()
    158158{
    159     /* Move & resize seamless frameless window: */
    160     QRect geometry = QApplication::desktop()->availableGeometry();
    161159#ifdef Q_WS_WIN
    162     m_prevRegion = geometry;
    163 #endif
    164     move(geometry.topLeft());
    165     resize(geometry.size());
     160    m_prevRegion = QApplication::desktop()->availableGeometry();
     161#endif
    166162
    167163#ifdef Q_WS_MAC
     
    172168    ::darwinSetShowsWindowTransparent(this, true);
    173169#endif
    174 
    175     /* Perform these events: */
    176     qApp->processEvents();
    177170}
    178171
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