From 78a69a7dc9fc77948db223057a4bdb4c41e292e9 Mon Sep 17 00:00:00 2001 From: Adrien Prokopowicz <6529475+prokopyl@users.noreply.github.com> Date: Tue, 25 Aug 2026 07:59:48 +0200 Subject: [PATCH 1/4] wip --- examples/plugin_clack/src/gui.rs | 54 +++--------------- src/context.rs | 2 +- src/dpi.rs | 96 ++++++++++++++++++++++++++++++++ src/lib.rs | 2 +- src/window.rs | 7 ++- 5 files changed, 112 insertions(+), 49 deletions(-) create mode 100644 src/dpi.rs diff --git a/examples/plugin_clack/src/gui.rs b/examples/plugin_clack/src/gui.rs index f3d58cda..74fefa5e 100644 --- a/examples/plugin_clack/src/gui.rs +++ b/examples/plugin_clack/src/gui.rs @@ -71,7 +71,9 @@ impl PluginGuiImpl for ExamplePluginMainThread<'_> { return None; }; - Some(window_size_to_gui_size(gui.handle.size())) + let size = gui.handle.size().to_native_size(); + + Some(GuiSize { width: size.width, height: size.height }) } fn can_resize(&mut self) -> bool { @@ -96,13 +98,13 @@ impl PluginGuiImpl for ExamplePluginMainThread<'_> { let scale_factor = gui.handle.size().scale_factor; if let Some(max_size) = gui.handle.max_size() { - let max_size = size_to_gui_size(max_size, scale_factor); + let max_size = NativeSize::from_size(max_size, scale_factor); size.width = size.width.min(max_size.width); size.height = size.height.min(max_size.height); } if let Some(min_size) = gui.handle.min_size() { - let min_size = size_to_gui_size(min_size, scale_factor); + let min_size = NativeSize::from_size(min_size, scale_factor); size.width = size.width.max(min_size.width); size.height = size.height.max(min_size.height); } @@ -115,8 +117,7 @@ impl PluginGuiImpl for ExamplePluginMainThread<'_> { return Err(PluginError::Message("set_size called without a GUI active")); }; - let size = gui_size_to_window_size(size); - gui.handle.resize(size)?; + gui.handle.resize(NativeSize { width: size.width, height: size.height })?; Ok(()) } @@ -162,45 +163,6 @@ impl PluginGuiImpl for ExamplePluginMainThread<'_> { } } -fn size_to_gui_size(size: Size, scale_factor: f64) -> GuiSize { - #[cfg(target_os = "macos")] - { - let size = size.to_logical(scale_factor); - GuiSize { width: size.width, height: size.height } - } - - #[cfg(not(target_os = "macos"))] - { - let size = size.to_physical(scale_factor); - GuiSize { width: size.width, height: size.height } - } -} - -fn window_size_to_gui_size(size: WindowSize) -> GuiSize { - #[cfg(target_os = "macos")] - { - let size = size.logical.cast(); - GuiSize { width: size.width, height: size.height } - } - - #[cfg(not(target_os = "macos"))] - { - let size = size.physical.cast(); - GuiSize { width: size.width, height: size.height } - } -} - -fn gui_size_to_window_size(size: GuiSize) -> Size { - #[cfg(target_os = "macos")] - { - Size::Logical(LogicalSize::new(size.width, size.height).cast()) - } - #[cfg(not(target_os = "macos"))] - { - Size::Physical(PhysicalSize::new(size.width, size.height)) - } -} - struct MainThreadHandler { host: HostSharedHandle<'static>, } @@ -218,8 +180,8 @@ struct HostGuiCallbacks { impl HostCallbacks for HostGuiCallbacks { fn request_resize(&mut self, new_size: WindowSize) -> Result<(), HandlerError> { - let size = window_size_to_gui_size(new_size); - self.ext.request_resize(&self.host, size.width, size.height)?; + let new_size = new_size.to_native_size(); + self.ext.request_resize(&self.host, new_size.width, new_size.height)?; Ok(()) } diff --git a/src/context.rs b/src/context.rs index 5c1ca9ca..a83b8f1f 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,6 +1,6 @@ use super::*; +use crate::dpi::Size; use crate::{platform, MouseCursor, WindowSize}; -use dpi::Size; use raw_window_handle::{ DisplayHandle, HandleError, HasDisplayHandle, HasWindowHandle, WindowHandle, }; diff --git a/src/dpi.rs b/src/dpi.rs new file mode 100644 index 00000000..c52d2e59 --- /dev/null +++ b/src/dpi.rs @@ -0,0 +1,96 @@ +use crate::WindowSize; +pub use dpi::*; + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +pub struct NativeSize

{ + pub width: P, + pub height: P, +} + +impl

NativeSize

{ + #[inline] + pub const fn new(width: P, height: P) -> Self { + NativeSize { width, height } + } +} + +impl NativeSize

{ + #[inline] + pub fn from_size(size: Size, scale_factor: f64) -> Self { + #[cfg(target_os = "macos")] + { + let size = size.to_logical(scale_factor); + Self { width: size.width, height: size.height } + } + + #[cfg(not(target_os = "macos"))] + { + let size = size.to_physical(scale_factor); + Self { width: size.width, height: size.height } + } + } + + #[inline] + pub fn cast(&self) -> NativeSize { + NativeSize { width: self.width.cast(), height: self.height.cast() } + } + + #[inline] + pub fn to_physical(self, scale_factor: f64) -> PhysicalSize

{ + #[cfg(target_os = "macos")] + { + let size = LogicalSize { width: self.width, height: self.height }; + size.to_physical(scale_factor) + } + #[cfg(not(target_os = "macos"))] + { + let _ = scale_factor; + PhysicalSize { width: self.width, height: self.height } + } + } + + #[inline] + pub fn to_logical(self, scale_factor: f64) -> LogicalSize

{ + #[cfg(target_os = "macos")] + { + let _ = scale_factor; + LogicalSize { width: self.width, height: self.height } + } + #[cfg(not(target_os = "macos"))] + { + let size = PhysicalSize { width: self.width, height: self.height }; + size.to_logical(scale_factor) + } + } +} + +impl From for NativeSize

{ + #[inline] + fn from(size: WindowSize) -> Self { + #[cfg(target_os = "macos")] + { + let size = size.logical.cast(); + Self { width: size.width, height: size.height } + } + + #[cfg(not(target_os = "macos"))] + { + let size = size.physical.cast(); + Self { width: size.width, height: size.height } + } + } +} + +impl From> for Size { + #[inline] + fn from(size: NativeSize

) -> Self { + #[cfg(target_os = "macos")] + { + Size::Logical(LogicalSize::new(size.width, size.height).cast()) + } + #[cfg(not(target_os = "macos"))] + { + Size::Physical(PhysicalSize::new(size.width, size.height).cast()) + } + } +} diff --git a/src/lib.rs b/src/lib.rs index 737c1d91..4e2cbe8b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ mod clipboard; mod context; +pub mod dpi; mod error; mod event; mod handler; @@ -17,7 +18,6 @@ pub mod gl; pub use clipboard::*; pub use context::{PlatformHandle, WindowContext}; -pub use dpi; pub use error::*; pub use event::*; pub use handler::WindowHandler; diff --git a/src/window.rs b/src/window.rs index b2fe41c9..f88b04f4 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1,8 +1,8 @@ +use crate::dpi::*; use crate::handler::WindowHandlerBuilder; use crate::host::Host; use crate::platform; use crate::*; -use dpi::{LogicalSize, PhysicalSize, Pixel, Size}; use std::marker::PhantomData; /// A handle to a Window created by baseview. @@ -262,6 +262,11 @@ impl WindowSize { pub fn from_logical(logical: LogicalSize, scale_factor: f64) -> Self { Self { physical: logical.to_physical(scale_factor), logical, scale_factor } } + + #[inline] + pub fn to_native_size(&self) -> NativeSize

{ + (*self).into() + } } impl From for PhysicalSize

{ From e7655a2a8bf94e843eb55716281d7c89c54ef1f9 Mon Sep 17 00:00:00 2001 From: Adrien Prokopowicz <6529475+prokopyl@users.noreply.github.com> Date: Tue, 25 Aug 2026 08:20:09 +0200 Subject: [PATCH 2/4] fixes --- src/event.rs | 2 +- src/platform/macos/context.rs | 2 +- src/platform/macos/view.rs | 2 +- src/platform/macos/window.rs | 2 +- src/platform/win/drop_target.rs | 2 +- src/platform/win/window.rs | 2 +- src/platform/win/window_state.rs | 2 +- src/platform/x11/drag_n_drop.rs | 2 +- src/platform/x11/event_loop.rs | 2 +- src/platform/x11/window_shared.rs | 2 +- src/platform/x11/window_thread.rs | 2 +- src/platform/x11/xcb_window.rs | 2 +- src/settings.rs | 2 +- src/utils.rs | 2 +- src/wrappers/appkit/view.rs | 2 +- src/wrappers/appkit/window.rs | 2 +- src/wrappers/win32.rs | 2 +- src/wrappers/win32/rect.rs | 2 +- src/wrappers/win32/window.rs | 2 +- src/wrappers/win32/window/handle.rs | 4 ++-- 20 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/event.rs b/src/event.rs index 438f0904..9ac7d0ce 100644 --- a/src/event.rs +++ b/src/event.rs @@ -1,4 +1,4 @@ -use dpi::PhysicalPosition; +use crate::dpi::PhysicalPosition; use keyboard_types::{KeyboardEvent, Modifiers}; use std::path::PathBuf; diff --git a/src/platform/macos/context.rs b/src/platform/macos/context.rs index 20e498fd..652b308e 100644 --- a/src/platform/macos/context.rs +++ b/src/platform/macos/context.rs @@ -1,3 +1,4 @@ +use crate::dpi::Size; use crate::platform::macos::cursor::Cursor; use crate::platform::macos::view::BaseviewView; use crate::platform::Result; @@ -5,7 +6,6 @@ use crate::platform::{PlatformHandle, WindowSharedState}; use crate::wrappers::appkit::{View, ViewRef}; use crate::*; use dispatch2::MainThreadBound; -use dpi::Size; use objc2::rc::Weak; use objc2::runtime::NSObjectProtocol; use objc2::{MainThreadMarker, Message}; diff --git a/src/platform/macos/view.rs b/src/platform/macos/view.rs index d9f2bf7a..cf3c5a0e 100644 --- a/src/platform/macos/view.rs +++ b/src/platform/macos/view.rs @@ -2,6 +2,7 @@ use super::keyboard::{make_modifiers, KeyboardState}; use super::window::WindowSharedState; +use crate::dpi::{LogicalPosition, LogicalSize, Size}; use crate::host::Host; use crate::platform::*; use crate::tracing::warn; @@ -13,7 +14,6 @@ use crate::{ DropData, DropEffect, Event, EventStatus, MouseButton, MouseEvent, ScrollDelta, WindowEvent, WindowHandler, WindowSize, }; -use dpi::{LogicalPosition, LogicalSize, Size}; use objc2::__framework_prelude::Retained; use objc2::rc::Weak; use objc2::runtime::{NSObjectProtocol, ProtocolObject}; diff --git a/src/platform/macos/window.rs b/src/platform/macos/window.rs index 954d7847..7596efa4 100644 --- a/src/platform/macos/window.rs +++ b/src/platform/macos/window.rs @@ -1,4 +1,4 @@ -use dpi::{LogicalSize, Size}; +use crate::dpi::{LogicalSize, Size}; use objc2::rc::{autoreleasepool, Retained, Weak}; use objc2::MainThreadMarker; use objc2_app_kit::{NSApplication, NSPasteboard, NSPasteboardTypeString, NSView, NSWindow}; diff --git a/src/platform/win/drop_target.rs b/src/platform/win/drop_target.rs index 44312648..5a84fe68 100644 --- a/src/platform/win/drop_target.rs +++ b/src/platform/win/drop_target.rs @@ -1,6 +1,6 @@ #![expect(clippy::indexing_slicing, reason = "To be refactored later")] -use dpi::PhysicalPosition; +use crate::dpi::PhysicalPosition; use std::cell::{Cell, RefCell}; use std::ffi::OsString; use std::os::windows::prelude::OsStringExt; diff --git a/src/platform/win/window.rs b/src/platform/win/window.rs index 985220f8..4be2a621 100644 --- a/src/platform/win/window.rs +++ b/src/platform/win/window.rs @@ -5,7 +5,7 @@ use windows_sys::Win32::{ }; use crate::{warn, EventStatus, HandlerError, WindowHandler}; -use dpi::{PhysicalPosition, PhysicalSize, Size}; +use crate::{PhysicalPosition, PhysicalSize, Size}; use std::cell::{Cell, OnceCell}; use std::num::NonZeroUsize; use windows_sys::Win32::Foundation::POINT; diff --git a/src/platform/win/window_state.rs b/src/platform/win/window_state.rs index 2f96f697..070e8ac4 100644 --- a/src/platform/win/window_state.rs +++ b/src/platform/win/window_state.rs @@ -1,3 +1,4 @@ +use crate::dpi::{PhysicalSize, Size}; use crate::platform::win::keyboard::KeyboardState; use crate::platform::PlatformHandle; use crate::utils::SizingStrategy; @@ -7,7 +8,6 @@ use crate::wrappers::win32::window::HWnd; use crate::wrappers::win32::{Dpi, ExtendedUser32}; use crate::WindowSettings; use crate::{MouseCursor, WindowSize}; -use dpi::{PhysicalSize, Size}; use raw_window_handle::{DisplayHandle, Win32WindowHandle}; use std::cell::{Cell, Ref, RefCell}; use std::num::NonZeroIsize; diff --git a/src/platform/x11/drag_n_drop.rs b/src/platform/x11/drag_n_drop.rs index edfcdb2a..a849b316 100644 --- a/src/platform/x11/drag_n_drop.rs +++ b/src/platform/x11/drag_n_drop.rs @@ -1,11 +1,11 @@ use super::xcb_connection::{Atoms, GetPropertyError}; use super::*; +use crate::dpi::PhysicalPosition; use crate::handler::WindowHandler; use crate::platform::x11::error::ReplyExt; use crate::warn; use crate::{DropData, Event, MouseEvent}; use core::result::Result; -use dpi::PhysicalPosition; use keyboard_types::Modifiers; use percent_encoding::percent_decode; use std::error::Error; diff --git a/src/platform/x11/event_loop.rs b/src/platform/x11/event_loop.rs index 9aad89fe..47590394 100644 --- a/src/platform/x11/event_loop.rs +++ b/src/platform/x11/event_loop.rs @@ -3,6 +3,7 @@ use super::keyboard::{convert_key_press_event, convert_key_release_event, key_mo use super::*; use std::result::Result; +use crate::dpi::{PhysicalPosition, PhysicalSize}; use crate::host::HostMainThreadCaller; use crate::platform::x11::error::FatalError; use crate::platform::x11::window_thread::{ @@ -14,7 +15,6 @@ use crate::{Event, MouseButton, MouseEvent, ScrollDelta, WindowEvent, WindowHand use calloop::generic::Generic; use calloop::timer::{TimeoutAction, Timer}; use calloop::{Interest, LoopHandle, LoopSignal, Mode, PostAction}; -use dpi::{PhysicalPosition, PhysicalSize}; use std::rc::Rc; use std::sync::mpsc; use std::sync::mpsc::Receiver; diff --git a/src/platform/x11/window_shared.rs b/src/platform/x11/window_shared.rs index cecd76cc..203f911d 100644 --- a/src/platform/x11/window_shared.rs +++ b/src/platform/x11/window_shared.rs @@ -1,3 +1,4 @@ +use crate::dpi::{PhysicalSize, Size}; use crate::platform::x11::event_loop::EventLoop; use crate::platform::x11::visibility_tree::AncestorVisibilityState; use crate::platform::x11::visual_info::WindowVisualConfig; @@ -8,7 +9,6 @@ use crate::platform::*; use crate::utils::SizingStrategy; use crate::{warn, MouseCursor, WindowHandler, WindowSettings, WindowSize}; use calloop::LoopSignal; -use dpi::{PhysicalSize, Size}; use raw_window_handle::{DisplayHandle, XlibWindowHandle}; use std::cell::Cell; use std::rc::Rc; diff --git a/src/platform/x11/window_thread.rs b/src/platform/x11/window_thread.rs index d57b10da..764452d7 100644 --- a/src/platform/x11/window_thread.rs +++ b/src/platform/x11/window_thread.rs @@ -1,4 +1,5 @@ use super::*; +use crate::dpi::{PhysicalSize, Size}; use crate::handler::WindowHandlerBuilder; use crate::host::HostCallbacks; use crate::platform::x11::event_loop::{EventLoop, MainThreadCaller}; @@ -8,7 +9,6 @@ use crate::warn; use crate::window::WindowInitializer; use crate::{WindowContext, WindowSettings, WindowSize}; use calloop::LoopSignal; -use dpi::{PhysicalSize, Size}; use std::cell::{Cell, RefCell}; use std::panic::resume_unwind; use std::rc::Rc; diff --git a/src/platform/x11/xcb_window.rs b/src/platform/x11/xcb_window.rs index 252c07dc..9c0e66f6 100644 --- a/src/platform/x11/xcb_window.rs +++ b/src/platform/x11/xcb_window.rs @@ -1,7 +1,7 @@ +use crate::dpi::PhysicalSize; use crate::platform::x11::error::CookieExt; use crate::platform::x11::visual_info::WindowVisualConfig; use crate::platform::X11Connection; -use dpi::PhysicalSize; use std::num::{NonZero, NonZeroU32}; use std::rc::Rc; use x11rb::connection::Connection; diff --git a/src/settings.rs b/src/settings.rs index 671f1760..cee0e125 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1,7 +1,7 @@ +use crate::dpi::{LogicalSize, Size}; #[cfg(feature = "opengl")] use crate::gl::GlConfig; use crate::platform; -use dpi::{LogicalSize, Size}; use raw_window_handle::HasWindowHandle; /// Settings used when creating a new window. diff --git a/src/utils.rs b/src/utils.rs index f4712021..1aa88287 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,5 +1,5 @@ +use crate::dpi::Size; use crate::WindowSettings; -use dpi::Size; #[derive(Copy, Clone)] pub(crate) enum SizingStrategy { diff --git a/src/wrappers/appkit/view.rs b/src/wrappers/appkit/view.rs index bed2b212..ac8b3898 100644 --- a/src/wrappers/appkit/view.rs +++ b/src/wrappers/appkit/view.rs @@ -1,4 +1,4 @@ -use dpi::LogicalSize; +use crate::dpi::LogicalSize; use objc2::__framework_prelude::{Allocated, AnyClass, ProtocolObject, Retained}; use objc2::rc::Weak; use objc2::runtime::{AnyObject, Ivar}; diff --git a/src/wrappers/appkit/window.rs b/src/wrappers/appkit/window.rs index bbfd0d53..5fe5d1e8 100644 --- a/src/wrappers/appkit/window.rs +++ b/src/wrappers/appkit/window.rs @@ -1,6 +1,6 @@ +use crate::dpi::LogicalSize; use crate::wrappers::appkit::{View, ViewImpl}; use crate::WindowSettings; -use dpi::LogicalSize; use objc2::rc::Retained; use objc2::{msg_send, MainThreadMarker, MainThreadOnly}; use objc2_app_kit::{NSBackingStoreType, NSWindow, NSWindowStyleMask}; diff --git a/src/wrappers/win32.rs b/src/wrappers/win32.rs index 4f2c5b01..c7e95686 100644 --- a/src/wrappers/win32.rs +++ b/src/wrappers/win32.rs @@ -8,7 +8,7 @@ mod user32; pub mod uuid; pub mod window; -pub use dpi::*; +pub use crate::dpi::*; pub use library::*; pub use rect::Rect; pub use style::*; diff --git a/src/wrappers/win32/rect.rs b/src/wrappers/win32/rect.rs index 73485c94..c4bd73e6 100644 --- a/src/wrappers/win32/rect.rs +++ b/src/wrappers/win32/rect.rs @@ -1,4 +1,4 @@ -use dpi::PhysicalSize; +use crate::dpi::PhysicalSize; use windows_sys::Win32::Foundation::RECT; #[derive(Copy, Clone)] diff --git a/src/wrappers/win32/window.rs b/src/wrappers/win32/window.rs index c1fc065b..8854d1f7 100644 --- a/src/wrappers/win32/window.rs +++ b/src/wrappers/win32/window.rs @@ -12,8 +12,8 @@ mod wgl; #[cfg(feature = "opengl")] pub use wgl::*; +use crate::dpi::PhysicalSize; pub use data::WindowData; -use dpi::PhysicalSize; pub use handle::HWnd; pub use proc::wnd_proc; use std::ptr::{null_mut, NonNull}; diff --git a/src/wrappers/win32/window/handle.rs b/src/wrappers/win32/window/handle.rs index efbbb5ba..1727233a 100644 --- a/src/wrappers/win32/window/handle.rs +++ b/src/wrappers/win32/window/handle.rs @@ -1,7 +1,7 @@ -use crate::wrappers::win32::style::WindowStyle; +use crate::dpi::{PhysicalPosition, PhysicalSize}; +use crate::wrappers::win32::style::WindowStyle; use crate::wrappers::win32::user32::ExtendedUser32; use crate::wrappers::win32::{Dpi, DpiAwarenessContext, Rect}; -use dpi::{PhysicalPosition, PhysicalSize}; use std::ffi::c_void; use std::num::NonZeroUsize; use std::ptr::{null_mut, NonNull}; From f0f4ac7cabb5f26787ea81203328ee31f62b47fc Mon Sep 17 00:00:00 2001 From: Adrien Prokopowicz <6529475+prokopyl@users.noreply.github.com> Date: Tue, 25 Aug 2026 08:29:50 +0200 Subject: [PATCH 3/4] fixes --- src/platform/win/window.rs | 2 +- src/wrappers/win32.rs | 2 +- src/wrappers/win32/window.rs | 2 +- src/wrappers/win32/window/handle.rs | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/platform/win/window.rs b/src/platform/win/window.rs index 4be2a621..d808362e 100644 --- a/src/platform/win/window.rs +++ b/src/platform/win/window.rs @@ -4,8 +4,8 @@ use windows_sys::Win32::{ UI::{Controls::WM_MOUSELEAVE, WindowsAndMessaging::*}, }; +use crate::dpi::{PhysicalPosition, PhysicalSize, Size}; use crate::{warn, EventStatus, HandlerError, WindowHandler}; -use crate::{PhysicalPosition, PhysicalSize, Size}; use std::cell::{Cell, OnceCell}; use std::num::NonZeroUsize; use windows_sys::Win32::Foundation::POINT; diff --git a/src/wrappers/win32.rs b/src/wrappers/win32.rs index c7e95686..4f2c5b01 100644 --- a/src/wrappers/win32.rs +++ b/src/wrappers/win32.rs @@ -8,7 +8,7 @@ mod user32; pub mod uuid; pub mod window; -pub use crate::dpi::*; +pub use dpi::*; pub use library::*; pub use rect::Rect; pub use style::*; diff --git a/src/wrappers/win32/window.rs b/src/wrappers/win32/window.rs index 8854d1f7..856af271 100644 --- a/src/wrappers/win32/window.rs +++ b/src/wrappers/win32/window.rs @@ -21,9 +21,9 @@ use std::rc::Rc; use window_class::RegisteredClass; use windows_core::{Error, Result, HSTRING}; +use crate::wrappers::win32::dpi::DpiAwarenessContext; use crate::wrappers::win32::h_instance::HInstance; use crate::wrappers::win32::style::WindowStyle; -use crate::wrappers::win32::DpiAwarenessContext; use windows_sys::Win32::Foundation::{LPARAM, LRESULT, WPARAM}; use windows_sys::Win32::UI::WindowsAndMessaging::CreateWindowExW; diff --git a/src/wrappers/win32/window/handle.rs b/src/wrappers/win32/window/handle.rs index 1727233a..4b56ce6c 100644 --- a/src/wrappers/win32/window/handle.rs +++ b/src/wrappers/win32/window/handle.rs @@ -1,7 +1,8 @@ use crate::dpi::{PhysicalPosition, PhysicalSize}; +use crate::wrappers::win32::dpi::{Dpi, DpiAwarenessContext}; use crate::wrappers::win32::style::WindowStyle; use crate::wrappers::win32::user32::ExtendedUser32; -use crate::wrappers::win32::{Dpi, DpiAwarenessContext, Rect}; +use crate::wrappers::win32::Rect; use std::ffi::c_void; use std::num::NonZeroUsize; use std::ptr::{null_mut, NonNull}; From ee34d26e73b490d4b8164f0d7272158d6cd812b6 Mon Sep 17 00:00:00 2001 From: Adrien Prokopowicz <6529475+prokopyl@users.noreply.github.com> Date: Tue, 25 Aug 2026 09:23:18 +0200 Subject: [PATCH 4/4] docs --- src/dpi.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/dpi.rs b/src/dpi.rs index c52d2e59..b9ce05d8 100644 --- a/src/dpi.rs +++ b/src/dpi.rs @@ -1,6 +1,9 @@ use crate::WindowSize; pub use dpi::*; +/// A size represented in the platform's native pixels. +/// +/// This size is represented in physical pixels on Windows and Linux, and in logical pixels on macOS. #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub struct NativeSize

{ pub width: P,