mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-06-12 14:17:48 +02:00
fix(positioner): return error instead of panicking when window has no monitor (#3449)
This commit is contained in:
@@ -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).
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user