VirtualBox

Changeset 27335 in vbox


Ignore:
Timestamp:
Mar 12, 2010 4:20:29 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4: new core: added multi monitor support in fullscreen and (partly) seamless

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 added
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r27215 r27335  
    377377        src/runtime/UIMachineLogic.h \
    378378        src/runtime/UIMachineView.h \
     379        src/runtime/UIMultiScreenLayout.h \
    379380        src/runtime/normal/UIMachineLogicNormal.h \
    380381        src/runtime/normal/UIMachineWindowNormal.h \
     
    503504        src/runtime/UIIndicatorsPool.cpp \
    504505        src/runtime/UIFrameBuffer.cpp \
    505         src/runtime/UIFrameBufferDirectDraw.cpp \
    506506        src/runtime/UIFrameBufferQGL.cpp \
    507507        src/runtime/UIFrameBufferQImage.cpp \
    508         src/runtime/UIFrameBufferQuartz2D.cpp \
    509508        src/runtime/UIFrameBufferSDL.cpp \
    510509        src/runtime/UIMachine.cpp \
     
    513512        src/runtime/UIMachineView.cpp \
    514513        src/runtime/UIMachineMenuBar.cpp \
     514        src/runtime/UIMultiScreenLayout.cpp \
    515515        src/runtime/normal/UIMachineLogicNormal.cpp \
    516516        src/runtime/normal/UIMachineWindowNormal.cpp \
     
    522522        src/runtime/seamless/UIMachineWindowSeamless.cpp \
    523523        src/runtime/seamless/UIMachineViewSeamless.cpp
     524VirtualBox_SOURCES.win += \
     525        src/runtime/UIFrameBufferDirectDraw.cpp
    524526VirtualBox_SOURCES.darwin += \
     527        src/runtime/UIFrameBufferQuartz2D.cpp \
    525528        src/darwin/UIAbstractDockIconPreview.cpp \
    526529        src/darwin/UICocoaDockIconPreview.mm
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.cpp

    r27296 r27335  
    3131const char* VBoxDefs::GUI_Fullscreen = "GUI/Fullscreen";
    3232const char* VBoxDefs::GUI_Seamless = "GUI/Seamless";
     33const char* VBoxDefs::GUI_VirtualScreenToHostScreen = "GUI/VirtualScreenToHostScreen";
    3334const char* VBoxDefs::GUI_AutoresizeGuest = "GUI/AutoresizeGuest";
    3435const char* VBoxDefs::GUI_FirstRun = "GUI/FirstRun";
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.h

    r27296 r27335  
    149149    static const char* GUI_Fullscreen;
    150150    static const char* GUI_Seamless;
     151    static const char* GUI_VirtualScreenToHostScreen;
    151152    static const char* GUI_AutoresizeGuest;
    152153    static const char* GUI_FirstRun;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionsPool.cpp

    r27143 r27335  
    508508        setText(VBoxGlobal::insertKeyToActionText(UIActionsPool::tr("&Close..." ), "Q"));
    509509        setStatusTip(UIActionsPool::tr("Close the virtual machine"));
     510    }
     511};
     512
     513class MenuViewAction : public UIMenuAction
     514{
     515    Q_OBJECT;
     516
     517public:
     518
     519    MenuViewAction(QObject *pParent)
     520        : UIMenuAction(pParent)
     521    {
     522        retranslateUi();
     523    }
     524
     525protected:
     526
     527    void retranslateUi()
     528    {
     529        menu()->setTitle(UIActionsPool::tr("&View"));
    510530    }
    511531};
     
    11201140        delete m_actionsPool[UIActionIndex_Menu_Machine];
    11211141    m_actionsPool[UIActionIndex_Menu_Machine] = new MenuMachineAction(this);
     1142    if (m_actionsPool[UIActionIndex_Menu_View])
     1143        delete m_actionsPool[UIActionIndex_Menu_View];
     1144    m_actionsPool[UIActionIndex_Menu_View] = new MenuViewAction(this);
    11221145    if (m_actionsPool[UIActionIndex_Menu_MouseIntegration])
    11231146        delete m_actionsPool[UIActionIndex_Menu_MouseIntegration];
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionsPool.h

    r27132 r27335  
    7777    UIActionIndex_Simple_Close,
    7878
     79    /* "View" menu actions: */
     80    UIActionIndex_Menu_View,
     81
    7982    /* "Devices" menu actions: */
    8083    UIActionIndex_Menu_Devices,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineDefs.h

    r26751 r27335  
    6868};
    6969
     70/* Main menu enum: */
     71enum UIMainMenuType
     72{
     73    UIMainMenuType_Machine = RT_BIT(0),
     74    UIMainMenuType_Devices = RT_BIT(1),
     75    UIMainMenuType_View    = RT_BIT(2),
     76    UIMainMenuType_Debug   = RT_BIT(3),
     77    UIMainMenuType_Help    = RT_BIT(4),
     78    UIMainMenuType_All     = 0xFF
     79};
     80
    7081#endif // __UIMachineDefs_h__
    7182
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r27311 r27335  
    6767    /* Main getters/setters: */
    6868    UISession* uisession() const { return m_pSession; }
     69    CSession& session();
    6970    UIActionsPool* actionsPool() const { return m_pActionsPool; }
    7071    UIVisualStateType visualStateType() const { return m_visualStateType; }
     
    9394    bool isMachineWindowsCreated() const { return m_fIsWindowsCreated; }
    9495    void setMachineWindowsCreated(bool fIsWindowsCreated) { m_fIsWindowsCreated = fIsWindowsCreated; }
    95 
    96     /* Protected wrappers: */
    97     CSession& session();
    9896
    9997    /* Protected members: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp

    r27141 r27335  
    3939}
    4040
    41 QMenu* UIMachineMenuBar::createMenu(UIActionsPool *pActionsPool)
     41QMenu* UIMachineMenuBar::createMenu(UIActionsPool *pActionsPool, UIMainMenuType fOptions /* = UIMainMenuType_All */)
    4242{
    4343    /* Create empty menu: */
     
    4545
    4646    /* Fill menu with prepared items: */
    47     foreach (QMenu *pSubMenu, prepareSubMenus(pActionsPool))
     47    foreach (QMenu *pSubMenu, prepareSubMenus(pActionsPool, fOptions))
    4848        pMenu->addMenu(pSubMenu);
    4949
     
    5252}
    5353
    54 QMenuBar* UIMachineMenuBar::createMenuBar(UIActionsPool *pActionsPool)
     54QMenuBar* UIMachineMenuBar::createMenuBar(UIActionsPool *pActionsPool, UIMainMenuType fOptions /* = UIMainMenuType_All */)
    5555{
    5656    /* Create empty menubar: */
     
    5858
    5959    /* Fill menubar with prepared items: */
    60     foreach (QMenu *pSubMenu, prepareSubMenus(pActionsPool))
     60    foreach (QMenu *pSubMenu, prepareSubMenus(pActionsPool, fOptions))
    6161        pMenuBar->addMenu(pSubMenu);
    6262
     
    6565}
    6666
    67 QList<QMenu*> UIMachineMenuBar::prepareSubMenus(UIActionsPool *pActionsPool)
     67QList<QMenu*> UIMachineMenuBar::prepareSubMenus(UIActionsPool *pActionsPool, UIMainMenuType fOptions /* = UIMainMenuType_All */)
    6868{
    6969    /* Create empty submenu list: */
     
    7171
    7272    /* Machine submenu: */
    73     QMenu *pMenuMachine = pActionsPool->action(UIActionIndex_Menu_Machine)->menu();
    74     prepareMenuMachine(pMenuMachine, pActionsPool);
    75     preparedSubMenus << pMenuMachine;
     73    if (fOptions & UIMainMenuType_Machine)
     74    {
     75        QMenu *pMenuMachine = pActionsPool->action(UIActionIndex_Menu_Machine)->menu();
     76        prepareMenuMachine(pMenuMachine, pActionsPool);
     77        preparedSubMenus << pMenuMachine;
     78    }
     79
     80    /* View submenu: */
     81    if (fOptions & UIMainMenuType_View)
     82    {
     83        QMenu *pMenuView = pActionsPool->action(UIActionIndex_Menu_View)->menu();
     84        preparedSubMenus << pMenuView;
     85    }
    7686
    7787    /* Devices submenu: */
    78     QMenu *pMenuDevices = pActionsPool->action(UIActionIndex_Menu_Devices)->menu();
    79     prepareMenuDevices(pMenuDevices, pActionsPool);
    80     preparedSubMenus << pMenuDevices;
     88    if (fOptions & UIMainMenuType_Devices)
     89    {
     90        QMenu *pMenuDevices = pActionsPool->action(UIActionIndex_Menu_Devices)->menu();
     91        prepareMenuDevices(pMenuDevices, pActionsPool);
     92        preparedSubMenus << pMenuDevices;
     93    }
    8194
    8295#ifdef VBOX_WITH_DEBUGGER_GUI
    8396    /* Debug submenu: */
    84     if (vboxGlobal().isDebuggerEnabled())
     97    if (   fOptions & UIMainMenuType_Debug
     98        && vboxGlobal().isDebuggerEnabled())
    8599    {
    86100        QMenu *pMenuDebug = pActionsPool->action(UIActionIndex_Menu_Debug)->menu();
     
    91105
    92106    /* Help submenu: */
    93     QMenu *pMenuHelp = pActionsPool->action(UIActionIndex_Menu_Help)->menu();
    94     prepareMenuHelp(pMenuHelp, pActionsPool);
    95     preparedSubMenus << pMenuHelp;
     107    if (fOptions & UIMainMenuType_Help)
     108    {
     109        QMenu *pMenuHelp = pActionsPool->action(UIActionIndex_Menu_Help)->menu();
     110        prepareMenuHelp(pMenuHelp, pActionsPool);
     111        preparedSubMenus << pMenuHelp;
     112    }
    96113
    97114    /* Return a list of prepared submenus: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.h

    r27141 r27335  
    2424#define __UIMachineMenuBar_h__
    2525
     26/* Local includes */
     27#include "UIMachineDefs.h"
     28
    2629/* Global includes */
    2730#include <QList>
     
    3740{
    3841public:
    39 
    4042    UIMachineMenuBar();
    4143
    42     QMenu* createMenu(UIActionsPool *pActionsPool);
    43     QMenuBar* createMenuBar(UIActionsPool *pActionsPool);
     44    QMenu* createMenu(UIActionsPool *pActionsPool, UIMainMenuType fOptions = UIMainMenuType_All);
     45    QMenuBar* createMenuBar(UIActionsPool *pActionsPool, UIMainMenuType fOptions = UIMainMenuType_All);
    4446
    4547protected:
    4648
    47     QList<QMenu*> prepareSubMenus(UIActionsPool *pActionsPool);
     49    QList<QMenu*> prepareSubMenus(UIActionsPool *pActionsPool, UIMainMenuType fOptions = UIMainMenuType_All);
    4850    void prepareMenuMachine(QMenu *pMenu, UIActionsPool *pActionsPool);
    4951    void prepareMenuDevices(QMenu *pMenu, UIActionsPool *pActionsPool);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r27296 r27335  
    443443}
    444444#endif
     445
     446void UIMachineView::updateSliders()
     447{
     448    QSize p = viewport()->size();
     449    QSize m = maximumViewportSize();
     450
     451    QSize v = QSize(frameBuffer()->width(), frameBuffer()->height());
     452    /* No scroll bars needed: */
     453    if (m.expandedTo(v) == m)
     454        p = m;
     455
     456    horizontalScrollBar()->setRange(0, v.width() - p.width());
     457    verticalScrollBar()->setRange(0, v.height() - p.height());
     458    horizontalScrollBar()->setPageStep(p.width());
     459    verticalScrollBar()->setPageStep(p.height());
     460}
    445461
    446462void UIMachineView::prepareFrameBuffer()
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r27333 r27335  
    131131    virtual void calculateDesktopGeometry() = 0;
    132132    virtual void maybeRestrictMinimumSize() = 0;
    133     virtual void updateSliders() =  0;
     133    virtual void updateSliders();
    134134
    135135#ifdef Q_WS_MAC
     
    328328};
    329329
    330 #endif // !___UIMachineViewNormal_h___
    331 
     330#endif // !___UIMachineView_h___
     331
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h

    r27044 r27335  
    5757    CSession& session() const;
    5858
     59    virtual void reshow() {}
     60
    5961protected:
    6062
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r27310 r27335  
    680680}
    681681
    682 QMenu* UISession::newMenu()
     682QMenu* UISession::newMenu(UIMainMenuType fOptions /* = UIMainMenuType_ALL */)
    683683{
    684684    /* Create new menu: */
    685     QMenu *pMenu = m_pMenuPool->createMenu(actionsPool());
     685    QMenu *pMenu = m_pMenuPool->createMenu(actionsPool(), fOptions);
    686686
    687687    /* Re-init menu pool for the case menu were recreated: */
     
    692692}
    693693
    694 QMenuBar* UISession::newMenuBar()
     694QMenuBar* UISession::newMenuBar(UIMainMenuType fOptions /* = UIMainMenuType_ALL */)
    695695{
    696696    /* Create new menubar: */
    697     QMenuBar *pMenuBar = m_pMenuPool->createMenuBar(actionsPool());
     697    QMenuBar *pMenuBar = m_pMenuPool->createMenuBar(actionsPool(), fOptions);
    698698
    699699    /* Re-init menu pool for the case menu were recreated: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r27310 r27335  
    3030/* Local includes */
    3131#include "COMDefs.h"
     32#include "UIMachineDefs.h"
    3233
    3334/* Global forwards */
     
    8485    UIActionsPool* actionsPool() const;
    8586    QWidget* mainMachineWindow() const;
    86     QMenu* newMenu();
    87     QMenuBar* newMenuBar();
     87    QMenu* newMenu(UIMainMenuType fOptions = UIMainMenuType_All);
     88    QMenuBar* newMenuBar(UIMainMenuType fOptions = UIMainMenuType_All);
    8889    QCursor cursor() const { return m_cursor; }
    8990
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp

    r27311 r27335  
    3030#include "VBoxProblemReporter.h"
    3131
    32 #include "UISession.h"
    3332#include "UIActionsPool.h"
    3433#include "UIMachineLogicFullscreen.h"
    3534#include "UIMachineWindow.h"
    36 
    37 #include "VBoxUtils.h"
    38 
    39 #ifdef Q_WS_MAC
    40 # ifdef QT_MAC_USE_COCOA
    41 #  include <Carbon/Carbon.h>
    42 # endif /* QT_MAC_USE_COCOA */
     35#include "UIMachineWindowFullscreen.h"
     36#include "UIMultiScreenLayout.h"
     37#include "UISession.h"
     38
     39
     40#ifdef Q_WS_MAC
     41# include "VBoxUtils.h"
     42# include <Carbon/Carbon.h>
    4343#endif /* Q_WS_MAC */
    4444
     
    4646    : UIMachineLogic(pParent, pSession, pActionsPool, UIVisualStateType_Fullscreen)
    4747{
     48    m_pScreenLayout = new UIMultiScreenLayout(this);
    4849}
    4950
     
    5556    /* Cleanup action related stuff */
    5657    cleanupActionGroups();
     58
     59    delete m_pScreenLayout;
    5760}
    5861
     
    6770    const CConsole &console = uisession()->session().GetConsole();
    6871
    69 #if (QT_VERSION >= 0x040600)
    70     int cHostScreens = QApplication::desktop()->screenCount();
    71 #else /* (QT_VERSION >= 0x040600) */
    72     int cHostScreens = QApplication::desktop()->numScreens();
    73 #endif /* !(QT_VERSION >= 0x040600) */
    74 
    75     int cGuestScreens = machine.GetMonitorCount();
     72    int cHostScreens = m_pScreenLayout->hostScreenCount();
     73    int cGuestScreens = m_pScreenLayout->guestScreenCount();
    7674    /* Check that there are enough physical screens are connected: */
    7775    if (cHostScreens < cGuestScreens)
     
    167165}
    168166
     167int UIMachineLogicFullscreen::hostScreenForGuestScreen(int screenId) const
     168{
     169    return m_pScreenLayout->hostScreenForGuestScreen(screenId);
     170}
     171
    169172#ifdef Q_WS_MAC
    170173void UIMachineLogicFullscreen::prepareCommonConnections()
     
    183186    /* Adjust-window action isn't allowed in fullscreen: */
    184187    actionsPool()->action(UIActionIndex_Simple_AdjustWindow)->setVisible(false);
     188
     189    /* Add the view menu: */
     190    QMenu *pMenu = actionsPool()->action(UIActionIndex_Menu_View)->menu();
     191    m_pScreenLayout->initialize(pMenu);
    185192}
    186193
     
    198205#endif /* Q_WS_MAC */
    199206
    200 #if 0 // TODO: Add seamless multi-monitor support!
    201     /* Get monitors count: */
    202     ulong uMonitorCount = session().GetMachine().GetMonitorCount();
     207    /* Update the multi screen layout */
     208    m_pScreenLayout->update();
     209
    203210    /* Create machine window(s): */
    204     for (ulong uScreenId = 0; uScreenId < uMonitorCount; ++ uScreenId)
    205         addMachineWindow(UIMachineWindow::create(this, visualStateType(), uScreenId));
     211    for (int screenId = 0; screenId < m_pScreenLayout->guestScreenCount(); ++screenId)
     212        addMachineWindow(UIMachineWindow::create(this, visualStateType(), screenId));
    206213    /* Order machine window(s): */
    207     for (ulong uScreenId = uMonitorCount; uScreenId > 0; -- uScreenId)
    208         machineWindows()[uScreenId - 1]->machineWindow()->raise();
    209 #else
    210     /* Create primary machine window: */
    211     addMachineWindow(UIMachineWindow::create(this, visualStateType(), 0 /* primary only */));
    212 #endif
     214    for (int screenId = m_pScreenLayout->guestScreenCount() - 1; screenId >= 0; --screenId)
     215        machineWindows().at(screenId)->machineWindow()->raise();
     216
     217    foreach (UIMachineWindow *pMachineWindow, machineWindows())
     218        connect(m_pScreenLayout, SIGNAL(screenLayoutChanged()),
     219                static_cast<UIMachineWindowFullscreen*>(pMachineWindow), SLOT(sltPlaceOnScreen()));
    213220
    214221    /* Remember what machine window(s) created: */
     
    222229        return;
    223230
    224 #if 0 // TODO: Add seamless multi-monitor support!
    225231    /* Cleanup normal machine window: */
    226232    foreach (UIMachineWindow *pMachineWindow, machineWindows())
    227233        UIMachineWindow::destroy(pMachineWindow);
    228 #else
    229     /* Create machine window(s): */
    230     UIMachineWindow::destroy(machineWindows()[0] /* primary only */);
    231 #endif
    232234
    233235#ifdef Q_WS_MAC
     
    272274}
    273275#endif /* Q_WS_MAC */
     276
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.h

    r27310 r27335  
    2929/* Local forwards */
    3030class UIActionsPool;
     31class UIMultiScreenLayout;
    3132class VBoxChangePresentationModeEvent;
    3233
     
    4546    bool checkAvailability();
    4647    void initialize();
     48
     49    int hostScreenForGuestScreen(int screenId) const;
    4750
    4851private slots:
     
    7275#endif /* Q_WS_MAC */
    7376
     77    UIMultiScreenLayout *m_pScreenLayout;
     78
    7479    /* Friend classes: */
    7580    friend class UIMachineLogic;
     81    friend class UIMachineWindowFullscreen;
    7682};
    7783
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h

    r27237 r27335  
    8181    void calculateDesktopGeometry();
    8282    void maybeRestrictMinimumSize();
    83     void updateSliders() {}
    8483
    8584    /* Private members: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r27332 r27335  
    3232#include "VBoxMiniToolBar.h"
    3333
    34 #include "UISession.h"
    3534#include "UIActionsPool.h"
    3635#include "UIMachineLogic.h"
     36#include "UIMachineLogicFullscreen.h"
    3737#include "UIMachineView.h"
    3838#include "UIMachineWindowFullscreen.h"
     39#include "UISession.h"
    3940
    4041UIMachineWindowFullscreen::UIMachineWindowFullscreen(UIMachineLogic *pMachineLogic, ulong uScreenId)
     
    7576    updateAppearanceOf(UIVisualElement_AllStuff);
    7677
     78    /* Make sure the window is placed on the right screen before we are going
     79     * into fullscreen. */
     80    sltPlaceOnScreen();
     81
    7782    /* Show window: */
    7883    showFullScreen();
     
    8085#ifdef Q_WS_MAC
    8186    /* Make sure it is really on the right place (especially on the Mac) */
    82     move(0, 0);
     87    QRect r = QApplication::desktop()->screenGeometry(static_cast<UIMachineLogicFullscreen*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId));
     88    move(r.topLeft());
    8389#endif /* Q_WS_MAC */
    8490}
     
    95101    cleanupMenu();
    96102}
     103
     104void UIMachineWindowFullscreen::sltPlaceOnScreen()
     105{
     106    QRect r = QApplication::desktop()->screenGeometry(static_cast<UIMachineLogicFullscreen*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId));
     107    move(r.topLeft());
     108    resize(r.size());
     109}
     110
    97111
    98112void UIMachineWindowFullscreen::sltMachineStateChanged()
     
    155169void UIMachineWindowFullscreen::prepareMenu()
    156170{
    157 #ifdef Q_WS_MAC
    158     setMenuBar(uisession()->newMenuBar());
    159 #endif /* Q_WS_MAC */
    160     m_pMainMenu = uisession()->newMenu();
     171    UIMainMenuType fMenus = UIMainMenuType_All;
     172    /* Remove the view menu in the case there is one screen only. */
     173    if (session().GetMachine().GetMonitorCount() == 1)
     174        fMenus = UIMainMenuType(fMenus ^ UIMainMenuType_View);
     175#ifdef Q_WS_MAC
     176    setMenuBar(uisession()->newMenuBar(fMenus));
     177#endif /* Q_WS_MAC */
     178    m_pMainMenu = uisession()->newMenu(fMenus);
    161179}
    162180
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.h

    r27332 r27335  
    3838{
    3939    Q_OBJECT;
     40
     41public slots:
     42
     43    void sltPlaceOnScreen();
    4044
    4145protected:
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h

    r27310 r27335  
    4646private slots:
    4747
    48     /* Windowed mode funtionality: */
     48    /* Windowed mode functionality: */
    4949    void sltPrepareNetworkAdaptersMenu();
    5050    void sltPrepareSharedFoldersMenu();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp

    r27296 r27335  
    358358}
    359359
    360 void UIMachineViewNormal::updateSliders()
    361 {
    362     QSize p = viewport()->size();
    363     QSize m = maximumViewportSize();
    364 
    365     QSize v = QSize(frameBuffer()->width(), frameBuffer()->height());
    366     /* No scroll bars needed: */
    367     if (m.expandedTo(v) == m)
    368         p = m;
    369 
    370     horizontalScrollBar()->setRange(0, v.width() - p.width());
    371     verticalScrollBar()->setRange(0, v.height() - p.height());
    372     horizontalScrollBar()->setPageStep(p.width());
    373     verticalScrollBar()->setPageStep(p.height());
    374 }
    375 
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h

    r27237 r27335  
    7979    void calculateDesktopGeometry();
    8080    void maybeRestrictMinimumSize();
    81     void updateSliders();
    8281
    8382    /* Private members: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r27174 r27335  
    349349void UIMachineWindowNormal::prepareMenu()
    350350{
    351     setMenuBar(uisession()->newMenuBar());
     351    /* No view menu in normal mode */
     352    setMenuBar(uisession()->newMenuBar(UIMainMenuType(UIMainMenuType_All ^ UIMainMenuType_View)));
    352353}
    353354
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp

    r27311 r27335  
    3030#include "VBoxProblemReporter.h"
    3131
    32 #include "UISession.h"
    3332#include "UIActionsPool.h"
    3433#include "UIMachineLogicSeamless.h"
    3534#include "UIMachineWindow.h"
    36 
    37 #include "VBoxUtils.h"
     35#include "UIMachineWindowSeamless.h"
     36#include "UIMultiScreenLayout.h"
     37#include "UISession.h"
     38
     39#ifdef Q_WS_MAC
     40# include "VBoxUtils.h"
     41#endif /* Q_WS_MAC */
    3842
    3943UIMachineLogicSeamless::UIMachineLogicSeamless(QObject *pParent, UISession *pSession, UIActionsPool *pActionsPool)
    4044    : UIMachineLogic(pParent, pSession, pActionsPool, UIVisualStateType_Seamless)
    4145{
     46    m_pScreenLayout = new UIMultiScreenLayout(this);
    4247}
    4348
     
    4954    /* Cleanup actions groups: */
    5055    cleanupActionGroups();
     56
     57    delete m_pScreenLayout;
    5158}
    5259
     
    6168    const CConsole &console = uisession()->session().GetConsole();
    6269
    63 #if (QT_VERSION >= 0x040600)
    64     int cHostScreens = QApplication::desktop()->screenCount();
    65 #else /* (QT_VERSION >= 0x040600) */
    66     int cHostScreens = QApplication::desktop()->numScreens();
    67 #endif /* !(QT_VERSION >= 0x040600) */
    68 
    69     int cGuestScreens = machine.GetMonitorCount();
     70    int cHostScreens = m_pScreenLayout->hostScreenCount();
     71    int cGuestScreens = m_pScreenLayout->guestScreenCount();
    7072    /* Check that there are enough physical screens are connected: */
    7173    if (cHostScreens < cGuestScreens)
     
    155157}
    156158
     159int UIMachineLogicSeamless::hostScreenForGuestScreen(int screenId) const
     160{
     161    return m_pScreenLayout->hostScreenForGuestScreen(screenId);
     162}
     163
    157164void UIMachineLogicSeamless::prepareActionGroups()
    158165{
     
    168175    /* Disable mouse-integration isn't allowed in seamless: */
    169176    actionsPool()->action(UIActionIndex_Toggle_MouseIntegration)->setVisible(false);
     177
     178    /* Add the view menu: */
     179    QMenu *pMenu = actionsPool()->action(UIActionIndex_Menu_View)->menu();
     180    m_pScreenLayout->initialize(pMenu);
     181    pMenu->setVisible(true);
    170182}
    171183
     
    182194#endif /* Q_WS_MAC */
    183195
    184 #if 0 // TODO: Add seamless multi-monitor support!
    185     /* Get monitors count: */
    186     ulong uMonitorCount = session().GetMachine().GetMonitorCount();
     196    /* Update the multi screen layout */
     197    m_pScreenLayout->update();
     198
    187199    /* Create machine window(s): */
    188     for (ulong uScreenId = 0; uScreenId < uMonitorCount; ++ uScreenId)
    189         addMachineWindow(UIMachineWindow::create(this, visualStateType(), uScreenId));
     200    for (int screenId = 0; screenId < m_pScreenLayout->guestScreenCount(); ++screenId)
     201        addMachineWindow(UIMachineWindow::create(this, visualStateType(), screenId));
    190202    /* Order machine window(s): */
    191     for (ulong uScreenId = uMonitorCount; uScreenId > 0; -- uScreenId)
    192         machineWindows()[uScreenId - 1]->machineWindow()->raise();
    193 #else
    194     /* Create primary machine window: */
    195     addMachineWindow(UIMachineWindow::create(this, visualStateType(), 0 /* primary only */));
    196 #endif
     203    for (int screenId = m_pScreenLayout->guestScreenCount() - 1; screenId >= 0; --screenId)
     204        machineWindows().at(screenId)->machineWindow()->raise();
     205
     206    foreach (UIMachineWindow *pMachineWindow, machineWindows())
     207        connect(m_pScreenLayout, SIGNAL(screenLayoutChanged()),
     208                static_cast<UIMachineWindowSeamless*>(pMachineWindow), SLOT(sltPlaceOnScreen()));
    197209
    198210    /* Remember what machine window(s) created: */
     
    206218        return;
    207219
    208 #if 0 // TODO: Add seamless multi-monitor support!
    209220    /* Cleanup normal machine window: */
    210221    foreach (UIMachineWindow *pMachineWindow, machineWindows())
    211222        UIMachineWindow::destroy(pMachineWindow);
    212 #else
    213     /* Create machine window(s): */
    214     UIMachineWindow::destroy(machineWindows()[0] /* primary only */);
    215 #endif
    216223}
    217224
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.h

    r27028 r27335  
    2929/* Local forwards */
    3030class UIActionsPool;
     31class UIMultiScreenLayout;
    3132
    3233class UIMachineLogicSeamless : public UIMachineLogic
     
    4546    void initialize();
    4647
     48    int hostScreenForGuestScreen(int screenId) const;
     49
    4750private:
    4851
     
    5558    void cleanupActionGroups();
    5659
     60    UIMultiScreenLayout *m_pScreenLayout;
     61
    5762    /* Friend classes: */
    5863    friend class UIMachineLogic;
     64    friend class UIMachineWindowSeamless;
    5965};
    6066
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp

    r27296 r27335  
    3636#include "UISession.h"
    3737#include "UIMachineWindow.h"
     38#include "UIMachineLogic.h"
    3839#include "UIFrameBuffer.h"
    3940#include "UIMachineViewSeamless.h"
     
    275276QRect UIMachineViewSeamless::availableGeometry()
    276277{
     278//    return machineWindowWrapper()->machineLogic()->availableGeometry(screenId());
     279
    277280    return QApplication::desktop()->availableGeometry(this);
    278281}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.h

    r27333 r27335  
    7878    void calculateDesktopGeometry();
    7979    void maybeRestrictMinimumSize() {}
    80     void updateSliders() {}
    8180    QRegion lastVisibleRegion() const { return m_lastVisibleRegion; }
    8281
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp

    r27333 r27335  
    3232#include "VBoxMiniToolBar.h"
    3333
    34 #ifdef Q_WS_MAC
    35 # include "VBoxUtils.h"
    36 #endif /* Q_WS_MAC */
    37 #include "UISession.h"
    3834#include "UIActionsPool.h"
    3935#include "UIMachineLogic.h"
     36#include "UIMachineLogicSeamless.h"
    4037#include "UIMachineView.h"
    4138#include "UIMachineWindowSeamless.h"
     39#include "UIMachineWindowSeamless.h"
     40#include "UISession.h"
     41
     42#ifdef Q_WS_MAC
     43# include "VBoxUtils.h"
     44#endif /* Q_WS_MAC */
    4245
    4346UIMachineWindowSeamless::UIMachineWindowSeamless(UIMachineLogic *pMachineLogic, ulong uScreenId)
     
    100103    /* Cleanup menu: */
    101104    cleanupMenu();
     105}
     106
     107void UIMachineWindowSeamless::sltPlaceOnScreen()
     108{
     109    QRect r = QApplication::desktop()->availableGeometry(static_cast<UIMachineLogicSeamless*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId));
     110    move(r.topLeft());
     111    resize(r.size());
    102112}
    103113
     
    186196{
    187197#ifdef Q_WS_WIN
    188     m_prevRegion = QApplication::desktop()->availableGeometry();
     198    m_prevRegion = QApplication::desktop()->availableGeometry(static_cast<UIMachineLogicSeamless*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId));
    189199#endif
    190200
     
    200210void UIMachineWindowSeamless::prepareMenu()
    201211{
    202 #ifdef Q_WS_MAC
    203     setMenuBar(uisession()->newMenuBar());
    204 #endif /* Q_WS_MAC */
    205     m_pMainMenu = uisession()->newMenu();
     212    UIMainMenuType fMenus = UIMainMenuType_All;
     213    /* Remove the view menu in the case there is one screen only. */
     214    if (session().GetMachine().GetMonitorCount() == 1)
     215        fMenus = UIMainMenuType(fMenus ^ UIMainMenuType_View);
     216#ifdef Q_WS_MAC
     217    setMenuBar(uisession()->newMenuBar(fMenus));
     218#endif /* Q_WS_MAC */
     219    m_pMainMenu = uisession()->newMenu(fMenus);
    206220}
    207221
     
    328342{
    329343    /* Show manually maximized window: */
    330     QRect geometry = QApplication::desktop()->availableGeometry();
    331     move(geometry.topLeft());
    332     resize(geometry.size());
     344    sltPlaceOnScreen();
    333345    show();
     346
     347#ifdef Q_WS_MAC
     348    /* Make sure it is really on the right place (especially on the Mac) */
     349    QRect r = QApplication::desktop()->availableGeometry(static_cast<UIMachineLogicSeamless*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId));
     350    move(r.topLeft());
     351#endif /* Q_WS_MAC */
    334352}
    335353
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.h

    r27333 r27335  
    3838{
    3939    Q_OBJECT;
     40
     41public slots:
     42
     43    void sltPlaceOnScreen();
    4044
    4145protected:
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