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

This commit is contained in:
Slava Minamoto
2026-06-11 21:05:20 +08:00
committed by GitHub
parent c2b3981248
commit 4be7690085
2 changed files with 9 additions and 1 deletions
+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();