VirtualBox

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


Ignore:
Timestamp:
Aug 4, 2016 3:29:10 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8422: Desktop-widget watchdog rework (part 06): Do not cache host-screen count.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/globals
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.cpp

    r62990 r62998  
    109109    : QObject(pParent)
    110110    , m_pDesktopWidget(QApplication::desktop())
    111     , m_cHostScreenCount(-1)
    112111{
    113112    /* Prepare: */
     
    121120}
    122121
     122int UIDesktopWidgetWatchdog::screenCount() const
     123{
     124    /* Redirect call to desktop-widget: */
     125    return QApplication::desktop()->screenCount();
     126}
     127
    123128const QRect UIDesktopWidgetWatchdog::screenGeometry(int iHostScreenIndex /* = -1 */) const
    124129{
    125130    /* Make sure index is valid: */
    126     if (iHostScreenIndex < 0 || iHostScreenIndex >= m_cHostScreenCount)
     131    if (iHostScreenIndex < 0 || iHostScreenIndex >= screenCount())
    127132        iHostScreenIndex = m_pDesktopWidget->primaryScreen();
    128     AssertReturn(iHostScreenIndex >= 0 && iHostScreenIndex < m_cHostScreenCount, QRect());
     133    AssertReturn(iHostScreenIndex >= 0 && iHostScreenIndex < screenCount(), QRect());
    129134
    130135    /* Redirect call to desktop-widget: */
     
    135140{
    136141    /* Make sure index is valid: */
    137     if (iHostScreenIndex < 0 || iHostScreenIndex >= m_cHostScreenCount)
     142    if (iHostScreenIndex < 0 || iHostScreenIndex >= screenCount())
    138143        iHostScreenIndex = m_pDesktopWidget->primaryScreen();
    139     AssertReturn(iHostScreenIndex >= 0 && iHostScreenIndex < m_cHostScreenCount, QRect());
     144    AssertReturn(iHostScreenIndex >= 0 && iHostScreenIndex < screenCount(), QRect());
    140145
    141146    /* Return cached available-geometry: */
     
    157162void UIDesktopWidgetWatchdog::sltHostScreenAdded(QScreen *pHostScreen)
    158163{
    159 //    printf("UIDesktopWidgetWatchdog::sltHostScreenAdded(%d)\n", m_pDesktopWidget->screenCount());
     164//    printf("UIDesktopWidgetWatchdog::sltHostScreenAdded(%d)\n", screenCount());
    160165
    161166    /* Update host-screen configuration: */
     
    165170void UIDesktopWidgetWatchdog::sltHostScreenRemoved(QScreen *pHostScreen)
    166171{
    167 //    printf("UIDesktopWidgetWatchdog::sltHostScreenRemoved(%d)\n", m_pDesktopWidget->screenCount());
     172//    printf("UIDesktopWidgetWatchdog::sltHostScreenRemoved(%d)\n", screenCount());
    168173
    169174    /* Update host-screen configuration: */
     
    228233{
    229234    /* Acquire new host-screen count: */
    230     m_cHostScreenCount = cHostScreenCount != -1 ? cHostScreenCount : m_pDesktopWidget->screenCount();
     235    if (cHostScreenCount == -1)
     236        cHostScreenCount = screenCount();
    231237
    232238    /* Cleanup existing workers first: */
     
    234240
    235241    /* Resize workers vectors to new host-screen count: */
    236     m_availableGeometryWorkers.resize(m_cHostScreenCount);
    237     m_availableGeometryData.resize(m_cHostScreenCount);
     242    m_availableGeometryWorkers.resize(cHostScreenCount);
     243    m_availableGeometryData.resize(cHostScreenCount);
    238244
    239245    /* Update host-screen available-geometry for each particular host-screen: */
    240     for (int iHostScreenIndex = 0; iHostScreenIndex < m_cHostScreenCount; ++iHostScreenIndex)
     246    for (int iHostScreenIndex = 0; iHostScreenIndex < cHostScreenCount; ++iHostScreenIndex)
    241247        updateHostScreenAvailableGeometry(iHostScreenIndex);
    242248}
     
    245251{
    246252    /* Make sure index is valid: */
    247     if (iHostScreenIndex < 0 || iHostScreenIndex >= m_cHostScreenCount)
     253    if (iHostScreenIndex < 0 || iHostScreenIndex >= screenCount())
    248254        iHostScreenIndex = m_pDesktopWidget->primaryScreen();
    249     AssertReturnVoid(iHostScreenIndex >= 0 && iHostScreenIndex < m_cHostScreenCount);
     255    AssertReturnVoid(iHostScreenIndex >= 0 && iHostScreenIndex < screenCount());
    250256
    251257    /* Create invisible frame-less window worker: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.h

    r62990 r62998  
    4343    /** Destructs watchdog. */
    4444    ~UIDesktopWidgetWatchdog();
     45
     46    /** Returns the host-screen count. */
     47    int screenCount() const;
    4548
    4649    /** Returns the geometry of the host-screen with @a iHostScreenIndex.
     
    8992    QDesktopWidget *m_pDesktopWidget;
    9093
    91     /** Holds current host-screen count. */
    92     int m_cHostScreenCount;
    9394    /** Holds current host-screen available-geometries. */
    9495    QVector<QRect> m_availableGeometryData;
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