File tree Expand file tree Collapse file tree
crates/scap-targets/src/platform Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1055,6 +1055,30 @@ impl WindowImpl {
10551055 }
10561056 }
10571057
1058+ pub fn logical_bounds ( & self ) -> Option < LogicalBounds > {
1059+ let physical_bounds = self . physical_bounds ( ) ?;
1060+
1061+ const BASE_DPI : f64 = 96.0 ;
1062+ let dpi = unsafe {
1063+ match GetDpiForWindow ( self . 0 ) {
1064+ 0 => BASE_DPI as u32 ,
1065+ dpi => dpi,
1066+ }
1067+ } as f64 ;
1068+ let scale_factor = dpi / BASE_DPI ;
1069+
1070+ Some ( LogicalBounds :: new (
1071+ LogicalPosition :: new (
1072+ physical_bounds. position ( ) . x ( ) / scale_factor,
1073+ physical_bounds. position ( ) . y ( ) / scale_factor,
1074+ ) ,
1075+ LogicalSize :: new (
1076+ physical_bounds. size ( ) . width ( ) / scale_factor,
1077+ physical_bounds. size ( ) . height ( ) / scale_factor,
1078+ ) ,
1079+ ) )
1080+ }
1081+
10581082 pub fn physical_size ( & self ) -> Option < PhysicalSize > {
10591083 Some ( self . physical_bounds ( ) ?. size ( ) )
10601084 }
You can’t perform that action at this time.
0 commit comments