VirtualBox

Changeset 7435 in vbox


Ignore:
Timestamp:
Mar 12, 2008 4:01:15 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
28873
Message:

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

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

Legend:

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

    r7407 r7435  
    189189private:
    190190
     191    void sendInitialSizeHint(void);
    191192    void maybeRestrictMinimumSize();
    192193
     
    280281    CGImageRef mVirtualBoxLogo;
    281282#endif
     283    QSize mLastSizeHint;
    282284};
    283285
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDefs.h

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

    r7407 r7435  
    28572857                }
    28582858            }
     2859            else if (mLastState == KMachineState_Starting)
     2860            {
     2861                /* Suggest an initial size. */
     2862                sendInitialSizeHint ();
     2863            }
    28592864            /* reuse the focus event handler to capture input */
    28602865            if (hasFocus())
    28612866                focusEvent (true /* aHasFocus */);
    28622867            break;
     2868        }
     2869        case KMachineState_Stopping:
     2870        {
     2871            if (mLastSizeHint.isValid())
     2872            {
     2873                CMachine cmachine = mConsole.GetMachine();
     2874                QString str = QString ("%1,%2")
     2875                                      .arg (mLastSizeHint.width())
     2876                                      .arg (mLastSizeHint.height());
     2877                cmachine.SetExtraData (VBoxDefs::GUI_LastSizeHint, str);
     2878            }
    28632879        }
    28642880        default:
     
    35633579
    35643580        mConsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0, 0);
    3565     }
     3581        mLastSizeHint = sz;
     3582    }
     3583}
     3584
     3585 
     3586/**
     3587 * We send an initial size hint to the VM on startup, so that it can choose
     3588 * an initial size which is well-readable on the host screen.
     3589 */
     3590void VBoxConsoleView::sendInitialSizeHint(void)
     3591{
     3592    CMachine cmachine = mConsole.GetMachine();
     3593    QString str = cmachine.GetExtraData (VBoxDefs::GUI_LastSizeHint);
     3594    int w = 0, h = 0;
     3595    bool ok = true;
     3596    w = str.section (',', 0, 0).toInt (&ok);
     3597    if (ok)
     3598        h = str.section (',', 1, 1).toInt (&ok);
     3599    QRect screen = QApplication::desktop()->screenGeometry (this);
     3600    if (!ok || w > screen.width() || h > screen.height())
     3601    {
     3602        enum { NUM_RES = 4 };
     3603        const int sizeList[NUM_RES][2] =
     3604        {
     3605            { 640, 480 },
     3606            { 800, 600 },
     3607            { 1024, 768 },
     3608            { 1280, 960 }
     3609        };
     3610        unsigned i = 0;
     3611
     3612        /* Find a size that is smaller than three quarters of the reported
     3613           screen geometry. */
     3614        while (   (i + 1 < NUM_RES)
     3615               && (sizeList[i + 1][0] < screen.width() * 3 / 4)
     3616               && (sizeList[i + 1][1] < screen.height() * 3 / 4))
     3617            ++i;
     3618        w = sizeList[i][0];
     3619        h = sizeList[i][1];
     3620    }
     3621    LogFlowFunc (("Will suggest %d x %d\n", w, h));
     3622    mConsole.GetDisplay().SetVideoModeHint (w, h, 0, 0);
    35663623}
    35673624
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDefs.cpp

    r7188 r7435  
    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