瀏覽代碼

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.
Jamie Mansfield 1 年之前
父節點
當前提交
b7bd3fd920
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      Ladybird/Qt/WebContentView.cpp

+ 4 - 1
Ladybird/Qt/WebContentView.cpp

@@ -568,8 +568,11 @@ void WebContentView::initialize_client(WebView::ViewImplementation::CreateNewCli
     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));
         }
 
         // FIXME: Update the screens again when QGuiApplication::screenAdded/Removed signals are emitted