From 70b0fb840eee9a92823df9108988ee6a779f4ae5 Mon Sep 17 00:00:00 2001 From: Euclid Ye Date: Sat, 5 Jul 2025 00:05:01 +0800 Subject: [PATCH] embedder: Improve documentation for various places that talk about "available screen size" (#37879) Testing: Just add comment. It turns out difficult to achieve, see https://github.com/rust-windowing/winit/issues/2494. Fixes: Nothing. Provide some guidance to #37878 --------- Signed-off-by: Euclid Ye Co-authored-by: Martin Robinson --- components/shared/compositing/lib.rs | 3 ++- components/shared/embedder/lib.rs | 2 +- ports/servoshell/desktop/headed_window.rs | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/shared/compositing/lib.rs b/components/shared/compositing/lib.rs index c9d2fe861bf..513ba116c4c 100644 --- a/components/shared/compositing/lib.rs +++ b/components/shared/compositing/lib.rs @@ -174,7 +174,8 @@ pub enum CompositorMsg { GetClientWindowRect(WebViewId, IpcSender), /// Get the size of the screen that the client window inhabits. GetScreenSize(WebViewId, IpcSender), - /// Get the available screen size (without toolbars and docks) for the screen + /// Get the available screen size, without system interface elements such as menus, docks, and + /// taskbars. /// the client window inhabits. GetAvailableScreenSize(WebViewId, IpcSender), diff --git a/components/shared/embedder/lib.rs b/components/shared/embedder/lib.rs index 89fb41d7327..cc287d20a41 100644 --- a/components/shared/embedder/lib.rs +++ b/components/shared/embedder/lib.rs @@ -711,7 +711,7 @@ pub struct ScreenGeometry { pub size: DeviceIntSize, /// The available size of the screen in device pixels. This size is the size /// available for web content on the screen, and should be `size` minus any system - /// toolbars, docks, and interface elements of the browser. This will be converted to + /// toolbars, docks, and interface elements. This will be converted to /// CSS pixels based on the pixel scaling of the `WebView`. pub available_size: DeviceIntSize, /// The offset of the `WebView` in device pixels for the purposes of the `window.screenLeft` diff --git a/ports/servoshell/desktop/headed_window.rs b/ports/servoshell/desktop/headed_window.rs index e0d3124e804..89594622f5b 100644 --- a/ports/servoshell/desktop/headed_window.rs +++ b/ports/servoshell/desktop/headed_window.rs @@ -431,6 +431,9 @@ impl WindowPortsMethods for Window { ); let screen_size = self.screen_size.to_f32() * hidpi_factor; + // FIXME: In reality, this should subtract screen space used by the system interface + // elements, but it is difficult to get this value with `winit` currently. See: + // See https://github.com/rust-windowing/winit/issues/2494 let available_screen_size = screen_size - toolbar_size; // Offset the WebView origin by the toolbar so that it reflects the actual viewport and