VirtualBox

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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 ();
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