VirtualBox

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


Ignore:
Timestamp:
Jan 22, 2015 10:51:03 AM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: 6278: Support for scaled video-output: More strict scaled hints calculation.

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

Legend:

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

    r53892 r53909  
    6262#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    6363
    64 
    6564/* Other VBox includes: */
    6665#include <iprt/asm.h>
     
    193192     * the available size for the guest display. We assume here that centralWidget()
    194193     * contains this view only and gives it all available space: */
    195     QSize newSize(toSize.isValid() ? toSize : machineWindow()->centralWidget()->size());
    196     AssertMsg(newSize.isValid(), ("Size should be valid!\n"));
     194    QSize size(toSize.isValid() ? toSize : machineWindow()->centralWidget()->size());
     195    AssertMsg(size.isValid(), ("Size should be valid!\n"));
    197196
    198197#ifdef Q_WS_MAC
     
    202201        const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
    203202        if (dBackingScaleFactor > 1.0)
    204             newSize *= dBackingScaleFactor;
     203            size = QSize(size.width() * dBackingScaleFactor, size.height() * dBackingScaleFactor);
    205204    }
    206205#endif /* Q_WS_MAC */
    207206
    208207    /* Take the scale-factor into account: */
    209     newSize /= gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     208    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     209    if (dScaleFactor != 1.0)
     210        size = QSize(size.width() / dScaleFactor, size.height() / dScaleFactor);
    210211
    211212    /* Expand current limitations: */
    212     setMaxGuestSize(newSize);
     213    setMaxGuestSize(size);
    213214
    214215    /* Send new size-hint to the guest: */
    215216    LogRel(("UIMachineView::sltPerformGuestResize: "
    216217            "Sending guest size-hint to screen %d as %dx%d\n",
    217             (int)screenId(), newSize.width(), newSize.height()));
     218            (int)screenId(), size.width(), size.height()));
    218219    display().SetVideoModeHint(screenId(),
    219220                               uisession()->isScreenVisible(screenId()),
    220                                false, 0, 0, newSize.width(), newSize.height(), 0);
     221                               false, 0, 0, size.width(), size.height(), 0);
    221222
    222223    /* And track whether we have a "normal" or "fullscreen"/"seamless" size-hint sent: */
     
    324325        if (dBackingScaleFactor > 1.0)
    325326        {
    326             rect.moveTo(rect.topLeft() / dBackingScaleFactor - QPoint(1, 1));
    327             rect.setSize(rect.size() / dBackingScaleFactor + QSize(2, 2));
     327            rect.moveTo(rect.x() / dBackingScaleFactor - 1,
     328                        rect.y() / dBackingScaleFactor - 1);
     329            rect.setSize(QSize(rect.width()  / dBackingScaleFactor + 2,
     330                               rect.height() / dBackingScaleFactor + 2));
    328331        }
    329332    }
     
    741744    QSize size(m_pFrameBuffer->width(), m_pFrameBuffer->height());
    742745
     746    /* Take the scale-factor into account: */
     747    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     748    if (dScaleFactor != 1.0)
     749        size = QSize(size.width() * dScaleFactor, size.height() * dScaleFactor);
     750
    743751#ifdef Q_WS_MAC
    744752    /* Take the backing-scale-factor into account: */
     
    747755        const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
    748756        if (dBackingScaleFactor > 1.0)
    749             size /= dBackingScaleFactor;
     757            size = QSize(size.width() / dBackingScaleFactor, size.height() / dBackingScaleFactor);
    750758    }
    751759#endif /* Q_WS_MAC */
    752 
    753     /* Take the scale-factor into account: */
    754     size *= gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    755760
    756761#ifdef VBOX_WITH_DEBUGGER_GUI
     
    834839        size = QSize(800, 600);
    835840
     841    /* Take the scale-factor into account: */
     842    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     843    if (dScaleFactor != 1.0)
     844        size = QSize(size.width() * dScaleFactor, size.height() * dScaleFactor);
     845
    836846#ifdef Q_WS_MAC
    837847    /* Take the backing-scale-factor into account: */
     
    840850        const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
    841851        if (dBackingScaleFactor > 1.0)
    842             size /= dBackingScaleFactor;
     852            size = QSize(size.width() / dBackingScaleFactor, size.height() / dBackingScaleFactor);
    843853    }
    844854#endif /* Q_WS_MAC */
    845 
    846     /* Take the scale-factor into account: */
    847     size *= gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    848855
    849856    /* Return size: */
     
    970977    QSize v = QSize(frameBuffer()->width(), frameBuffer()->height());
    971978
     979    /* Take the scale-factor into account: */
     980    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     981    if (dScaleFactor != 1.0)
     982        v = QSize(v.width() * dScaleFactor, v.height() * dScaleFactor);
     983
    972984#ifdef Q_WS_MAC
    973985    /* Take the backing-scale-factor into account: */
     
    976988        const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
    977989        if (dBackingScaleFactor > 1.0)
    978             v /= dBackingScaleFactor;
     990            v = QSize(v.width() / dBackingScaleFactor, v.height() / dBackingScaleFactor);
    979991    }
    980992#endif /* Q_WS_MAC */
    981 
    982     /* Take the scale-factor into account: */
    983     v *= gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    984993
    985994    /* No scroll bars needed: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp

    r53389 r53909  
    2020#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
    2121
    22 /* Global includes */
     22/* Qt includes: */
    2323# include <QApplication>
    2424# include <QDesktopWidget>
     
    2727# ifdef Q_WS_MAC
    2828#  include <QMenuBar>
    29 # endif
     29# endif /* Q_WS_MAC */
    3030
    31 /* Local includes */
     31/* GUI includes: */
    3232# include "VBoxGlobal.h"
    3333# include "UISession.h"
     
    3838# include "UIFrameBuffer.h"
    3939# include "UIExtraDataManager.h"
     40# ifdef Q_WS_MAC
     41#  include "VBoxUtils-darwin.h"
     42# endif /* Q_WS_MAC */
    4043
    4144#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    4346#ifdef Q_WS_X11
    4447# include <limits.h>
    45 #endif
     48#endif /* Q_WS_X11 */
    4649
    4750
     
    149152    /* Acquire frame-buffer size: */
    150153    QSize frameBufferSize(frameBuffer()->width(), frameBuffer()->height());
     154
    151155    /* Take the scale-factor into account: */
    152     frameBufferSize *= gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     156    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     157    if (dScaleFactor != 1.0)
     158        frameBufferSize = QSize(frameBufferSize.width() * dScaleFactor, frameBufferSize.height() * dScaleFactor);
     159
     160#ifdef Q_WS_MAC
     161    /* Take the backing-scale-factor into account: */
     162    if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
     163    {
     164        const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
     165        if (dBackingScaleFactor > 1.0)
     166            frameBufferSize = QSize(frameBufferSize.width() / dBackingScaleFactor, frameBufferSize.height() / dBackingScaleFactor);
     167    }
     168#endif /* Q_WS_MAC */
     169
    153170    /* Check if we should adjust guest-screen to new size: */
    154171    if (frameBuffer()->isAutoEnabled() ||
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp

    r53389 r53909  
    2020#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
    2121
    22 /* Global includes */
     22/* Qt includes: */
    2323# include <QApplication>
    2424# include <QDesktopWidget>
     
    2828# include <QTimer>
    2929
    30 /* Local includes */
     30/* GUI includes: */
    3131# include "VBoxGlobal.h"
    3232# include "UISession.h"
     
    3737# include "UIExtraDataManager.h"
    3838# include "UIFrameBuffer.h"
     39# ifdef Q_WS_MAC
     40#  include "VBoxUtils-darwin.h"
     41# endif /* Q_WS_MAC */
    3942
    4043#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    172175    /* Acquire frame-buffer size: */
    173176    QSize frameBufferSize(frameBuffer()->width(), frameBuffer()->height());
     177
    174178    /* Take the scale-factor into account: */
    175     frameBufferSize *= gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     179    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     180    if (dScaleFactor != 1.0)
     181        frameBufferSize = QSize(frameBufferSize.width() * dScaleFactor, frameBufferSize.height() * dScaleFactor);
     182
     183#ifdef Q_WS_MAC
     184    /* Take the backing-scale-factor into account: */
     185    if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
     186    {
     187        const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
     188        if (dBackingScaleFactor > 1.0)
     189            frameBufferSize = QSize(frameBufferSize.width() / dBackingScaleFactor, frameBufferSize.height() / dBackingScaleFactor);
     190    }
     191#endif /* Q_WS_MAC */
     192
    176193    /* Check if we should adjust guest-screen to new size: */
    177194    if (frameBufferSize != centralWidgetSize)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp

    r53389 r53909  
    3737# include "UIFrameBuffer.h"
    3838# include "UIExtraDataManager.h"
     39# ifdef Q_WS_MAC
     40#  include "VBoxUtils-darwin.h"
     41# endif /* Q_WS_MAC */
    3942
    4043/* COM includes: */
     
    166169    /* Acquire frame-buffer size: */
    167170    QSize frameBufferSize(frameBuffer()->width(), frameBuffer()->height());
     171
    168172    /* Take the scale-factor into account: */
    169     frameBufferSize *= gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     173    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     174    if (dScaleFactor != 1.0)
     175        frameBufferSize = QSize(frameBufferSize.width() * dScaleFactor, frameBufferSize.height() * dScaleFactor);
     176
     177#ifdef Q_WS_MAC
     178    /* Take the backing-scale-factor into account: */
     179    if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
     180    {
     181        const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
     182        if (dBackingScaleFactor > 1.0)
     183            frameBufferSize = QSize(frameBufferSize.width() / dBackingScaleFactor, frameBufferSize.height() / dBackingScaleFactor);
     184    }
     185#endif /* Q_WS_MAC */
     186
    170187    /* Check if we should adjust guest-screen to new size: */
    171188    if (frameBuffer()->isAutoEnabled() ||
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