VirtualBox

Changeset 7335 in vbox


Ignore:
Timestamp:
Mar 6, 2008 5:16:24 PM (17 years ago)
Author:
vboxsync
Message:

Frontends/VirtualBox: remember the last video mode hint sent in the machine XML file and resend it on VM boot

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h

    r7323 r7335  
    285285    CGImageRef mVirtualBoxLogo;
    286286#endif
     287    QSize mLastSizeHint;
    287288};
    288289
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h

    r7188 r7335  
    168168    static const char* GUI_LastVMSelected;
    169169    static const char* GUI_InfoDlgState;
     170    static const char* GUI_LastSizeHint;
    170171};
    171172
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r7322 r7335  
    28682868            break;
    28692869        }
     2870        case KMachineState_Stopping:
     2871        {
     2872            if (mLastSizeHint.isValid())
     2873            {
     2874                CMachine cmachine = mConsole.GetMachine();
     2875                QString str = QString ("%1,%2")
     2876                                      .arg (mLastSizeHint.width())
     2877                                      .arg (mLastSizeHint.height());
     2878                cmachine.SetExtraData (VBoxDefs::GUI_LastSizeHint, str);
     2879            }
     2880        }
    28702881        default:
    28712882            break;
     
    35673578
    35683579        mConsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0, 0);
     3580        mLastSizeHint = sz;
    35693581    }
    35703582}
     
    35773589void VBoxConsoleView::sendInitialSizeHint(void)
    35783590{
    3579     enum { NUM_RES = 4 };
    3580 
    3581     const int sizeList[NUM_RES][2] =
    3582     {
    3583         { 640, 480 },
    3584         { 800, 600 },
    3585         { 1024, 768 },
    3586         { 1280, 960 }
    3587     };
    3588     /** @todo save the last resize hint sent before a VM shutdown in
    3589         the XML and send that on next startup. */
     3591    CMachine cmachine = mConsole.GetMachine();
     3592    QString str = cmachine.GetExtraData (VBoxDefs::GUI_LastSizeHint);
     3593    int w = 0, h = 0;
     3594    bool ok = true;
     3595    w = str.section (',', 0, 0).toInt (&ok);
     3596    if (ok)
     3597        h = str.section (',', 1, 1).toInt (&ok);
    35903598    QRect screen = QApplication::desktop()->screenGeometry (this);
    3591     unsigned i = 0;
    3592     /* Find a size that is smaller than three quarters of the reported
    3593        screen geometry. */
    3594     while (   (i + 1 < NUM_RES)
    3595            && (sizeList[i + 1][0] < screen.width() * 3 / 4)
    3596            && (sizeList[i + 1][1] < screen.height() * 3 / 4))
    3597         ++i;
    3598     LogFlowFunc (("Will suggest %d x %d\n", sizeList[i][0], sizeList[i][1]));
    3599     mConsole.GetDisplay().SetVideoModeHint (sizeList[i][0], sizeList[i][1], 0, 0);
     3599    if (!ok || w > screen.width() || h > screen.height())
     3600    {
     3601        enum { NUM_RES = 4 };
     3602        const int sizeList[NUM_RES][2] =
     3603        {
     3604            { 640, 480 },
     3605            { 800, 600 },
     3606            { 1024, 768 },
     3607            { 1280, 960 }
     3608        };
     3609        unsigned i = 0;
     3610
     3611        /* Find a size that is smaller than three quarters of the reported
     3612           screen geometry. */
     3613        while (   (i + 1 < NUM_RES)
     3614               && (sizeList[i + 1][0] < screen.width() * 3 / 4)
     3615               && (sizeList[i + 1][1] < screen.height() * 3 / 4))
     3616            ++i;
     3617        w = sizeList[i][0];
     3618        h = sizeList[i][1];
     3619    }
     3620    LogFlowFunc (("Will suggest %d x %d\n", w, h));
     3621    mConsole.GetDisplay().SetVideoModeHint (w, h, 0, 0);
    36003622}
    36013623
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxDefs.cpp

    r7188 r7335  
    3636const char* VBoxDefs::GUI_LastVMSelected = "GUI/LastVMSelected";
    3737const char* VBoxDefs::GUI_InfoDlgState = "GUI/InfoDlgState";
     38const char* VBoxDefs::GUI_LastSizeHint = "GUI/LastSizeHint";
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