VirtualBox

Changeset 27124 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Mar 5, 2010 6:30:32 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4: New running VM core: restoring guest size hint on exiting fullscreen/seamless modes.

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

Legend:

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

    r27081 r27124  
    2626/* Global includes */
    2727#include <QAbstractScrollArea>
     28#include <QEventLoop>
    2829
    2930/* Local includes */
     
    281282};
    282283
     284/* This maintenance class is a part of future roll-back mechanism.
     285 * It allows to block main GUI thread until specific event received.
     286 * Later it will become more abstract but now its just used to help
     287 * fullscreen & seamless modes to restore normal guest size hint. */
     288class UIMachineViewBlocker : public QEventLoop
     289{
     290    Q_OBJECT;
     291
     292public:
     293
     294    UIMachineViewBlocker(QObject *pWatchedObject)
     295        : QEventLoop(0)
     296        , m_iTimerId(0)
     297    {
     298        /* Install object event watcher: */
     299        pWatchedObject->installEventFilter(this);
     300
     301        /* Also start timer to unlock pool in case of
     302         * required condition doesn't happens by some reason: */
     303        m_iTimerId = startTimer(3000);
     304    }
     305
     306    virtual ~UIMachineViewBlocker()
     307    {
     308        /* Kill the timer: */
     309        killTimer(m_iTimerId);
     310    }
     311
     312protected:
     313
     314    bool eventFilter(QObject *pWatched, QEvent *pEvent)
     315    {
     316        switch (pEvent->type())
     317        {
     318            case VBoxDefs::ResizeEventType:
     319            {
     320                /* Its a specific part related to fullscreen/seamless modes.
     321                 * Here we are waiting for guest resize event to be sure what
     322                 * non-normal modes successfully restored previous guest size hint.
     323                 * And we just unlocking the 'this' blocker afterwards: */
     324                exit();
     325                return false;
     326            }
     327            default:
     328                break;
     329        }
     330        return QEventLoop::eventFilter(pWatched, pEvent);
     331    }
     332
     333    void timerEvent(QTimerEvent *pEvent)
     334    {
     335        /* If that timer event occurs => it seems
     336         * guest resize event doesn't comes in time,
     337         * shame on it, but we just unlocking 'this': */
     338        QEventLoop::timerEvent(pEvent);
     339        exit();
     340    }
     341
     342    int m_iTimerId;
     343};
     344
    283345#endif // !___UIMachineViewNormal_h___
    284346
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r26998 r27124  
    633633}
    634634
     635QSize UISession::guestSizeHint(ulong uScreenId) const
     636{
     637    return (int)uScreenId < m_guestSizeHints.size() ? m_guestSizeHints[uScreenId] : QSize();
     638}
     639
    635640bool UISession::setPause(bool fOn)
    636641{
     
    655660
    656661    return ok;
     662}
     663
     664void UISession::setGuestSizeHint(ulong uScreenId, QSize size)
     665{
     666    if ((int)uScreenId < m_guestSizeHints.size())
     667        m_guestSizeHints[uScreenId] = size;
    657668}
    658669
     
    923934    }
    924935
    925 
    926936    /* Load extra-data settings: */
    927937    {
     
    945955        pGuestAutoresizeSwitch->setChecked(strSettings != "off");
    946956        pGuestAutoresizeSwitch->blockSignals(false);
     957    }
     958
     959    /* Some initialization: */
     960    {
     961        /* Initial guest size hints: */
     962        m_guestSizeHints.clear();
     963        for (ulong i = 0; i < machine.GetMonitorCount(); ++ i)
     964            m_guestSizeHints << QSize(640, 480);
    947965    }
    948966}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r26996 r27124  
    8080    UIActionsPool* actionsPool() const;
    8181    QMenuBar* newMenuBar();
     82    QSize guestSizeHint(ulong uScreenId) const;
    8283
    8384    bool isSaved() const { return machineState() == KMachineState_Saved; }
     
    122123    bool setPause(bool fOn);
    123124    void setGuestResizeIgnored(bool fIsGuestResizeIgnored) { m_fIsGuestResizeIgnored = fIsGuestResizeIgnored; }
     125    void setGuestSizeHint(ulong uScreenId, QSize size);
    124126
    125127    /* Keyboard setters: */
     
    191193    HCURSOR m_alphaCursor;
    192194#endif
     195    QList<QSize> m_guestSizeHints;
    193196
    194197    /* Common flags: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp

    r27101 r27124  
    8080UIMachineViewFullscreen::~UIMachineViewFullscreen()
    8181{
     82    /* Cleanup fullscreen: */
     83    cleanupFullscreen();
     84
    8285    /* Cleanup common things: */
    8386    cleanupCommon();
     
    342345}
    343346
     347void UIMachineViewFullscreen::cleanupFullscreen()
     348{
     349    /* Rollback fullscreen frame-buffer size to normal: */
     350    machineWindowWrapper()->machineWindow()->hide();
     351    UIMachineViewBlocker blocker(this);
     352    sltPerformGuestResize(uisession()->guestSizeHint(screenId()));
     353    blocker.exec();
     354}
     355
    344356void UIMachineViewFullscreen::setGuestAutoresizeEnabled(bool fEnabled)
    345357{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h

    r27101 r27124  
    6464    void prepareConnections();
    6565    void prepareConsoleConnections();
     66    //void prepareFullscreen() {}
    6667
    6768    /* Cleanup routines: */
     69    void cleanupFullscreen();
    6870    //void cleanupConsoleConnections() {}
    6971    //void cleanupConnections() {}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp

    r27093 r27124  
    8080UIMachineViewNormal::~UIMachineViewNormal()
    8181{
     82    /* Save machine view settings: */
     83    saveMachineViewSettings();
     84
    8285    /* Cleanup common things: */
    8386    cleanupCommon();
     
    341344}
    342345
     346void UIMachineViewNormal::saveMachineViewSettings()
     347{
     348    /* Store guest size hint: */
     349    uisession()->setGuestSizeHint(screenId(), QSize(frameBuffer()->width(), frameBuffer()->height()));
     350}
     351
    343352void UIMachineViewNormal::setGuestAutoresizeEnabled(bool fEnabled)
    344353{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h

    r27090 r27124  
    6363    void prepareConnections();
    6464    void prepareConsoleConnections();
     65    //void loadMachineViewSettings();
    6566
    6667    /* Cleanup helpers: */
     68    void saveMachineViewSettings();
    6769    //void cleanupConsoleConnections() {}
    6870    //void prepareConnections() {}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp

    r27101 r27124  
    9494}
    9595
    96 void UIMachineViewSeamless::sltPerformGuestResize()
    97 {
    98     /* Get machine window: */
    99     QIMainDialog *pMachineWindow = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ?
    100                                 qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow()) : 0;
    101 
    102     /* Get the available size for the guest display. We assume here that
    103      * centralWidget() contains only this machine view and gives it all available space: */
    104     QSize newSize(pMachineWindow ? pMachineWindow->centralWidget()->size() : QSize());
    105     AssertMsg(newSize.isValid(), ("Size should be valid!\n"));
    106 
    107     /* Do not send the same hints as we already have: */
    108     if ((newSize.width() == storedConsoleSize().width()) && (newSize.height() == storedConsoleSize().height()))
    109         return;
    110 
    111     /* If we awaiting resize: */
    112     if (m_fShouldWeDoResize)
     96void UIMachineViewSeamless::sltPerformGuestResize(const QSize &toSize)
     97{
     98    if (uisession()->isGuestSupportsGraphics())
    11399    {
    114         /* Remember the new size: */
    115         storeConsoleSize(newSize.width(), newSize.height());
    116 
    117         /* Send new size-hint to the guest: */
    118         session().GetConsole().GetDisplay().SetVideoModeHint(newSize.width(), newSize.height(), 0, screenId());
     100        /* Get machine window: */
     101        QIMainDialog *pMachineWindow = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ?
     102                                       qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow()) : 0;
     103
     104        /* If this slot is invoked directly then use the passed size otherwise get
     105         * the available size for the guest display. We assume here that centralWidget()
     106         * contains this view only and gives it all available space: */
     107        QSize newSize(toSize.isValid() ? toSize : pMachineWindow ? pMachineWindow->centralWidget()->size() : QSize());
     108        AssertMsg(newSize.isValid(), ("Size should be valid!\n"));
     109
     110        /* Do not send the same hints as we already have: */
     111        if ((newSize.width() == storedConsoleSize().width()) && (newSize.height() == storedConsoleSize().height()))
     112            return;
     113
     114        /* We only actually send the hint if either an explicit new size was given
     115         * (e.g. if the request was triggered directly by a console resize event) or
     116         * if no explicit size was specified but a resize is flagged as being needed
     117         * (e.g. the autoresize was just enabled and the console was resized while it was disabled). */
     118        if (toSize.isValid() || m_fShouldWeDoResize)
     119        {
     120            /* Remember the new size: */
     121            storeConsoleSize(newSize.width(), newSize.height());
     122
     123            /* Send new size-hint to the guest: */
     124            session().GetConsole().GetDisplay().SetVideoModeHint(newSize.width(), newSize.height(), 0, screenId());
     125        }
     126
     127        /* We had requested resize now, rejecting other accident requests: */
     128        m_fShouldWeDoResize = false;
    119129    }
    120 
    121     /* We had requested resize now, rejecting other accident requests: */
    122     m_fShouldWeDoResize = false;
    123130}
    124131
     
    355362    /* Reset seamless feature flag of the guest: */
    356363    session().GetConsole().GetDisplay().SetSeamlessMode(false);
     364
     365    /* Rollback seamless frame-buffer size to normal: */
     366    machineWindowWrapper()->machineWindow()->hide();
     367    UIMachineViewBlocker blocker(this);
     368    sltPerformGuestResize(uisession()->guestSizeHint(screenId()));
     369    blocker.exec();
    357370}
    358371
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.h

    r27101 r27124  
    4545
    4646    /* Slot to perform guest resize: */
    47     void sltPerformGuestResize();
     47    void sltPerformGuestResize(const QSize &aSize = QSize());
    4848
    4949    /* Console callback handlers: */
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