VirtualBox

Changeset 52902 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 30, 2014 3:38:46 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI rework/cleanup for 7115 (part #1): Cleanup for code touched by r96322.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r52894 r52902  
    222222    , mSelectorWnd (NULL)
    223223    , m_pVirtualMachine(0)
    224     , mIsSeparate(false)
     224    , m_fSeparateProcess(false)
    225225    , m_pMediumEnumerator(0)
    226226    , mIsKWinManaged (false)
     
    39833983    mShowStartVMErrors = true;
    39843984    bool startVM = false;
    3985     bool fSeparate = false;
     3985    bool fSeparateProcess = false;
    39863986    QString vmNameOrUuid;
    39873987
     
    40054005        else if (!::strcmp (arg, "-separate") || !::strcmp (arg, "--separate"))
    40064006        {
    4007             fSeparate = true;
     4007            fSeparateProcess = true;
    40084008        }
    40094009#ifdef VBOX_GUI_WITH_PIDFILE
     
    41414141    if (startVM)
    41424142    {
    4143         /* mIsSeparate makes sense only if a VM is started. */
    4144         mIsSeparate = fSeparate;
     4143        /* m_fSeparateProcess makes sense only if a VM is started. */
     4144        m_fSeparateProcess = fSeparateProcess;
    41454145
    41464146        QUuid uuid = QUuid(vmNameOrUuid);
     
    46144614        if (enmLaunchMode == LaunchMode_Separate)
    46154615        {
    4616             KMachineState s = machine.GetState();
    4617             if (   s >= KMachineState_FirstOnline
    4618                 && s <= KMachineState_LastOnline)
     4616            KMachineState state = machine.GetState();
     4617            if (   state >= KMachineState_FirstOnline
     4618                && state <= KMachineState_LastOnline)
    46194619            {
    46204620                /* Already running. */
     
    46304630     * Hope 1 minute will be enough to spawn any running VM silently,
    46314631     * otherwise we better show the progress...
    4632      * If starting separately, then show the progress now.
    4633      */
    4634     int iSpawningDuration = enmLaunchMode == LaunchMode_Separate?
    4635                                 0:
    4636                                 60000;
     4632     * If starting separately, then show the progress now. */
     4633    int iSpawningDuration = enmLaunchMode == LaunchMode_Separate ? 0 : 60000;
    46374634    msgCenter().showModalProgressDialog(progress, machine.GetName(),
    46384635                                        ":/progress_start_90px.png", 0, iSpawningDuration);
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r52894 r52902  
    6868public:
    6969
     70    /** VM launch modes. */
     71    enum LaunchMode
     72    {
     73        LaunchMode_Default,
     74        LaunchMode_Headless,
     75        LaunchMode_Separate
     76    };
     77
    7078    /* Static API: Create/destroy stuff: */
    7179    static VBoxGlobal* instance();
     
    8795    bool isBeta() const;
    8896
    89     bool isSeparate() const { return mIsSeparate; }
     97    /** Returns whether GUI is separate (from VM) process. */
     98    bool isSeparateProcess() const { return m_fSeparateProcess; }
    9099
    91100#ifdef Q_WS_MAC
     
    122131    bool switchToMachine(CMachine &machine);
    123132
    124     enum LaunchMode
    125     {
    126         LaunchMode_Default,
    127         LaunchMode_Headless,
    128         LaunchMode_Separate
    129     };
    130133    bool launchMachine(CMachine &machine, LaunchMode enmLaunchMode = LaunchMode_Default);
    131134
     
    430433    UIMachine *m_pVirtualMachine;
    431434
    432     bool mIsSeparate;
     435    /** Holds whether GUI is separate (from VM) process. */
     436    bool m_fSeparateProcess;
    433437
    434438    QString vmUuid;
  • trunk/src/VBox/Frontends/VirtualBox/src/hardenedmain.cpp

    r52894 r52902  
    4242int main(int argc, char **argv, char **envp)
    4343{
    44     /*
    45      * First check whether we're about to start a VM.
    46      */
     44    /* First check whether we're about to start a VM: */
    4745    bool fStartVM = false;
    48     bool fSeparate = false;
    49     for (int i = 1; i < argc && !(fStartVM && fSeparate); i++)
     46    /* In separate process: */
     47    bool fSeparateProcess = false;
     48    for (int i = 1; i < argc && !(fStartVM && fSeparateProcess); ++i)
    5049    {
    5150        /* NOTE: the check here must match the corresponding check for the
     
    6059                 || !MyStrCmp(argv[i], "-separate"))
    6160        {
    62             fSeparate = true;
     61            fSeparateProcess = true;
    6362        }
    6463    }
    6564
    66     uint32_t fFlags = (fStartVM && !fSeparate)? 0: SUPSECMAIN_FLAGS_DONT_OPEN_DEV;
     65    uint32_t fFlags = (fStartVM && !fSeparateProcess) ? 0 : SUPSECMAIN_FLAGS_DONT_OPEN_DEV;
    6766
    6867    return SUPR3HardenedMain("VirtualBox", fFlags | SUPSECMAIN_FLAGS_TRUSTED_ERROR, argc, argv, envp);
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r52894 r52902  
    301301    if (!VBoxXInitThreads())
    302302        return 1;
    303 #endif
     303#endif /* Q_WS_X11 */
    304304
    305305    /* Simulate try-catch block: */
     
    516516    if (!VBoxXInitThreads())
    517517        return 1;
    518 #endif
     518#endif /* Q_WS_X11 */
     519
    519520    /* Initialize VBox Runtime.
    520521     * Initialize the SUPLib as well only if we are really about to start a VM.
    521      * Don't do this if we are only starting the selector window
    522      * or a separate VM process. */
     522     * Don't do this if we are only starting the selector window or a separate VM process. */
    523523    bool fStartVM = false;
    524     bool fSeparate = false;
    525     for (int i = 1; i < argc && !(fStartVM && fSeparate); ++i)
     524    bool fSeparateProcess = false;
     525    for (int i = 1; i < argc && !(fStartVM && fSeparateProcess); ++i)
    526526    {
    527527        /* NOTE: the check here must match the corresponding check for the
     
    536536                 || !::strcmp(argv[i], "-separate"))
    537537        {
    538             fSeparate = true;
     538            fSeparateProcess = true;
    539539        }
    540540    }
    541541
    542     uint32_t fFlags = fStartVM && !fSeparate? RTR3INIT_FLAGS_SUPLIB: 0;
     542    uint32_t fFlags = fStartVM && !fSeparateProcess ? RTR3INIT_FLAGS_SUPLIB : 0;
    543543
    544544    int rc = RTR3InitExe(argc, &argv, fFlags);
     
    550550         * just to show the only one error-message: */
    551551        QApplication a(argc, &argv[0]);
     552        Q_UNUSED(a);
     553
    552554#ifdef Q_OS_SOLARIS
    553555        /* Use plastique look&feel for Solaris instead of the default motif (Qt 4.7.x): */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp

    r52894 r52902  
    202202
    203203    com::SafeArray<FramebufferCapabilities_T> caps;
    204     if (vboxGlobal().isSeparate())
     204    if (vboxGlobal().isSeparateProcess())
    205205    {
    206206       caps.resize(1);
     
    221221{
    222222    CDisplaySourceBitmap sourceBitmap;
    223     if (!vboxGlobal().isSeparate())
     223    if (!vboxGlobal().isSeparateProcess())
    224224        m_pMachineView->session().GetConsole().GetDisplay().QuerySourceBitmap(uScreenId, sourceBitmap);
    225225
     
    248248    m_pendingSyncVisibleRegion = QRegion();
    249249
    250     if (!vboxGlobal().isSeparate())
     250    if (!vboxGlobal().isSeparateProcess())
    251251    {
    252252       /* Acquire new pending bitmap: */
     
    317317                                              ComSafeArrayIn(BYTE, image))
    318318{
     319    // TODO: Retina handling..
     320
     321    /* Copying received data (is it shallow?): */
    319322    com::SafeArray<BYTE> imageData(ComSafeArrayInArg(image));
    320323
    321     lock();
     324    /* Lock access to frame-buffer: */
     325    lock();
     326
     327    // TODO: Why does this handling so different from UIFrameBuffer::NotifyUpdate?
     328    //       And where is the part about m_fUnused?
    322329
    323330    if (m_fUpdatesAllowed)
    324331    {
    325         /* Copy to m_image */
     332        /* Copy to m_image: */
    326333        uchar *pu8Dst = m_image.bits() + uY * m_image.bytesPerLine() + uX * 4;
    327334        uchar *pu8Src = imageData.raw();
     
    339346    }
    340347
    341     unlock();
    342    
     348    /* Unlock access to frame-buffer: */
     349    unlock();
     350
     351    /* Confirm NotifyUpdateImage: */
    343352    return S_OK;
    344353}
     
    545554
    546555    /* If there is NO pending source-bitmap: */
    547     if (!vboxGlobal().isSeparate() && m_pendingSourceBitmap.isNull())
     556    if (!vboxGlobal().isSeparateProcess() && m_pendingSourceBitmap.isNull())
    548557    {
    549558        /* Do nothing, change-event already processed: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h

    r52574 r52902  
    125125      * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
    126126    STDMETHOD(NotifyUpdate)(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight);
    127     /** EMT callback which is not used in current implementation. */
     127
     128    /** EMT callback: Notifies frame-buffer about guest-screen update.
     129      * @param        uX      Horizontal origin of the update rectangle, in pixels.
     130      * @param        uY      Vertical origin of the update rectangle, in pixels.
     131      * @param        uWidth  Width of the update rectangle, in pixels.
     132      * @param        uHeight Height of the update rectangle, in pixels.
     133      * @param        image   Brings image container which can be used to copy data from.
     134      * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     135      * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
    128136    STDMETHOD(NotifyUpdateImage)(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight, ComSafeArrayIn(BYTE, image));
    129137
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r52894 r52902  
    826826            VBoxGlobal::tr("Disabled", "details report (Unrestricted Execution)");
    827827
     828        /* Get machine: */
    828829        const CMachine machine = console.GetMachine();
    829830        if (machine.isNull())
     
    10701071    /* Acquire current states from the console: */
    10711072    CConsole console = m_session.GetConsole();
    1072     if (console.isNull())
     1073    if (!m_session.isOk() || console.isNull())
    10731074        return;
    10741075    const QVector<KDeviceActivity> states = console.GetDeviceActivity(deviceTypes);
    1075     if (!console.isOk())
    1076         return;
     1076    AssertReturnVoid(console.isOk());
    10771077
    10781078    /* Update indicators with the acquired states: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r52894 r52902  
    9393bool UIMachine::create(UIMachine **ppSelf)
    9494{
    95     UIMachine *pVirtualMachine = new UIMachine(ppSelf);
    96     if (!pVirtualMachine)
     95    UIMachine *pMachine = new UIMachine(ppSelf);
     96    if (!pMachine)
    9797        return false;
    98     return pVirtualMachine->prepare();
     98    return pMachine->prepare();
    9999}
    100100
     
    103103    , m_ppThis(ppSelf)
    104104    , initialStateType(UIVisualStateType_Normal)
    105     , m_session()
    106105    , m_pSession(0)
    107106    , m_pVisualState(0)
     
    116115{
    117116    KLockType lockType;
    118     if (vboxGlobal().isSeparate())
    119     {
    120         /* Search for the corresponding machine: */
     117    if (!vboxGlobal().isSeparateProcess())
     118    {
     119        lockType = KLockType_VM;
     120    }
     121    else
     122    {
     123        /* Try to find corresponding machine: */
    121124        CVirtualBox virtualBox = vboxGlobal().virtualBox();
    122125        CMachine machine = virtualBox.FindMachine(vboxGlobal().managedVMUuid());
     
    127130        }
    128131
     132        /* Try to launch corresponding machine: */
    129133        if (!vboxGlobal().launchMachine(machine, VBoxGlobal::LaunchMode_Separate))
    130134            return false;
    131135
    132136        lockType = KLockType_Shared;
    133     }
    134     else
    135     {
    136         lockType = KLockType_VM;
    137137    }
    138138
     
    165165    /* Now power up the machine.
    166166     * Actually powerUp does more that just a power up,
    167      * so call it regardless of isSeparate setting.
    168      */
     167     * so call it regardless of isSeparateProcess setting. */
    169168    uisession()->powerUp();
    170169
    171170    /* Initialization of MachineLogic internals after the powerUp.
    172      * This is a hack, maybe more generic approach can be used.
    173      */
     171     * This is a hack, maybe more generic approach can be used. */
    174172    machineLogic()->initializePostPowerUp();
    175173
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r52894 r52902  
    677677    shot.fill(0);
    678678    CDisplay dsp = session().GetConsole().GetDisplay();
    679     if (vboxGlobal().isSeparate())
     679    if (vboxGlobal().isSeparateProcess())
    680680    {
    681681        QVector<BYTE> screenData = dsp.TakeScreenShotToArray(screenId(), shot.width(), shot.height(), KBitmapFormat_BGR0);
     
    10891089            /* Can't do COM inter-process calls from a SendMessage handler,
    10901090             * see http://support.microsoft.com/kb/131056 */
    1091             if (vboxGlobal().isSeparate() && InSendMessage())
     1091            if (vboxGlobal().isSeparateProcess() && InSendMessage())
    10921092            {
    10931093                PostMessage(pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r52894 r52902  
    272272
    273273    /* If VM process is running separately, then leave it alone and close UI: */
    274     if (vboxGlobal().isSeparate())
     274    if (vboxGlobal().isSeparateProcess())
    275275    {
    276276        uisession()->closeRuntimeUI();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r52894 r52902  
    261261    }
    262262
    263     if (!vboxGlobal().isSeparate())
     263    if (!vboxGlobal().isSeparateProcess())
    264264    {
    265265        /* Power UP machine: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r52894 r52902  
    476476        /* Launch/show current VM: */
    477477        CMachine machine = pItem->machine();
    478         vboxGlobal().launchMachine(machine, qApp->keyboardModifiers() == Qt::ShiftModifier?
    479                                                 VBoxGlobal::LaunchMode_Headless:
    480                                                 VBoxGlobal::LaunchMode_Default);
     478        vboxGlobal().launchMachine(machine, qApp->keyboardModifiers() == Qt::ShiftModifier ?
     479                                            VBoxGlobal::LaunchMode_Headless :
     480                                            VBoxGlobal::LaunchMode_Default);
    481481    }
    482482}
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