fix(positioner): return error instead of panicking when window has no monitor (#3449)

This commit is contained in:
Slava Minamoto
2026-06-11 22:05:20 +09:00
committed by GitHub
parent c2b3981248
commit 4be7690085
2 changed files with 9 additions and 1 deletions
@@ -0,0 +1,6 @@
---
positioner: patch
positioner-js: patch
---
Replaced a panic in `calculate_position` with an error return when the window has no associated monitor (e.g. during display sleep or monitor reconfiguration).
+3 -1
View File
@@ -152,7 +152,9 @@ fn calculate_position<R: Runtime>(
) -> Result<PhysicalPosition<i32>> {
use Position::*;
let screen = window.current_monitor()?.unwrap();
let screen = window.current_monitor()?.ok_or_else(|| {
tauri::Error::Io(std::io::Error::other("No monitor found for the window"))
})?;
// Only use the screen_position for the Tray independent positioning,
// because a tray event may not be called on the currently active monitor.
let screen_position = screen.position();