VirtualBox

Changeset 2700 in vbox for trunk/src


Ignore:
Timestamp:
May 17, 2007 3:34:02 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
21279
Message:

Full-screen and maximization issues fixed. Current implementation:

  1. In case of auto-resize feature is on: VBox window returns to previous dimensions then going normal mode after leaving Full-screen or Maximized modes.
  2. In case of auto-resize feature is off: VBox tries to adjust window dimensions to guest dimensions if necessary then going normal mode after leaving Full-screen or Maximized modes.

Guest additions event handler implemented and used for:

  1. Guest Addition outdated version detection. User will be warned about outdated additions.
  2. Auto-resize feature enabling. This feature will be disabled in the dropped down menu until additions-state-change event notifies vbox about guest additions activation.
Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
5 edited

Legend:

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

    r2354 r2700  
    4949class QMenuData;
    5050
     51/** Auto-resize event.
     52  * Useful for posting into events queue to be processed just after all
     53  * QEvent::Resize & QEvent::WindowStateChange events currently posted.
     54  * This is necessary due to these two events - QEvent::Resize &
     55  * QEvent::WindowStateChange are processed in different sequence
     56  * under Win32 and X11. */
     57class AutoResizeEvent : public QEvent
     58{
     59public:
     60    AutoResizeEvent () :
     61        QEvent ((QEvent::Type) VBoxDefs::AutoResizeEventType) {}
     62};
     63
    5164class VBoxConsoleView : public QScrollView
    5265{
     
    96109    void mouseStateChanged (int state);
    97110    void machineStateChanged (CEnums::MachineState state);
     111    void additionsStateChanged (const QString &, bool);
    98112
    99113protected:
     
    169183    static void dimImage (QImage &img);
    170184
     185    void performAutoResize();
     186
    171187private slots:
    172188
    173189    void doResizeHint();
    174     void normalizeGeo() { normalizeGeometry(); }
     190    void normalizeGeo() { normalizeGeometry (true); }
    175191
    176192private:
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h

    r2495 r2700  
    160160    void updateMouseState (int state);
    161161
     162    void updateAdditionsState (const QString&, bool);
     163
    162164    void tryClose();
    163165
     
    246248
    247249    CSession csession;
     250
     251    bool mIsAutoresizeEnabled;
    248252
    249253    // widgets
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h

    r1889 r2700  
    128128        MousePointerChangeEventType,
    129129        MachineStateChangeEventType,
     130        AdditionsStateChangeEventType,
     131        AutoResizeEventType,
    130132        MachineDataChangeEventType,
    131133        MachineRegisteredEventType,
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r2540 r2700  
    225225};
    226226
     227/** Guest Additions property changes. */
     228class GuestAdditionsEvent : public QEvent
     229{
     230public:
     231    GuestAdditionsEvent (const QString &aOsTypeId,
     232                         const QString &aAddVersion,
     233                         bool aAddActive) :
     234        QEvent ((QEvent::Type) VBoxDefs::AdditionsStateChangeEventType),
     235        mOsTypeId (aOsTypeId), mAddVersion (aAddVersion), mAddActive (aAddActive) {}
     236    const QString &osTypeId() const { return mOsTypeId; }
     237    const QString &additionVersion() const { return mAddVersion; }
     238    bool additionActive() const { return mAddActive; }
     239private:
     240    QString mOsTypeId;
     241    QString mAddVersion;
     242    bool mAddActive;
     243};
     244
    227245/** Menu activation event */
    228246class ActivateMenuEvent : public QEvent
     
    352370                      guest.GetAdditionsVersion().latin1(),
    353371                      guest.GetAdditionsActive()));
    354         /** @todo */
     372        QApplication::postEvent (mView,
     373                                 new GuestAdditionsEvent (
     374                                     guest.GetOSTypeId(),
     375                                     guest.GetAdditionsVersion(),
     376                                     guest.GetAdditionsActive()));
    355377        return S_OK;
    356378    }
     
    811833            case VBoxDefs::ResizeEventType:
    812834            {
     835                bool old_ignore_mainwnd_resize = ignore_mainwnd_resize;
    813836                ignore_mainwnd_resize = true;
    814837
     
    842865                 * full screen */
    843866                if (!mainwnd->isTrueFullscreen() &&
    844                     !topLevelWidget()->isMaximized() &&
    845                     !resize_hint_timer->isActive())
     867                    !topLevelWidget()->isMaximized())
    846868                    normalizeGeometry (true /* adjustPosition */);
    847869
     
    849871                cconsole.GetDisplay().ResizeCompleted();
    850872
    851                 ignore_mainwnd_resize = false;
     873                ignore_mainwnd_resize = old_ignore_mainwnd_resize;
    852874
    853875                return true;
     
    912934                onStateChange (me->machineState());
    913935                emit machineStateChanged (me->machineState());
     936                return true;
     937            }
     938
     939            case VBoxDefs::AdditionsStateChangeEventType:
     940            {
     941                GuestAdditionsEvent *ge = (GuestAdditionsEvent *) e;
     942                LogFlowFunc (("AdditionsStateChangeEventType\n"));
     943                emit additionsStateChanged (ge->additionVersion(), ge->additionActive());
    914944                return true;
    915945            }
     
    10041034            }
    10051035
     1036            case VBoxDefs::AutoResizeEventType:
     1037            {
     1038                performAutoResize();
     1039                return true;
     1040            }
     1041
    10061042            default:
    10071043                break;
     
    11051141                    if (autoresize_guest)
    11061142                        resize_hint_timer->start (300, TRUE);
     1143                    /* During window maximization WindowStateChange event is
     1144                     * processed before Resize event, so the ignore_mainwnd_resize
     1145                     * variable should be set to true here in case of mainwnd is
     1146                     * maximized or in fullscreen state. */
     1147                    if (mainwnd->isMaximized() || mainwnd->isTrueFullscreen())
     1148                        ignore_mainwnd_resize = true;
    11071149                }
    11081150                break;
     
    11101152            case QEvent::WindowStateChange:
    11111153            {
    1112                 if (!mainwnd->isMinimized())
    1113                 {
    1114                     if (!mainwnd->isMaximized())
    1115                     {
    1116                         /* The guest screen size (and therefore the contents
    1117                          * size) could have been changed while we were maximized
    1118                          * or minimized, so normalize the main window size
    1119                          * unless we're in true fullscreen mode. Calling
    1120                          * normalizeGeometry() directly from here doesn't work
    1121                          * for some reason, so use a single shot timer. */
    1122                         if (!mainwnd->isTrueFullscreen())
    1123                             QTimer::singleShot (0, this, SLOT (normalizeGeo()));
    1124                     }
    1125                 }
     1154                /* The guest screen size (and therefore the contents size)
     1155                 * could have been changed while we were maximized or minimized,
     1156                 * so posting event for auto-resize and normalization. */
     1157                if (!mainwnd->isMinimized() &&
     1158                    !mainwnd->isMaximized() &&
     1159                    !mainwnd->isTrueFullscreen())
     1160                    QApplication::postEvent (this, new AutoResizeEvent ());
    11261161            }
    11271162
     
    14831518        m_darwinKeyModifiers = newMask;
    14841519
    1485         /* Always return true here because we'll otherwise getting a Qt event 
     1520        /* Always return true here because we'll otherwise getting a Qt event
    14861521           we don't want and that will only cause the Pause warning to pop up. */
    14871522        ret = true;
     
    16711706
    16721707
     1708}
     1709
     1710void VBoxConsoleView::performAutoResize()
     1711{
     1712    if (autoresize_guest)
     1713    {
     1714        doResizeHint();
     1715        QTimer::singleShot (200, this, SLOT (normalizeGeo()));
     1716    }
     1717    else
     1718    {
     1719        normalizeGeo();
     1720    }
     1721    ignore_mainwnd_resize = false;
    16731722}
    16741723
     
    24522501    // Note, that it's just a guess that sending RESEND will give the desired
    24532502    // effect :), but at least it works with NT and W2k guests.
    2454     /** @todo This seems to causes linux guests (in console mode) to cough a bit. 
     2503    /** @todo This seems to causes linux guests (in console mode) to cough a bit.
    24552504     * We need to check if this is the cause of #1944 and/or #1949. --bird */
    24562505    codes [0] = 0xFE;
     
    24772526    m_darwinKeyModifiers &= alphaLock | kEventKeyModifierNumLockMask
    24782527                          | (release_hostkey ? 0 : ::DarwinKeyCodeToDarwinModifierMask (gs.hostKey()));
    2479 #endif 
     2528#endif
    24802529
    24812530    emitKeyboardStateChanged ();
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r2586 r2700  
    5757#include <qtimer.h>
    5858
     59#include <VBox/VBoxGuest.h>
     60#define VBOX_GUEST_ADDITIONS_VERSION_OK(additionsVersion) \
     61        (RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) && \
     62         RT_LOWORD(additionsVersion) <= RT_LOWORD(VMMDEV_VERSION))
     63
    5964#if defined(Q_WS_X11)
    6065#include <X11/Xlib.h>
     
    214219    , dbgMenu (NULL)
    215220#endif
     221    , mIsAutoresizeEnabled (false)
    216222    , console (0)
    217223    , mUsbLedTip (0)
     
    268274        VBoxGlobal::iconSet ("auto_resize_on_16px.png", "auto_resize_on_disabled_16px.png"));
    269275    vmAutoresizeGuestAction->setToggleAction (true);
     276    vmAutoresizeGuestAction->setEnabled (false);
    270277
    271278    vmAdjustWindowAction = new QAction (this, "vmAdjustWindowAction");
     
    722729        str = cmachine.GetExtraData (GUI_AutoresizeGuest);
    723730        if (str != "off")
    724             vmAutoresizeGuestAction->setOn (true);
     731            mIsAutoresizeEnabled = true;
    725732
    726733        str = cmachine.GetExtraData (GUI_LastWindowPosition);
     
    825832    connect (console, SIGNAL (machineStateChanged (CEnums::MachineState)),
    826833             this, SLOT (updateMachineState (CEnums::MachineState)));
     834    connect (console, SIGNAL (additionsStateChanged (const QString&, bool)),
     835             this, SLOT (updateAdditionsState (const QString &, bool)));
    827836
    828837#ifdef Q_WS_MAC
     
    17821791        if (was_max)
    17831792            setWindowState (windowState() | WindowMaximized);
     1793        QApplication::postEvent (console, new AutoResizeEvent());
    17841794    }
    17851795
     
    24932503}
    24942504
     2505
     2506void VBoxConsoleWnd::updateAdditionsState (const QString &aVersion, bool aActive)
     2507{
     2508    /* mIsAutoresizeEnabled flag stores the auto-resize status loaded from the
     2509     * settings and used for the activation of the autoresize feature
     2510     * if the additions state told us here it is activated. */
     2511    vmAutoresizeGuestAction->setEnabled (aActive);
     2512    vmAutoresizeGuestAction->setOn (aActive && mIsAutoresizeEnabled);
     2513
     2514    /* Checking for the Guest Additions version to warn user about possible
     2515     * compatibility issues in case of installed version is outdated. */
     2516    uint version = aVersion.toUInt();
     2517    bool isVersionOk = VBOX_GUEST_ADDITIONS_VERSION_OK (version);
     2518    if (!isVersionOk)
     2519        vboxProblem().message (this, VBoxProblemReporter::Warning,
     2520            tr ("<p>Current Guest Additions version is outdated. Please install "
     2521                "the latest version to avoid compatibility issues.</p>"));
     2522}
     2523
    24952524/**
    24962525 *  Helper to safely close the main console window.
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette