VirtualBox

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


Ignore:
Timestamp:
Mar 4, 2010 7:45:10 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
58372
Message:

FE/Qt4: New running VM core: fullscreen mode rework: seamless functionality partially merged into fullscreen, some code cleaning.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp

    r27015 r27057  
    2525#include <QApplication>
    2626#include <QDesktopWidget>
     27#include <QTimer>
     28#ifdef Q_WS_MAC
    2729#include <QMenuBar>
    28 #include <QTimer>
     30#endif
     31#ifdef Q_WS_X11
     32#include <limits.h>
     33#endif
    2934
    3035/* Local includes */
    31 #include "VBoxGlobal.h"
    3236#include "UISession.h"
    3337#include "UIActionsPool.h"
     
    5054#endif
    5155                    , uMonitor)
    52 , m_bIsGuestAutoresizeEnabled(pMachineWindow->machineLogic()->actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->isChecked())
     56    , m_fIsInitialResizeEventProcessed(false)
     57    , m_bIsGuestAutoresizeEnabled(pMachineWindow->machineLogic()->actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->isChecked())
    5358    , m_fShouldWeDoResize(false)
    5459{
     
    8287    /* Cleanup frame buffer: */
    8388    cleanupFrameBuffer();
    84 }
    85 
    86 void UIMachineViewFullscreen::sltAdditionsStateChanged()
    87 {
    88     /* Check if we should restrict minimum size: */
    89     maybeRestrictMinimumSize();
    9089}
    9190
     
    105104        AssertMsg(newSize.isValid(), ("This size should be valid!\n"));
    106105
    107         /* Subtracting frame in case we basing on machine view size: */
    108         if (!toSize.isValid())
    109             newSize -= QSize(frameWidth() * 2, frameWidth() * 2);
    110 
    111106        /* Do not send the same hints as we already have: */
    112107        if ((newSize.width() == storedConsoleSize().width()) && (newSize.height() == storedConsoleSize().height()))
    113108            return;
    114109
    115         /* We only actually send the hint if
    116          * 1) the autoresize property is set to true and
    117          * 2) either an explicit new size was given (e.g. if the request
    118          *    was triggered directly by a console resize event) or if no
    119          *    explicit size was specified but a resize is flagged as being
    120          *    needed (e.g. the autoresize was just enabled and the console
    121          *    was resized while it was disabled). */
     110        /* We only actually send the hint if either an explicit new size was given
     111         * (e.g. if the request was triggered directly by a console resize event) or
     112         * if no explicit size was specified but a resize is flagged as being needed
     113         * (e.g. the autoresize was just enabled and the console was resized while it was disabled). */
    122114        if (toSize.isValid() || m_fShouldWeDoResize)
    123115        {
    124             /* Remember the new size. */
     116            /* Remember the new size: */
    125117            storeConsoleSize(newSize.width(), newSize.height());
    126118
     
    128120            session().GetConsole().GetDisplay().SetVideoModeHint(newSize.width(), newSize.height(), 0, screenId());
    129121        }
    130         /* We had requested resize now, rejecting accident requests: */
     122
     123        /* We had requested resize now, rejecting other accident requests: */
    131124        m_fShouldWeDoResize = false;
    132125    }
    133126}
    134127
    135 /* If the desktop geometry is set automatically, this will update it: */
     128void UIMachineViewFullscreen::sltAdditionsStateChanged()
     129{
     130    /* Check if we should restrict minimum size: */
     131    maybeRestrictMinimumSize();
     132}
     133
    136134void UIMachineViewFullscreen::sltDesktopResized()
    137135{
     136    /* If the desktop geometry is set automatically, this will update it: */
    138137    calculateDesktopGeometry();
    139138}
    140139
    141 void UIMachineViewFullscreen::prepareCommon()
    142 {
    143     UIMachineView::prepareCommon();
    144 
    145     /* Maximum size of the screen */
    146     setMaximumSize(availableGeometry().size());
    147     /* Minimum size is ignored too */
    148     setMinimumSize(0, 0);
    149     /* No scrollbars */
    150     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    151     setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    152 }
    153 
    154 void UIMachineViewFullscreen::prepareFilters()
    155 {
    156     /* Base-class filters: */
    157     UIMachineView::prepareFilters();
    158 
    159     /* Normal window filters: */
    160     qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow())->menuBar()->installEventFilter(this);
    161 }
    162 
    163 void UIMachineViewFullscreen::prepareConsoleConnections()
    164 {
    165     /* Base class connections: */
    166     UIMachineView::prepareConsoleConnections();
    167 
    168     /* Guest additions state-change updater: */
    169     connect(uisession(), SIGNAL(sigAdditionsStateChange()), this, SLOT(sltAdditionsStateChanged()));
    170 }
    171 
    172 void UIMachineViewFullscreen::loadMachineViewSettings()
    173 {
    174     /* Base class settings: */
    175     UIMachineView::loadMachineViewSettings();
    176 
    177     /* Global settings: */
    178     {
    179         connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(sltDesktopResized()));
    180     }
    181 }
    182 
    183 void UIMachineViewFullscreen::setGuestAutoresizeEnabled(bool fEnabled)
    184 {
    185     if (m_bIsGuestAutoresizeEnabled != fEnabled)
    186     {
    187         m_bIsGuestAutoresizeEnabled = fEnabled;
    188 
    189         maybeRestrictMinimumSize();
    190 
    191         sltPerformGuestResize();
    192     }
    193 }
    194 
    195 void UIMachineViewFullscreen::normalizeGeometry(bool bAdjustPosition /* = false */)
    196 {
    197     QWidget *pTopLevelWidget = window();
    198 
    199     /* Make no normalizeGeometry in case we are in manual resize mode or main window is maximized: */
    200     if (pTopLevelWidget->isMaximized())
    201         return;
    202 
    203     /* Calculate client window offsets: */
    204     QRect frameGeo = pTopLevelWidget->frameGeometry();
    205     QRect geo = pTopLevelWidget->geometry();
    206     int dl = geo.left() - frameGeo.left();
    207     int dt = geo.top() - frameGeo.top();
    208     int dr = frameGeo.right() - geo.right();
    209     int db = frameGeo.bottom() - geo.bottom();
    210 
    211     /* Get the best size w/o scroll bars: */
    212     QSize s = pTopLevelWidget->sizeHint();
    213 
    214     /* Resize the frame to fit the contents: */
    215     s -= pTopLevelWidget->size();
    216     frameGeo.setRight(frameGeo.right() + s.width());
    217     frameGeo.setBottom(frameGeo.bottom() + s.height());
    218 
    219     if (bAdjustPosition)
    220     {
    221         QRegion availableGeo;
    222         QDesktopWidget *dwt = QApplication::desktop();
    223         if (dwt->isVirtualDesktop())
    224             /* Compose complex available region */
    225             for (int i = 0; i < dwt->numScreens(); ++ i)
    226                 availableGeo += dwt->availableGeometry(i);
    227         else
    228             /* Get just a simple available rectangle */
    229             availableGeo = dwt->availableGeometry(pTopLevelWidget->pos());
    230 
    231         frameGeo = VBoxGlobal::normalizeGeometry(frameGeo, availableGeo, mode() != VBoxDefs::SDLMode /* canResize */);
    232     }
    233 
    234 #if 0
    235     /* Center the frame on the desktop: */
    236     frameGeo.moveCenter(availableGeo.center());
    237 #endif
    238 
    239     /* Finally, set the frame geometry */
    240     pTopLevelWidget->setGeometry(frameGeo.left() + dl, frameGeo.top() + dt, frameGeo.width() - dl - dr, frameGeo.height() - dt - db);
    241 }
    242 
    243 QRect UIMachineViewFullscreen::availableGeometry()
    244 {
    245     return QApplication::desktop()->screenGeometry(this);
    246 }
    247 
    248 void UIMachineViewFullscreen::maybeRestrictMinimumSize()
    249 {
    250     /* Sets the minimum size restriction depending on the auto-resize feature state and the current rendering mode.
    251      * Currently, the restriction is set only in SDL mode and only when the auto-resize feature is inactive.
    252      * We need to do that because we cannot correctly draw in a scrolled window in SDL mode.
    253      * In all other modes, or when auto-resize is in force, this function does nothing. */
    254     if (mode() == VBoxDefs::SDLMode)
    255     {
    256         if (!uisession()->isGuestSupportsGraphics() || !m_bIsGuestAutoresizeEnabled)
    257             setMinimumSize(sizeHint());
    258         else
    259             setMinimumSize(0, 0);
    260     }
    261 }
    262 
    263140bool UIMachineViewFullscreen::event(QEvent *pEvent)
    264141{
     
    267144        case VBoxDefs::ResizeEventType:
    268145        {
    269             /* Some situations require initial VGA Resize Request
    270              * to be ignored at all, leaving previous framebuffer,
    271              * machine view and machine window sizes preserved: */
     146            /* Some situations require framebuffer resize events to be ignored,
     147             * leaving machine window & machine view & framebuffer sizes preserved: */
    272148            if (uisession()->isGuestResizeIgnored())
    273149                return true;
    274150
     151            /* We are starting to perform machine view resize: */
    275152            bool oldIgnoreMainwndResize = isMachineWindowResizeIgnored();
    276153            setMachineWindowResizeIgnored(true);
    277154
     155            /* Get guest resize-event: */
    278156            UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent);
    279157
    280             /* Store the new size to prevent unwanted resize hints being sent back. */
     158            /* Perform framebuffer resize: */
     159            frameBuffer()->resizeEvent(pResizeEvent);
     160
     161            /* Reapply maximum size restriction for machine view: */
     162            setMaximumSize(sizeHint());
     163
     164            /* Store the new size to prevent unwanted resize hints being sent back: */
    281165            storeConsoleSize(pResizeEvent->width(), pResizeEvent->height());
    282166
    283             /* Unfortunately restoreOverrideCursor() is broken in Qt 4.4.0 if WA_PaintOnScreen widgets are present.
    284              * This is the case on linux with SDL. As workaround we save/restore the arrow cursor manually.
    285              * See http://trolltech.com/developer/task-tracker/index_html?id=206165&method=entry for details.
    286              * Moreover the current cursor, which could be set by the guest, should be restored after resize: */
    287             QCursor cursor;
    288             if (uisession()->isHidingHostPointer())
    289                 cursor = QCursor(Qt::BlankCursor);
    290             else
    291                 cursor = viewport()->cursor();
    292             frameBuffer()->resizeEvent(pResizeEvent);
    293             viewport()->setCursor(cursor);
    294 
    295 #ifdef Q_WS_MAC
    296             // TODO_NEW_CORE
    297 //            mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height());
    298 #endif /* Q_WS_MAC */
    299 
    300             /* This event appears in case of guest video was changed for somehow even without video resolution change.
    301              * In this last case the host VM window will not be resized according this event and the host mouse cursor
    302              * which was unset to default here will not be hidden in capture state. So it is necessary to perform
    303              * updateMouseClipping() for the guest resize event if the mouse cursor was captured: */
    304             if (uisession()->isMouseCaptured())
    305                 updateMouseClipping();
    306 
    307             /* Apply maximum size restriction: */
    308             setMaximumSize(sizeHint());
    309 
    310             /* May be we have to restrict minimum size? */
    311             maybeRestrictMinimumSize();
    312 
    313             /* Resize the guest canvas: */
    314             if (!isFrameBufferResizeIgnored())
    315                 resize(pResizeEvent->width(), pResizeEvent->height());
    316             updateSliders();
     167            /* Perform machine view resize: */
     168            resize(pResizeEvent->width(), pResizeEvent->height());
    317169
    318170            /* Let our toplevel widget calculate its sizeHint properly. */
     
    326178#endif /* Q_WS_X11 */
    327179
    328             if (!isFrameBufferResizeIgnored())
    329                 normalizeGeometry(true /* adjustPosition */);
     180#ifdef Q_WS_MAC
     181            // TODO_NEW_CORE
     182//            mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height());
     183#endif /* Q_WS_MAC */
     184
     185            /* Unfortunately restoreOverrideCursor() is broken in Qt 4.4.0 if WA_PaintOnScreen widgets are present.
     186             * This is the case on linux with SDL. As workaround we save/restore the arrow cursor manually.
     187             * See http://trolltech.com/developer/task-tracker/index_html?id=206165&method=entry for details.
     188             * Moreover the current cursor, which could be set by the guest, should be restored after resize: */
     189            if (uisession()->isValidPointerShapePresent())
     190                viewport()->setCursor(uisession()->cursor());
     191            else if (uisession()->isHidingHostPointer())
     192                viewport()->setCursor(Qt::BlankCursor);
     193            /* This event appears in case of guest video was changed for somehow even without video resolution change.
     194             * In this last case the host VM window will not be resized according this event and the host mouse cursor
     195             * which was unset to default here will not be hidden in capture state. So it is necessary to perform
     196             * updateMouseClipping() for the guest resize event if the mouse cursor was captured: */
     197            if (uisession()->isMouseCaptured())
     198                updateMouseClipping();
     199
     200            /* May be we have to restrict minimum size? */
     201            maybeRestrictMinimumSize();
    330202
    331203            /* Report to the VM thread that we finished resizing */
    332204            session().GetConsole().GetDisplay().ResizeCompleted(screenId());
    333205
     206            /* We are finishing to perform machine view resize: */
    334207            setMachineWindowResizeIgnored(oldIgnoreMainwndResize);
    335 
    336             /* Update geometry after entering fullscreen */
    337             updateGeometry();
    338208
    339209            /* Make sure that all posted signals are processed: */
    340210            qApp->processEvents();
    341211
     212            /* We also recalculate the desktop geometry if this is determined automatically.
     213             * In fact, we only need this on the first resize,
     214             * but it is done every time to keep the code simpler. */
     215            calculateDesktopGeometry();
     216
    342217            /* Emit a signal about guest was resized: */
    343218            emit resizeHintDone();
    344 
    345             /* We also recalculate the desktop geometry if this is determined
    346              * automatically.  In fact, we only need this on the first resize,
    347              * but it is done every time to keep the code simpler. */
    348             calculateDesktopGeometry();
    349 
    350             // TODO_NEW_CORE: try to understand this, cause this is bullshit in fullscreen
    351             /* Enable frame-buffer resize watching: */
    352 //            if (isFrameBufferResizeIgnored())
    353 //                setFrameBufferResizeIgnored(false);
    354219
    355220            return true;
     
    365230                if (pKeyEvent->key() == Qt::Key_Home)
    366231                {
    367                     /* In Qt4 it is not enough to just set the focus to menu-bar.
    368                      * So to get the menu-bar we have to send Qt::Key_Alt press/release events directly: */
    369                     QKeyEvent e1(QEvent::KeyPress, Qt::Key_Alt, Qt::NoModifier);
    370                     QKeyEvent e2(QEvent::KeyRelease, Qt::Key_Alt, Qt::NoModifier);
    371                     QMenuBar *pMenuBar = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ?
    372                                          qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow())->menuBar() : 0;
    373                     QApplication::sendEvent(pMenuBar, &e1);
    374                     QApplication::sendEvent(pMenuBar, &e2);
     232#if 0 // TODO: Activate Main Menu!
     233                    // should we create it first?
     234#endif
    375235                }
    376236                else
     
    386246bool UIMachineViewFullscreen::eventFilter(QObject *pWatched, QEvent *pEvent)
    387247{
    388     /* Who are we watchin? */
    389248    QIMainDialog *pMainDialog = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ?
    390249        qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow()) : 0;
    391     QMenuBar *pMenuBar = pMainDialog ? qobject_cast<QIMainDialog*>(pMainDialog)->menuBar() : 0;
    392 
    393250    if (pWatched != 0 && pWatched == pMainDialog)
    394251    {
     
    397254            case QEvent::Resize:
    398255            {
     256                /* Ignore initial resize event: */
     257                if (!m_fIsInitialResizeEventProcessed)
     258                {
     259                    m_fIsInitialResizeEventProcessed = true;
     260                    break;
     261                }
     262
    399263                /* Set the "guest needs to resize" hint.
    400264                 * This hint is acted upon when (and only when) the autoresize property is "true": */
    401265                m_fShouldWeDoResize = uisession()->isGuestSupportsGraphics();
    402266                if (!isMachineWindowResizeIgnored() && m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics())
    403                     QTimer::singleShot(300, this, SLOT(sltPerformGuestResize()));
     267                    QTimer::singleShot(0, this, SLOT(sltPerformGuestResize()));
    404268                break;
    405269            }
    406 #if defined (Q_WS_WIN32)
    407 # if defined (VBOX_GUI_USE_DDRAW)
    408             case QEvent::Move:
    409             {
    410                 /* Notification from our parent that it has moved. We need this in order
    411                  * to possibly adjust the direct screen blitting: */
    412                 if (frameBuffer())
    413                     frameBuffer()->moveEvent(static_cast<QMoveEvent*>(pEvent));
    414                 break;
    415             }
    416 # endif
    417 #endif /* defined (Q_WS_WIN32) */
    418270            default:
    419271                break;
    420272        }
    421273    }
    422     else if (pWatched != 0 && pWatched == pMenuBar)
     274#ifdef Q_WS_MAC // TODO: Is it really needed?
     275    QMenuBar *pMenuBar = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ?
     276                         qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow())->menuBar() : 0;
     277    if (pWatched != 0 && pWatched == pMenuBar)
    423278    {
    424279        /* Sometimes when we press ESC in the menu it brings the focus away (Qt bug?)
     
    445300        }
    446301    }
     302#endif /* Q_WS_MAC */
    447303    return UIMachineView::eventFilter(pWatched, pEvent);
    448304}
    449305
     306void UIMachineViewFullscreen::prepareCommon()
     307{
     308    /* Base class common settings: */
     309    UIMachineView::prepareCommon();
     310
     311    /* Store old machine view size before bramebuffer resized: */
     312    m_normalSize = QSize(frameBuffer()->width(), frameBuffer()->height());
     313
     314    /* Minimum size is ignored: */
     315    setMinimumSize(0, 0);
     316    /* No scrollbars: */
     317    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     318    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     319}
     320
     321void UIMachineViewFullscreen::prepareFilters()
     322{
     323    /* Base class filters: */
     324    UIMachineView::prepareFilters();
     325
     326#ifdef Q_WS_MAC // TODO: Is it really needed? See UIMachineViewSeamless::eventFilter(...);
     327    /* Menu bar filter: */
     328    qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow())->menuBar()->installEventFilter(this);
     329#endif
     330}
     331
     332void UIMachineViewFullscreen::prepareConnections()
     333{
     334    connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(sltDesktopResized()));
     335}
     336
     337void UIMachineViewFullscreen::prepareConsoleConnections()
     338{
     339    /* Base class connections: */
     340    UIMachineView::prepareConsoleConnections();
     341
     342    /* Guest additions state-change updater: */
     343    connect(uisession(), SIGNAL(sigAdditionsStateChange()), this, SLOT(sltAdditionsStateChanged()));
     344}
     345
     346void UIMachineViewFullscreen::setGuestAutoresizeEnabled(bool fEnabled)
     347{
     348    if (m_bIsGuestAutoresizeEnabled != fEnabled)
     349    {
     350        m_bIsGuestAutoresizeEnabled = fEnabled;
     351
     352        maybeRestrictMinimumSize();
     353
     354        sltPerformGuestResize();
     355    }
     356}
     357
     358QRect UIMachineViewFullscreen::availableGeometry()
     359{
     360    return QApplication::desktop()->screenGeometry(this);
     361}
     362
     363void UIMachineViewFullscreen::maybeRestrictMinimumSize()
     364{
     365    /* Sets the minimum size restriction depending on the auto-resize feature state and the current rendering mode.
     366     * Currently, the restriction is set only in SDL mode and only when the auto-resize feature is inactive.
     367     * We need to do that because we cannot correctly draw in a scrolled window in SDL mode.
     368     * In all other modes, or when auto-resize is in force, this function does nothing. */
     369    if (mode() == VBoxDefs::SDLMode)
     370    {
     371        if (!uisession()->isGuestSupportsGraphics() || !m_bIsGuestAutoresizeEnabled)
     372            setMinimumSize(sizeHint());
     373        else
     374            setMinimumSize(0, 0);
     375    }
     376}
     377
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h

    r27012 r27057  
    4444private slots:
    4545
     46    /* Slot to perform guest resize: */
     47    void sltPerformGuestResize(const QSize &aSize = QSize());
     48
    4649    /* Console callback handlers: */
    4750    void sltAdditionsStateChanged();
    48 
    49     /* Slot to perform guest resize: */
    50     void sltPerformGuestResize(const QSize &aSize = QSize());
    5151
    5252    /* Watch dog for desktop resizes: */
     
    5555private:
    5656
     57    /* Event handlers: */
     58    bool event(QEvent *pEvent);
     59    bool eventFilter(QObject *pWatched, QEvent *pEvent);
     60
    5761    /* Prepare routines: */
    5862    void prepareCommon();
    5963    void prepareFilters();
     64    void prepareConnections();
    6065    void prepareConsoleConnections();
    61     void loadMachineViewSettings();
     66
     67    /* Cleanup routines: */
     68    //void cleanupConsoleConnections() {}
     69    //void cleanupConnections() {}
     70    //void cleanupFilters() {}
     71    //void cleanupCommon() {}
    6272
    6373    /* Private setters: */
     
    6575
    6676    /* Private helpers: */
    67     void normalizeGeometry(bool bAdjustPosition = false);
    6877    QRect availableGeometry();
    6978    void maybeRestrictMinimumSize();
    7079
    71     bool event(QEvent *pEvent);
    72     bool eventFilter(QObject *pWatched, QEvent *pEvent);
    73 
    7480    /* Private members: */
     81    bool m_fIsInitialResizeEventProcessed : 1;
    7582    bool m_bIsGuestAutoresizeEnabled : 1;
    7683    bool m_fShouldWeDoResize : 1;
     84    QSize m_normalSize;
    7785
    7886    /* Friend classes: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r27027 r27057  
    2424/* Global includes */
    2525#include <QDesktopWidget>
    26 #include <QMenuBar>
    27 #include <QTimer>
    28 #include <QContextMenuEvent>
     26#ifdef Q_WS_MAC
     27# include <QMenuBar>
     28#endif /* Q_WS_MAC */
    2929
    3030/* Local includes */
    3131#include "VBoxGlobal.h"
    3232
     33#ifdef Q_WS_MAC
    3334#include "UISession.h"
    34 #include "UIActionsPool.h"
     35#endif /* Q_WS_MAC */
    3536#include "UIMachineLogic.h"
    3637#include "UIMachineView.h"
     
    3839
    3940UIMachineWindowFullscreen::UIMachineWindowFullscreen(UIMachineLogic *pMachineLogic, ulong uScreenId)
    40     : QIWithRetranslateUI<QIMainDialog>(0)
     41    : QIWithRetranslateUI2<QIMainDialog>(0, Qt::Window)
    4142    , UIMachineWindow(pMachineLogic, uScreenId)
    4243{
     
    6465    prepareMachineView();
    6566
     67#ifdef Q_WS_MAC
    6668    /* Load normal window settings: */
    6769    loadWindowSettings();
     70#endif /* Q_WS_MAC */
    6871
    6972    /* Update all the elements: */
     
    7174
    7275    /* Show window: */
    73 //    show();
     76    showFullScreen();
    7477}
    7578
    7679UIMachineWindowFullscreen::~UIMachineWindowFullscreen()
    7780{
    78     /* Save normal window settings: */
    79     saveWindowSettings();
    80 
    8181    /* Cleanup normal machine view: */
    8282    cleanupMachineView();
     
    148148
    149149    /* Set central widget: */
    150     setCentralWidget(new QWidget(this));
     150    setCentralWidget(new QWidget);
    151151
    152152    /* Set central widget layout: */
     
    163163    /* Add machine view into layout: */
    164164    m_pMachineViewContainer->addWidget(m_pMachineView, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter);
    165 }
    166165
    167 void UIMachineWindowFullscreen::loadWindowSettings()
    168 {
    169     /* Toggle console to manual resize mode. */
    170     m_pMachineView->setFrameBufferResizeIgnored(true);
    171 
    172     /* The background has to go black */
     166    /* The background has to go black: */
    173167    QPalette palette(centralWidget()->palette());
    174168    palette.setColor(centralWidget()->backgroundRole(), Qt::black);
     
    176170    centralWidget()->setAutoFillBackground(true);
    177171    setAutoFillBackground(true);
    178 
    179     /* Here we are going really fullscreen */
    180     setWindowState(windowState() | Qt::WindowFullScreen);
    181 
    182     /* Show the window */
    183     show();
    184     /* Make sure it is really on the right place (especially on the Mac) */
    185     move(0, 0);
    186172}
    187173
    188 void UIMachineWindowFullscreen::saveWindowSettings()
     174#ifdef Q_WS_MAC
     175void UIMachineWindowFullscreen::loadWindowSettings()
    189176{
     177    /* Load global settings: */
     178    {
     179        VBoxGlobalSettings settings = vboxGlobal().settings();
     180        menuBar()->setHidden(settings.isFeatureActive("noMenuBar"));
     181    }
    190182}
     183#endif
    191184
    192185void UIMachineWindowFullscreen::cleanupMachineView()
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.h

    r27027 r27057  
    2424#define __UIMachineWindowFullscreen_h__
    2525
    26 /* Global includes */
    27 #include <QLabel>
    28 
    2926/* Local includes */
    30 #include "VBoxDefs.h"
    3127#include "QIWithRetranslateUI.h"
    3228#include "QIMainDialog.h"
     
    3632#endif
    3733
    38 #ifdef Q_WS_MAC
    39 # include <ApplicationServices/ApplicationServices.h>
    40 #endif /* Q_WS_MAC */
    41 
    42 /* Local forwards */
    43 class CMediumAttachment;
    44 
    45 class UIMachineWindowFullscreen : public QIWithRetranslateUI<QIMainDialog>, public UIMachineWindow
     34class UIMachineWindowFullscreen : public QIWithRetranslateUI2<QIMainDialog>, public UIMachineWindow
    4635{
    4736    Q_OBJECT;
     
    4938protected:
    5039
    51     /* Normal machine window constructor/destructor: */
     40    /* Fullscreen machine window constructor/destructor: */
    5241    UIMachineWindowFullscreen(UIMachineLogic *pMachineLogic, ulong uScreenId);
    5342    virtual ~UIMachineWindowFullscreen();
     
    6958#ifdef Q_WS_X11
    7059    bool x11Event(XEvent *pEvent);
    71 #endif
     60#endif /* Q_WS_X11 */
    7261    void closeEvent(QCloseEvent *pEvent);
    7362
     
    7766#endif /* Q_WS_MAC */
    7867    void prepareMachineView();
     68#ifdef Q_WS_MAC
    7969    void loadWindowSettings();
     70#endif /* Q_WS_MAC */
    8071
    8172    /* Cleanup helpers: */
    82     void saveWindowSettings();
     73#ifdef Q_WS_MAC
     74    //void saveWindowSettings() {}
     75#endif /* Q_WS_MAC */
    8376    void cleanupMachineView();
     77#ifdef Q_WS_MAC
    8478    //void cleanupMenu() {}
    85     //void cleanupConsoleConnections() {}
    86 
    87     /* Other members: */
    88     QRect m_normalGeometry;
     79#endif /* Q_WS_MAC */
    8980
    9081    /* Factory support: */
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