From 1fa45e63a342eae05a64262f73efd4eb404b6647 Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Tue, 30 Mar 2021 08:18:12 -0400 Subject: [PATCH] UI: Remove fractional scaling ifdefs Among the systems we officially support, the oldest Qt version is Qt 5.9 on Ubuntu 18.04. Fractional scaling is supported in Qt 5.6 and newer. We should be able to safely remove these ifdefs. --- UI/display-helpers.hpp | 8 -------- UI/window-basic-interaction.cpp | 4 ---- UI/window-basic-main.cpp | 5 ----- UI/window-basic-preview.cpp | 19 ------------------- 4 files changed, 36 deletions(-) diff --git a/UI/display-helpers.hpp b/UI/display-helpers.hpp index 5b1b20ca7..eff3c51ea 100644 --- a/UI/display-helpers.hpp +++ b/UI/display-helpers.hpp @@ -17,10 +17,6 @@ #pragma once -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) -#define SUPPORTS_FRACTIONAL_SCALING -#endif - static inline void GetScaleAndCenterPos(int baseCX, int baseCY, int windowCX, int windowCY, int &x, int &y, float &scale) @@ -55,9 +51,5 @@ static inline void GetCenterPosFromFixedScale(int baseCX, int baseCY, static inline QSize GetPixelSize(QWidget *widget) { -#ifdef SUPPORTS_FRACTIONAL_SCALING return widget->size() * widget->devicePixelRatioF(); -#else - return widget->size() * widget->devicePixelRatio(); -#endif } diff --git a/UI/window-basic-interaction.cpp b/UI/window-basic-interaction.cpp index 304fb56c5..b2788259b 100644 --- a/UI/window-basic-interaction.cpp +++ b/UI/window-basic-interaction.cpp @@ -221,11 +221,7 @@ static int TranslateQtMouseEventModifiers(QMouseEvent *event) bool OBSBasicInteraction::GetSourceRelativeXY(int mouseX, int mouseY, int &relX, int &relY) { -#ifdef SUPPORTS_FRACTIONAL_SCALING float pixelRatio = devicePixelRatioF(); -#else - float pixelRatio = devicePixelRatio(); -#endif int mouseXscaled = (int)roundf(mouseX * pixelRatio); int mouseYscaled = (int)roundf(mouseY * pixelRatio); diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index f27bc85af..20b18e373 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -1279,13 +1279,8 @@ bool OBSBasic::InitBasicConfigDefaults() uint32_t cx = primaryScreen->size().width(); uint32_t cy = primaryScreen->size().height(); -#ifdef SUPPORTS_FRACTIONAL_SCALING cx *= devicePixelRatioF(); cy *= devicePixelRatioF(); -#elif - cx *= devicePixelRatio(); - cy *= devicePixelRatio(); -#endif bool oldResolutionDefaults = config_get_bool( App()->GlobalConfig(), "General", "Pre19Defaults"); diff --git a/UI/window-basic-preview.cpp b/UI/window-basic-preview.cpp index 579b34dbb..fa211e71b 100644 --- a/UI/window-basic-preview.cpp +++ b/UI/window-basic-preview.cpp @@ -13,9 +13,6 @@ #define HANDLE_RADIUS 4.0f #define HANDLE_SEL_RADIUS (HANDLE_RADIUS * 1.5f) -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) -#define SUPPORTS_FRACTIONAL_SCALING -#endif /* TODO: make C++ math classes and clean up code here later */ @@ -44,11 +41,7 @@ OBSBasicPreview::~OBSBasicPreview() vec2 OBSBasicPreview::GetMouseEventPos(QMouseEvent *event) { OBSBasic *main = reinterpret_cast(App()->GetMainWindow()); -#ifdef SUPPORTS_FRACTIONAL_SCALING float pixelRatio = main->devicePixelRatioF(); -#else - float pixelRatio = main->devicePixelRatio(); -#endif float scale = pixelRatio / main->previewScale; vec2 pos; vec2_set(&pos, @@ -406,11 +399,7 @@ void OBSBasicPreview::GetStretchHandleData(const vec2 &pos, bool ignoreGroup) if (!scene) return; -#ifdef SUPPORTS_FRACTIONAL_SCALING float scale = main->previewScale / main->devicePixelRatioF(); -#else - float scale = main->previewScale / main->devicePixelRatio(); -#endif vec2 scaled_pos = pos; vec2_divf(&scaled_pos, &scaled_pos, scale); HandleFindData data(scaled_pos, scale); @@ -533,11 +522,7 @@ void OBSBasicPreview::mousePressEvent(QMouseEvent *event) } OBSBasic *main = reinterpret_cast(App()->GetMainWindow()); -#ifdef SUPPORTS_FRACTIONAL_SCALING float pixelRatio = main->devicePixelRatioF(); -#else - float pixelRatio = main->devicePixelRatio(); -#endif float x = float(event->x()) - main->previewX / pixelRatio; float y = float(event->y()) - main->previewY / pixelRatio; Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers(); @@ -1552,11 +1537,7 @@ void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event) mousePos = pos; OBSBasic *main = reinterpret_cast( App()->GetMainWindow()); -#ifdef SUPPORTS_FRACTIONAL_SCALING float scale = main->devicePixelRatioF(); -#else - float scale = main->devicePixelRatio(); -#endif float x = float(event->x()) - main->previewX / scale; float y = float(event->y()) - main->previewY / scale; vec2_set(&startPos, x, y);