VirtualBox

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


Ignore:
Timestamp:
Jul 17, 2007 4:12:36 PM (18 years ago)
Author:
vboxsync
Message:

Seamless Mode beta version committed:

  1. Menu item "Seamless Mode" is added into VM menu and linked to "GUI/Seamless" xml-config parameter.
  2. This menu item could be toggled on/off (the starting value is loading from config at startup) but disabled at startup until the guest additions notifies the host about this feature is supported.
  3. After that this mode is activated automatically (in case it was set "on" in config) and can be toggled on/off by the user with Host+S key-shortcut.

Due to any callback to guest additions are not supported yet (afaik) the Seamless Mode's starting screen could be correct (only one guest status-bar displayed) and incorrect sometimes (whole guest desktop). It becomes correct after any guest region update (for example, in case of any guest window is created, moved or resized).

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

Legend:

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

    r2981 r3674  
    9595    void fixModifierState (LONG *codes, uint *count);
    9696
     97    bool isInSeamlessMode();
     98
    9799signals:
    98100
     
    100102    void mouseStateChanged (int state);
    101103    void machineStateChanged (CEnums::MachineState state);
    102     void additionsStateChanged (const QString &, bool);
     104    void additionsStateChanged (const QString &, bool, bool);
    103105
    104106protected:
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h

    r3490 r3674  
    7373    bool isTrueFullscreen() const { return full_screen; }
    7474
     75    bool isTrueSeamless() const { return mIsInSeamlessMode; }
     76
    7577    void setMouseIntegrationLocked (bool);
    7678
     
    120122
    121123    void vmFullscreen (bool on);
     124    void vmSeamless (bool on);
    122125    void vmAutoresizeGuest (bool on);
    123126    void vmAdjustWindow();
     
    162165    void updateMouseState (int state);
    163166
    164     void updateAdditionsState (const QString&, bool);
     167    void updateAdditionsState (const QString&, bool, bool);
    165168
    166169    void tryClose();
     
    177180    // VM actions
    178181    QAction *vmFullscreenAction;
     182    QAction *vmSeamlessAction;
    179183    QAction *vmAutoresizeGuestAction;
    180184    QAction *vmAdjustWindowAction;
     
    279283    // variables for dealing with true fullscreen
    280284    bool full_screen : 1;
     285    bool mIsInSeamlessMode : 1;
    281286    int normal_wflags;
    282287    bool was_max : 1;
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h

    r3483 r3674  
    125125        ResizeEventType = QEvent::User,
    126126        RepaintEventType,
     127        SetRegionEventType,
    127128        MouseCapabilityEventType,
    128129        MousePointerChangeEventType,
     
    143144#if defined (Q_WS_MAC)
    144145        ShowWindowEventType,
    145 #endif 
     146#endif
    146147    };
    147148};
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h

    r3614 r3674  
    104104private:
    105105    int ex, ey, ew, eh;
     106};
     107
     108/**
     109 *  Frame buffer set region event.
     110 */
     111class VBoxSetRegionEvent : public QEvent
     112{
     113public:
     114    VBoxSetRegionEvent (const QRegion &aReg)
     115        : QEvent ((QEvent::Type) VBoxDefs::SetRegionEventType)
     116        , mReg (aReg) {}
     117    QRegion region() { return mReg; }
     118private:
     119    QRegion mReg;
    106120};
    107121
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r3483 r3674  
    231231    GuestAdditionsEvent (const QString &aOsTypeId,
    232232                         const QString &aAddVersion,
    233                          bool aAddActive) :
     233                         bool aAddActive,
     234                         bool aSeamlessActive) :
    234235        QEvent ((QEvent::Type) VBoxDefs::AdditionsStateChangeEventType),
    235         mOsTypeId (aOsTypeId), mAddVersion (aAddVersion), mAddActive (aAddActive) {}
     236        mOsTypeId (aOsTypeId), mAddVersion (aAddVersion),
     237        mAddActive (aAddActive), mSeamlessActive (aSeamlessActive) {}
    236238    const QString &osTypeId() const { return mOsTypeId; }
    237239    const QString &additionVersion() const { return mAddVersion; }
    238240    bool additionActive() const { return mAddActive; }
     241    bool seamlessActive() const { return mSeamlessActive; }
    239242private:
    240243    QString mOsTypeId;
    241244    QString mAddVersion;
    242245    bool mAddActive;
     246    bool mSeamlessActive;
    243247};
    244248
     
    391395                                     guest.GetOSTypeId(),
    392396                                     guest.GetAdditionsVersion(),
    393                                      guest.GetAdditionsActive()));
     397                                     guest.GetAdditionsActive(),
     398                                     guest.GetSeamlessSupport()));
    394399        return S_OK;
    395400    }
     
    935940                 * full screen */
    936941                if (!mainwnd->isTrueFullscreen() &&
     942                    !mainwnd->isTrueSeamless() &&
    937943                    !topLevelWidget()->isMaximized())
    938944                    normalizeGeometry (true /* adjustPosition */);
     
    955961            }
    956962#endif /* Q_WS_MAC */
     963
     964            case VBoxDefs::SetRegionEventType:
     965            {
     966                VBoxSetRegionEvent *sre = (VBoxSetRegionEvent*) e;
     967                mainwnd->setMask (sre->region());
     968                return true;
     969            }
    957970
    958971            case VBoxDefs::MousePointerChangeEventType:
     
    10221035                maybeRestrictMinimumSize();
    10231036
    1024                 emit additionsStateChanged (ge->additionVersion(), ge->additionActive());
     1037                emit additionsStateChanged (ge->additionVersion(),
     1038                                            ge->additionActive(),
     1039                                            ge->seamlessActive());
    10251040                return true;
    10261041            }
     
    12611276                     * variable should be set to true here in case of mainwnd is
    12621277                     * maximized or in fullscreen state. */
    1263                     if (mainwnd->isMaximized() || mainwnd->isTrueFullscreen())
     1278                    if (mainwnd->isMaximized() || mainwnd->isTrueFullscreen()
     1279                                               || mainwnd->isTrueSeamless())
    12641280                        ignore_mainwnd_resize = true;
    12651281                }
     
    12731289                if (!mainwnd->isMinimized() &&
    12741290                    !mainwnd->isMaximized() &&
    1275                     !mainwnd->isTrueFullscreen())
     1291                    !mainwnd->isTrueFullscreen() &&
     1292                    !mainwnd->isTrueSeamless())
    12761293                    QTimer::singleShot (0, this, SLOT (exitFullScreen()));
    12771294            }
     
    18241841}
    18251842
     1843bool VBoxConsoleView::isInSeamlessMode()
     1844{
     1845    return mainwnd->isTrueSeamless();
     1846}
     1847
    18261848/**
    18271849 *  Called on exit from fullscreen or from maximized mode.
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r3547 r3674  
    225225    , no_auto_close (false)
    226226    , full_screen (false)
     227    , mIsInSeamlessMode (false)
    227228    , normal_wflags (getWFlags())
    228229    , was_max (false)
     
    271272    vmFullscreenAction->setToggleAction (true);
    272273
     274    vmSeamlessAction = new QAction (this, "vmSeamlessAction");
     275    vmSeamlessAction->setIconSet (
     276        VBoxGlobal::iconSet ("nw_16px.png", "nw_disabled_16px.png"));
     277    vmSeamlessAction->setToggleAction (true);
     278
    273279    vmAutoresizeGuestAction = new QAction (runningActions, "vmAutoresizeGuestAction");
    274280    vmAutoresizeGuestAction->setIconSet (
     
    372378    QPopupMenu *vmMenu = new QPopupMenu (this, "vmMenu");
    373379    vmFullscreenAction->addTo (vmMenu);
     380    vmSeamlessAction->addTo (vmMenu);
    374381    vmAdjustWindowAction->addTo (vmMenu);
    375382    vmAutoresizeGuestAction->addTo (vmMenu);
     
    536543    connect (vmFullscreenAction, SIGNAL (toggled (bool)),
    537544             this, SLOT (vmFullscreen (bool)));
     545    connect (vmSeamlessAction, SIGNAL (toggled (bool)),
     546             this, SLOT (vmSeamless (bool)));
    538547    connect (vmAutoresizeGuestAction, SIGNAL (toggled (bool)),
    539548             this, SLOT (vmAutoresizeGuest (bool)));
     
    679688
    680689static const char *GUI_Fullscreen = "GUI/Fullscreen";
     690static const char *GUI_Seamless = "GUI/Seamless";
    681691static const char *GUI_AutoresizeGuest = "GUI/AutoresizeGuest";
    682692extern const char *GUI_FirstRun = "GUI/FirstRun";
     
    729739        if (str == "on")
    730740            vmFullscreenAction->setOn (true);
     741
     742        vmSeamlessAction->setEnabled (false);
     743        str = cmachine.GetExtraData (GUI_Seamless);
     744        if (str == "on")
     745            vmSeamlessAction->setOn (true);
    731746
    732747        str = cmachine.GetExtraData (GUI_AutoresizeGuest);
     
    762777            normal_pos = QPoint (x, y);
    763778            normal_size = QSize (w, h);
    764             if (!full_screen)
     779            if (!full_screen && !vmSeamlessAction->isOn())
    765780            {
    766781                move (normal_pos);
     
    779794            normal_pos = QPoint();
    780795            normal_size = QSize();
    781             if (!full_screen)
     796            if (!full_screen && !vmSeamlessAction->isOn())
    782797            {
    783798                console->normalizeGeometry (true /* adjustPosition */);
     
    845860    connect (console, SIGNAL (machineStateChanged (CEnums::MachineState)),
    846861             this, SLOT (updateMachineState (CEnums::MachineState)));
    847     connect (console, SIGNAL (additionsStateChanged (const QString&, bool)),
    848              this, SLOT (updateAdditionsState (const QString &, bool)));
     862    connect (console, SIGNAL (additionsStateChanged (const QString&, bool, bool)),
     863             this, SLOT (updateAdditionsState (const QString &, bool, bool)));
    849864
    850865#ifdef Q_WS_MAC
     
    10151030                                 .arg (normal_size.width())
    10161031                                 .arg (normal_size.height());
    1017         if (isMaximized() || (full_screen && was_max))
     1032        if (isMaximized() || (full_screen && was_max)
     1033                          || (mIsInSeamlessMode && was_max))
    10181034            winPos += QString (",%1").arg (GUI_LastWindowPosition_Max);
    10191035
     
    10221038        machine.SetExtraData (GUI_Fullscreen,
    10231039                              vmFullscreenAction->isOn() ? "on" : "off");
     1040        machine.SetExtraData (GUI_Seamless,
     1041                              vmSeamlessAction->isOn() ? "on" : "off");
    10241042        machine.SetExtraData (GUI_AutoresizeGuest,
    10251043                              vmAutoresizeGuestAction->isOn() ? "on" : "off");
     
    10701088        {
    10711089            QResizeEvent *re = (QResizeEvent *) e;
    1072             if (!full_screen &&
     1090            if (!full_screen && !mIsInSeamlessMode &&
    10731091                (windowState() & (WindowMaximized | WindowMinimized |
    10741092                                  WindowFullScreen)) == 0)
     
    10831101        case QEvent::Move:
    10841102        {
    1085             if (!full_screen &&
     1103            if (!full_screen && !mIsInSeamlessMode &&
    10861104                (windowState() & (WindowMaximized | WindowMinimized |
    10871105                                  WindowFullScreen)) == 0)
     
    13541372    vmFullscreenAction->setStatusTip (tr ("Switch to fullscreen mode" ));
    13551373
     1374    vmSeamlessAction->setMenuText (tr ("&Seamless Mode") + "\tHost+S");
     1375    vmSeamlessAction->setStatusTip (tr ("Switch to seamless mode"));
     1376
    13561377    vmDisMouseIntegrMenu->setToolTip (tr ("Mouse Integration",
    13571378                                          "enable/disable..."));
     
    17641785
    17651786    vmAdjustWindowAction->setEnabled (!on);
     1787    vmSeamlessAction->setEnabled (!on);
    17661788
    17671789    bool wasHidden = isHidden();
     
    18561878        if (was_max)
    18571879            setWindowState (windowState() | WindowMaximized);
    1858         QTimer::singleShot (0, console, SLOT (exitFullScreen()));
     1880        else
     1881            QTimer::singleShot (0, console, SLOT (exitFullScreen()));
     1882    }
     1883
     1884    /* VBoxConsoleView loses focus for some reason after reparenting,
     1885     * restore it */
     1886    console->setFocus();
     1887
     1888    if (!wasHidden)
     1889        show();
     1890}
     1891
     1892void VBoxConsoleWnd::vmSeamless (bool on)
     1893{
     1894    if (on && !vmSeamlessAction->isEnabled() ||
     1895        !on && !mIsInSeamlessMode ||
     1896        on && full_screen)
     1897        return;
     1898
     1899    AssertReturnVoid (console);
     1900    AssertReturnVoid (mIsInSeamlessMode != on);
     1901    AssertReturnVoid ((hidden_children.isEmpty() == on));
     1902
     1903    /* activate the auto-resize feature required for the seamless mode */
     1904    if (!vmAutoresizeGuestAction->isOn())
     1905        vmAutoresizeGuestAction->setOn (true);
     1906    mIsInSeamlessMode = on;
     1907
     1908    vmAdjustWindowAction->setEnabled (!on);
     1909    vmFullscreenAction->setEnabled (!on);
     1910    vmAutoresizeGuestAction->setEnabled (!on);
     1911
     1912    bool wasHidden = isHidden();
     1913
     1914    if (on)
     1915    {
     1916        /* Save the previous scroll-view minimum size before entering
     1917         * fullscreen state to restore this minimum size before the exiting
     1918         * fullscreen. Required for correct scroll-view and guest display
     1919         * update in SDL mode. */
     1920        prev_min_size = console->minimumSize();
     1921        console->setMinimumSize (0, 0);
     1922
     1923        /* memorize the maximized state */
     1924        was_max = isMaximized();
     1925        /* set the correct flags to disable unnecessary frame controls */
     1926        int flags = WType_TopLevel | WStyle_Customize | WStyle_NoBorder;
     1927        QRect scrGeo = QApplication::desktop()->availableGeometry (this);
     1928        /* hide early to avoid extra flicker */
     1929        hide();
     1930        /* hide all but the central widget containing the console view */
     1931        QObjectList *list = queryList (NULL, NULL, false, false);
     1932        for (QObject *obj = list->first(); obj != NULL; obj = list->next())
     1933        {
     1934            if (obj->isWidgetType() && obj != centralWidget())
     1935            {
     1936                QWidget *w = (QWidget *) obj;
     1937                if (!w->isHidden())
     1938                {
     1939                    w->hide();
     1940                    hidden_children.append (w);
     1941                }
     1942            }
     1943        }
     1944        delete list;
     1945        /* reparent to apply new flags and place to the top left corner of the
     1946         * current desktop */
     1947        reparent (parentWidget(), flags, QPoint (scrGeo.x(), scrGeo.y()), false);
     1948        /* adjust colors and appearance */
     1949        console_style = console->frameStyle();
     1950        console->setFrameStyle (QFrame::NoFrame);
     1951        console->setMaximumSize (console->sizeHint());
     1952        console->setVScrollBarMode (QScrollView::AlwaysOff);
     1953        console->setHScrollBarMode (QScrollView::AlwaysOff);
     1954        /* go full available screen */
     1955        resize (scrGeo.size());
     1956        setMinimumSize (size());
     1957        setMaximumSize (size());
     1958    }
     1959    else
     1960    {
     1961        /* Restore the previous scroll-view minimum size before the exiting
     1962         * fullscreen. Required for correct scroll-view and guest display
     1963         * update in SDL mode. */
     1964        console->setMinimumSize (prev_min_size);
     1965
     1966        /* hide early to avoid extra flicker */
     1967        hide();
     1968        /* reparent to restore normal flags */
     1969        reparent (parentWidget(), normal_wflags, QPoint (0, 0), false);
     1970        /* adjust colors and appearance */
     1971        console->setFrameStyle (console_style);
     1972        console->setMaximumSize (console->sizeHint());
     1973        console->setVScrollBarMode (QScrollView::Auto);
     1974        console->setHScrollBarMode (QScrollView::Auto);
     1975        /* show everything hidden when going fullscreen */
     1976        for (QObject *obj = hidden_children.first(); obj != NULL;
     1977             obj = hidden_children.next())
     1978            ((QWidget *) obj)->show();
     1979        hidden_children.clear();
     1980        /* restore normal values */
     1981        setMinimumSize (QSize(0, 0));
     1982        setMaximumSize (QSize (QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
     1983        move (normal_pos);
     1984        resize (normal_size);
     1985        /* let our toplevel widget calculate its sizeHint properly */
     1986        QApplication::sendPostedEvents (0, QEvent::LayoutHint);
     1987        /* restore the maximized state */
     1988        if (was_max)
     1989            setWindowState (windowState() | WindowMaximized);
     1990        else
     1991            QTimer::singleShot (0, console, SLOT (exitFullScreen()));
    18591992    }
    18601993
     
    26132746
    26142747
    2615 void VBoxConsoleWnd::updateAdditionsState (const QString &aVersion, bool aActive)
     2748void VBoxConsoleWnd::updateAdditionsState (const QString &aVersion,
     2749                                           bool aActive,
     2750                                           bool aSeamless)
    26162751{
    26172752    vmAutoresizeGuestAction->setEnabled (aActive);
     2753    vmSeamlessAction->setEnabled (aSeamless);
     2754    if (aSeamless && vmSeamlessAction->isOn())
     2755        vmSeamless (true);
    26182756
    26192757    /* Check the Guest Additions version and warn the user about possible
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFrameBuffer.cpp

    r3611 r3674  
    267267        return E_POINTER;
    268268
    269         /// @todo
    270 
    271         NOREF(aCount);
    272         NOREF(aCountCopied);
    273 
    274     return S_OK;
    275 }
    276 
    277 STDMETHODIMP VBoxFrameBuffer::SetVisibleRegion(BYTE *aRectangles, ULONG aCount)
     269    /// @todo what and why?
     270
     271    NOREF(aCount);
     272    NOREF(aCountCopied);
     273
     274    return S_OK;
     275}
     276
     277STDMETHODIMP VBoxFrameBuffer::SetVisibleRegion (BYTE *aRectangles, ULONG aCount)
    278278{
    279279    PRTRECT rects = (PRTRECT)aRectangles;
     
    282282        return E_POINTER;
    283283
    284         /// @todo
    285 
    286         NOREF(aCount);
     284    if (!mView->isInSeamlessMode())
     285        return S_OK;
     286
     287    QRegion reg;
     288    for (ULONG ind = 0; ind < aCount; ++ ind)
     289    {
     290        QRect rect;
     291        rect.setLeft (rects->xLeft);
     292        rect.setBottom (rects->yBottom);
     293        rect.setRight (rects->xRight);
     294        rect.setTop (rects->yTop);
     295        reg += rect;
     296        ++ rects;
     297    }
     298    QApplication::postEvent (mView, new VBoxSetRegionEvent (reg));
    287299
    288300    return S_OK;
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