Skip to content

Commit 224ee36

Browse files
committed
clippy
1 parent 48645d5 commit 224ee36

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

  • crates/scap-targets/src/platform

crates/scap-targets/src/platform/win.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)