T48: round 3 fix: a keep moves her only while its DPI is still hers, so it changes no DPI and posts no other, where a keep whose DPI had passed while two places piled up set her DPI back and forth
CI / platforms (windows-latest) (push) Successful in 1m59s
CI / platforms (ubuntu-24.04) (push) Successful in 2m44s
CI / macos (push) Successful in 14m3s

This commit is contained in:
ZacharyZhang-NY committed 2026-10-18 13:24:49 -04:00
1 parent f7e5563a71
commit 47826ee262
4 files changed
+111 -53

No files matched your search

+11 -3
View File
@@ -153,12 +153,16 @@ unsafe extern "system" fn inactive(
answer
}
KEEP => {
let dpi = wparam as u32;
let (dpi, current) = (wparam as u32, unsafe { GetDpiForWindow(window) });
if current == 0 {
log::error!("pet: her window's DPI does not read at a new DPI");
return 0;
}
let Some(corner) = CORNER.get() else {
log::debug!("pet: at {dpi} DPI Ely has no place to keep yet");
return 0;
};
match keeping(corner, dpi, display_dpi) {
match keeping(corner, dpi, current, display_dpi) {
Ok(Some(kept)) => {
move_to(window, kept);
log::debug!("pet: at {dpi} DPI Ely keeps her corner at {corner:?}");
@@ -188,12 +192,16 @@ fn move_to(window: HWND, rect: RECT) {
}
}
/// Her box at `dpi` on the bottom left `corner` her place gave her, if it lies mostly on a display of that DPI, as `dpi_of` reads it; else none, and Windows' rect stands, which sets off no other change.
/// Her box at `dpi` on the bottom left `corner` her place gave her, while `dpi` is still hers, `current`, and the box lies mostly on a display of that DPI, as `dpi_of` reads it, so the move changes no DPI and posts no other keep; else none, and Windows' rect stands.
fn keeping(
(left, bottom): (i32, i32),
dpi: u32,
current: u32,
dpi_of: impl Fn(&RECT) -> anyhow::Result<u32>,
) -> anyhow::Result<Option<RECT>> {
if dpi != current {
return Ok(None);
}
let (width, height) = sized(dpi as f32 / USER_DEFAULT_SCREEN_DPI as f32);
let kept = RECT {
left,