فهرست منبع

Fix handling of autoselected interface scaling by client

Ivan Savenko 1 سال پیش
والد
کامیت
e442e71ed9

+ 2 - 0
client/render/IScreenHandler.h

@@ -44,6 +44,8 @@ public:
 	/// Dimensions of logical output. Can be different if scaling is used
 	virtual Point getLogicalResolution() const = 0;
 
+	virtual int getInterfaceScalingPercentage() const = 0;
+
 	virtual int getScalingFactor() const = 0;
 
 	/// Window has focus

+ 1 - 1
client/renderSDL/CursorHardware.cpp

@@ -48,7 +48,7 @@ void CursorHardware::setVisible(bool on)
 
 void CursorHardware::setImage(std::shared_ptr<IImage> image, const Point & pivotOffset)
 {
-	int videoScalingSettings = settings["video"]["resolution"]["scaling"].Integer();
+	int videoScalingSettings = GH.screenHandler().getInterfaceScalingPercentage();
 	float cursorScalingSettings = settings["video"]["cursorScalingFactor"].Float();
 	int cursorScalingPercent = videoScalingSettings * cursorScalingSettings;
 	Point cursorDimensions = image->dimensions() * GH.screenHandler().getScalingFactor();

+ 10 - 6
client/renderSDL/ScreenHandler.cpp

@@ -84,12 +84,8 @@ Rect ScreenHandler::convertLogicalPointsToWindow(const Rect & input) const
 	return result;
 }
 
-Point ScreenHandler::getPreferredLogicalResolution() const
+int ScreenHandler::getInterfaceScalingPercentage() const
 {
-	Point renderResolution = getRenderResolution();
-	double reservedAreaWidth = settings["video"]["reservedWidth"].Float();
-	Point availableResolution = Point(renderResolution.x * (1 - reservedAreaWidth), renderResolution.y);
-
 	auto [minimalScaling, maximalScaling] = getSupportedScalingRange();
 
 	int userScaling = settings["video"]["resolution"]["scaling"].Integer();
@@ -110,9 +106,17 @@ Point ScreenHandler::getPreferredLogicalResolution() const
 	}
 
 	int scaling = std::clamp(userScaling, minimalScaling, maximalScaling);
+	return scaling;
+}
 
-	Point logicalResolution = availableResolution * 100.0 / scaling;
+Point ScreenHandler::getPreferredLogicalResolution() const
+{
+	Point renderResolution = getRenderResolution();
+	double reservedAreaWidth = settings["video"]["reservedWidth"].Float();
 
+	int scaling = getInterfaceScalingPercentage();
+	Point availableResolution = Point(renderResolution.x * (1 - reservedAreaWidth), renderResolution.y);
+	Point logicalResolution = availableResolution * 100.0 / scaling;
 	return logicalResolution;
 }
 

+ 2 - 0
client/renderSDL/ScreenHandler.h

@@ -112,6 +112,8 @@ public:
 
 	int getScalingFactor() const final;
 
+	int getInterfaceScalingPercentage() const final;
+
 	std::vector<Point> getSupportedResolutions() const final;
 	std::vector<Point> getSupportedResolutions(int displayIndex) const;
 	std::tuple<int, int> getSupportedScalingRange() const final;

+ 1 - 3
client/windows/settings/GeneralOptionsTab.cpp

@@ -194,10 +194,8 @@ GeneralOptionsTab::GeneralOptionsTab()
 
 	build(config);
 
-	const auto & currentResolution = settings["video"]["resolution"];
-
 	std::shared_ptr<CLabel> scalingLabel = widget<CLabel>("scalingLabel");
-	scalingLabel->setText(scalingToLabelString(currentResolution["scaling"].Integer()));
+	scalingLabel->setText(scalingToLabelString(GH.screenHandler().getInterfaceScalingPercentage()));
 
 	std::shared_ptr<CLabel> longTouchLabel = widget<CLabel>("longTouchLabel");
 	if (longTouchLabel)