Browse Source

Ladybird/Qt: Calculate the 'physical pixels' for screens

This fixes a regression introduced by GH-23855 in [1], and re-applies
a previous change I made [2].

[1] https://github.com/SerenityOS/serenity/commit/dfc7534
[2] https://github.com/SerenityOS/serenity/commit/b7bd3fd
Jamie Mansfield 1 year ago
parent
commit
b08d43a5d3
1 changed files with 4 additions and 1 deletions
  1. 4 1
      Ladybird/Qt/WebContentView.cpp

+ 4 - 1
Ladybird/Qt/WebContentView.cpp

@@ -543,8 +543,11 @@ void WebContentView::update_screen_rects()
     if (!screens.empty()) {
         Vector<Web::DevicePixelRect> 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));
         }
 
         // NOTE: The first item in QGuiApplication::screens is always the primary screen.