Skip to content

Commit b7bd3fd

Browse files
jamierocksawesomekling
authored andcommitted
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.
1 parent d4f08fb commit b7bd3fd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Ladybird/Qt/WebContentView.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,11 @@ void WebContentView::initialize_client(WebView::ViewImplementation::CreateNewCli
568568
if (!screens.empty()) {
569569
Vector<Web::DevicePixelRect> screen_rects;
570570
for (auto const& screen : screens) {
571+
// NOTE: QScreen::geometry() returns the 'device-independent pixels', we multiply
572+
// by the device pixel ratio to get the 'physical pixels' of the display.
571573
auto geometry = screen->geometry();
572-
screen_rects.append(Web::DevicePixelRect(geometry.x(), geometry.y(), geometry.width(), geometry.height()));
574+
auto device_pixel_ratio = screen->devicePixelRatio();
575+
screen_rects.append(Web::DevicePixelRect(geometry.x(), geometry.y(), geometry.width() * device_pixel_ratio, geometry.height() * device_pixel_ratio));
573576
}
574577

575578
// FIXME: Update the screens again when QGuiApplication::screenAdded/Removed signals are emitted

0 commit comments

Comments
 (0)