VirtualBox

Changeset 69957 in vbox


Ignore:
Timestamp:
Dec 6, 2017 1:35:06 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8694: Make macOS Unscaled HiDPI Output feature to be cross-platform; Enable automatic HiDPI upscaling for Windows/Linux hosts.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
7 edited

Legend:

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

    r69931 r69957  
    44474447    }
    44484448
    4449 #ifdef VBOX_WS_MAC
    44504449    /* Take the device-pixel-ratio into account: */
    44514450    if (mSizeInfo.useUnscaledHiDPIOutput())
     
    44604459        }
    44614460    }
    4462 #endif /* VBOX_WS_MAC */
    44634461
    44644462    /* we do not to miss notify updates, because we have to update bg textures for it,
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r69824 r69957  
    398398        qInstallMessageHandler(QtMessageOutput);
    399399
     400        /* Enable HiDPI support: */
     401        QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
     402        QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
     403
    400404        /* Create application: */
    401405        QApplication a(argc, argv);
     
    412416
    413417#ifdef VBOX_WS_MAC
    414         /* Enable HiDPI icons: */
    415         a.setAttribute(Qt::AA_UseHighDpiPixmaps);
    416 
    417418        /* Disable menu icons on MacOS X host: */
    418419        ::darwinDisableIconsInMenus();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp

    r69931 r69957  
    15201520        }
    15211521
    1522 #ifdef VBOX_WS_MAC
    15231522        /* Should we
    15241523         * not perform logical HiDPI scaling or
     
    15291528            subPixmap.setDevicePixelRatio(dDevicePixelRatio);
    15301529        }
    1531 #endif /* VBOX_WS_MAC */
    15321530    }
    15331531
     
    15781576        }
    15791577
    1580 #ifdef VBOX_WS_MAC
    15811578        /* Should we
    15821579         * not perform logical HiDPI scaling or
     
    15871584            subPixmap.setDevicePixelRatio(dDevicePixelRatio);
    15881585        }
    1589 #endif /* VBOX_WS_MAC */
    15901586    }
    15911587
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r69931 r69957  
    439439    rect.translate(-contentsX(), -contentsY());
    440440
    441 #ifdef VBOX_WS_MAC
    442441    /* Take the device-pixel-ratio into account: */
    443442    if (frameBuffer()->useUnscaledHiDPIOutput())
     
    452451        }
    453452    }
    454 #endif /* VBOX_WS_MAC */
    455453
    456454    /* Limit the resulting part by the viewport rectangle: */
     
    631629    , m_pFrameBuffer(0)
    632630    , m_previousState(KMachineState_Null)
    633 #ifdef VBOX_WS_MAC
    634631    , m_iHostScreenNumber(0)
    635 #endif /* VBOX_WS_MAC */
    636632    , m_maxGuestSizePolicy(MaxGuestResolutionPolicy_Automatic)
    637633    , m_u64MaxGuestSize(0)
     
    705701        m_pFrameBuffer->setScalingOptimizationType(gEDataManager->scalingOptimizationType(vboxGlobal().managedVMUuid()));
    706702
    707 #ifdef VBOX_WS_MAC
    708703        /* Take device-pixel-ratio into account: */
    709704        m_pFrameBuffer->setDevicePixelRatio(gpDesktop->devicePixelRatio(machineWindow()));
    710 #endif /* VBOX_WS_MAC */
    711705
    712706        /* Take the scale-factor related attributes into account: */
     
    11201114    /* Finally copy the screen-shot to pause-pixmap: */
    11211115    m_pausePixmap = QPixmap::fromImage(screenShot);
    1122 #ifdef VBOX_WS_MAC
    11231116    /* Adjust device-pixel-ratio if necessary: */
    11241117    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
    11251118    if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput())
    11261119        m_pausePixmap.setDevicePixelRatio(dDevicePixelRatio);
    1127 #endif /* VBOX_WS_MAC */
    11281120
    11291121    /* Update scaled pause pixmap: */
     
    11551147    /* Finally copy the screen-shot to pause-pixmap: */
    11561148    m_pausePixmap = QPixmap::fromImage(screenShot);
    1157 #ifdef VBOX_WS_MAC
    11581149    /* Adjust device-pixel-ratio if necessary: */
    11591150    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
    11601151    if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput())
    11611152        m_pausePixmap.setDevicePixelRatio(dDevicePixelRatio);
    1162 #endif /* VBOX_WS_MAC */
    11631153
    11641154    /* Update scaled pause pixmap: */
     
    11791169    /* Update pause pixmap finally: */
    11801170    m_pausePixmapScaled = pausePixmap().scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    1181 #ifdef VBOX_WS_MAC
    11821171    /* Adjust device-pixel-ratio if necessary: */
    11831172    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
    11841173    if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput())
    11851174        m_pausePixmapScaled.setDevicePixelRatio(dDevicePixelRatio);
    1186 #endif /* VBOX_WS_MAC */
    11871175}
    11881176
     
    12071195    int yRange = frameBufferSize.height() - curViewportSize.height();
    12081196
    1209 #ifdef VBOX_WS_MAC
    1210     /* Due to Qt 4.x doesn't supports HiDPI directly
    1211      * we should take the device-pixel-ratio into account.
    1212      * See also viewportToContents()... */
     1197    /* Take the device-pixel-ratio into account: */
    12131198    if (frameBuffer()->useUnscaledHiDPIOutput())
    12141199    {
     
    12201205        }
    12211206    }
    1222 #endif /* VBOX_WS_MAC */
    12231207
    12241208    /* Configure scroll-bars: */
     
    12351219    int iContentsY = contentsY();
    12361220
    1237 #ifdef VBOX_WS_MAC
    1238     /* Due to Qt 4.x doesn't supports HiDPI directly
    1239      * we should take the device-pixel-ratio into account.
    1240      * See also updateSliders()... */
     1221    /* Take the device-pixel-ratio into account: */
    12411222    if (frameBuffer()->useUnscaledHiDPIOutput())
    12421223    {
     
    12481229        }
    12491230    }
    1250 #endif /* VBOX_WS_MAC */
    12511231
    12521232    /* Return point shifted according scroll-bars: */
     
    14471427                break;
    14481428            }
    1449 #ifdef VBOX_WS_MAC
    14501429            case QEvent::Move:
    14511430            {
     
    14711450                break;
    14721451            }
    1473 #endif /* VBOX_WS_MAC */
    14741452            default:
    14751453                break;
     
    18681846        size = QSize((int)(size.width() * dScaleFactor), (int)(size.height() * dScaleFactor));
    18691847
    1870 #ifdef VBOX_WS_MAC
    18711848    /* Take the device-pixel-ratio into account: */
    18721849    if (frameBuffer()->useUnscaledHiDPIOutput())
     
    18761853            size = QSize(size.width() / dDevicePixelRatio, size.height() / dDevicePixelRatio);
    18771854    }
    1878 #endif /* VBOX_WS_MAC */
    18791855
    18801856    /* Return result: */
     
    18841860QSize UIMachineView::scaledBackward(QSize size) const
    18851861{
    1886 #ifdef VBOX_WS_MAC
    18871862    /* Take the device-pixel-ratio into account: */
    18881863    if (frameBuffer()->useUnscaledHiDPIOutput())
     
    18921867            size = QSize(size.width() * dDevicePixelRatio, size.height() * dDevicePixelRatio);
    18931868    }
    1894 #endif /* VBOX_WS_MAC */
    18951869
    18961870    /* Take the scale-factor into account: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r69500 r69957  
    351351    QSize m_sizeHintOverride;
    352352
    353 #ifdef VBOX_WS_MAC
    354353    /** Holds current host-screen number. */
    355354    int m_iHostScreenNumber;
    356 #endif /* VBOX_WS_MAC */
    357355
    358356    /** The policy for calculating the maximum guest resolution which we wish
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r69931 r69957  
    10441044            }
    10451045
    1046 #ifdef VBOX_WS_MAC
    10471046            /* Take the device-pixel-ratio into account: */
    10481047            if (pFrameBuffer->useUnscaledHiDPIOutput())
     
    10551054                }
    10561055            }
    1057 #endif /* VBOX_WS_MAC */
    10581056
    10591057#ifdef VBOX_WITH_DRAG_AND_DROP
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r68958 r69957  
    4545        , m_cGuestScreenCount(0)
    4646        , m_dScaleFactor(1.0)
    47 #ifdef VBOX_WS_MAC
    4847        , m_fUseUnscaledHiDPIOutput(false)
    49 #endif /* VBOX_WS_MAC */
    5048        , m_f3dAccelerationEnabled(false)
    5149#ifdef VBOX_WITH_VIDEOHWACCEL
     
    7573               && (m_cGuestScreenCount == other.m_cGuestScreenCount)
    7674               && (m_dScaleFactor == other.m_dScaleFactor)
    77 #ifdef VBOX_WS_MAC
    7875               && (m_fUseUnscaledHiDPIOutput == other.m_fUseUnscaledHiDPIOutput)
    79 #endif /* VBOX_WS_MAC */
    8076               && (m_f3dAccelerationEnabled == other.m_f3dAccelerationEnabled)
    8177#ifdef VBOX_WITH_VIDEOHWACCEL
     
    231227    /** Holds the guest screen scale-factor. */
    232228    double  m_dScaleFactor;
    233 #ifdef VBOX_WS_MAC
    234229    /** Holds whether automatic Retina scaling is disabled. */
    235230    bool    m_fUseUnscaledHiDPIOutput;
    236 #endif /* VBOX_WS_MAC */
    237231    /** Holds whether the 3D acceleration is enabled. */
    238232    bool    m_f3dAccelerationEnabled;
     
    353347    oldDisplayData.m_cGuestScreenCount = m_machine.GetMonitorCount();
    354348    oldDisplayData.m_dScaleFactor = gEDataManager->scaleFactor(m_machine.GetId());
    355 #ifdef VBOX_WS_MAC
    356349    oldDisplayData.m_fUseUnscaledHiDPIOutput = gEDataManager->useUnscaledHiDPIOutput(m_machine.GetId());
    357 #endif
    358350    oldDisplayData.m_f3dAccelerationEnabled = m_machine.GetAccelerate3DEnabled();
    359351#ifdef VBOX_WITH_VIDEOHWACCEL
     
    403395    m_pEditorVideoScreenCount->setValue(oldDisplayData.m_cGuestScreenCount);
    404396    m_pEditorGuestScreenScale->setValue((int)(oldDisplayData.m_dScaleFactor * 100));
    405 #ifdef VBOX_WS_MAC
    406397    m_pCheckBoxUnscaledHiDPIOutput->setChecked(oldDisplayData.m_fUseUnscaledHiDPIOutput);
    407 #endif
    408398    m_pCheckbox3D->setChecked(oldDisplayData.m_f3dAccelerationEnabled);
    409399#ifdef VBOX_WITH_VIDEOHWACCEL
     
    452442    newDisplayData.m_cGuestScreenCount = m_pEditorVideoScreenCount->value();
    453443    newDisplayData.m_dScaleFactor = (double)m_pEditorGuestScreenScale->value() / 100;
    454 #ifdef VBOX_WS_MAC
    455444    newDisplayData.m_fUseUnscaledHiDPIOutput = m_pCheckBoxUnscaledHiDPIOutput->isChecked();
    456 #endif
    457445    newDisplayData.m_f3dAccelerationEnabled = m_pCheckbox3D->isChecked();
    458446#ifdef VBOX_WITH_VIDEOHWACCEL
     
    711699    m_pLabelGuestScreenScaleMax->setEnabled(isMachineInValidMode());
    712700    m_pEditorGuestScreenScale->setEnabled(isMachineInValidMode());
    713 #ifdef VBOX_WS_MAC
    714701    m_pLabelHiDPI->setEnabled(isMachineInValidMode());
    715702    m_pCheckBoxUnscaledHiDPIOutput->setEnabled(isMachineInValidMode());
    716 #else /* !VBOX_WS_MAC */
    717     m_pLabelHiDPI->hide();
    718     m_pCheckBoxUnscaledHiDPIOutput->hide();
    719 #endif /* !VBOX_WS_MAC */
    720703    m_pLabelVideoOptions->setEnabled(isMachineOffline());
    721704    m_pCheckbox3D->setEnabled(isMachineOffline());
     
    14141397        if (fSuccess && newDisplayData.m_dScaleFactor != oldDisplayData.m_dScaleFactor)
    14151398            /* fSuccess = */ gEDataManager->setScaleFactor(newDisplayData.m_dScaleFactor, strMachineId);
    1416 #ifdef VBOX_WS_MAC
    14171399        /* Save whether Unscaled HiDPI Output is enabled: : */
    14181400        if (fSuccess && newDisplayData.m_fUseUnscaledHiDPIOutput != oldDisplayData.m_fUseUnscaledHiDPIOutput)
    14191401            /* fSuccess = */ gEDataManager->setUseUnscaledHiDPIOutput(newDisplayData.m_fUseUnscaledHiDPIOutput, strMachineId);
    1420 #endif
    14211402    }
    14221403    /* Return result: */
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