From b7bd3fd92030d554c98bf88f9edce5e50698d670 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Sun, 21 Apr 2024 21:41:00 +0100 Subject: [PATCH] Ladybird: Calculate the 'physical pixels' for screens Previously the 'device independent pixels' (which consider scaling) were used, and then scaling would be applied again when calculating the screen width for CSS. --- Ladybird/Qt/WebContentView.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Ladybird/Qt/WebContentView.cpp b/Ladybird/Qt/WebContentView.cpp index 4dc6977540..7b2fb89b2d 100644 --- a/Ladybird/Qt/WebContentView.cpp +++ b/Ladybird/Qt/WebContentView.cpp @@ -568,8 +568,11 @@ void WebContentView::initialize_client(WebView::ViewImplementation::CreateNewCli if (!screens.empty()) { Vector screen_rects; for (auto const& screen : screens) { + // NOTE: QScreen::geometry() returns the 'device-independent pixels', we multiply + // by the device pixel ratio to get the 'physical pixels' of the display. auto geometry = screen->geometry(); - screen_rects.append(Web::DevicePixelRect(geometry.x(), geometry.y(), geometry.width(), geometry.height())); + auto device_pixel_ratio = screen->devicePixelRatio(); + screen_rects.append(Web::DevicePixelRect(geometry.x(), geometry.y(), geometry.width() * device_pixel_ratio, geometry.height() * device_pixel_ratio)); } // FIXME: Update the screens again when QGuiApplication::screenAdded/Removed signals are emitted