#monitor_from_point always returns None

4 messages · Page 1 of 1 (latest)

icy tide
#
  • macos 15.6.1
  • tauri 2.9.3
fn calculate_main_window_position(
    main_window: &WebviewWindow,
    app_handle: &AppHandle,
) -> Result<PhysicalPosition<i32>, WindowManagerError> {
    let cursor_position = app_handle.cursor_position().map_err(|e| {
        log::error!("Error getting cursor position: {}", e);
        WindowManagerError::Other(e.to_string())
    })?;

    log::debug!("Available monitors: {:?}", app_handle.available_monitors());
    log::debug!("Acquired cursor position: {:?}", cursor_position);
    let mut monitor = app_handle
        .monitor_from_point(cursor_position.x, cursor_position.y)
        .map_err(|e| {
            log::error!("Error getting monitor from cursor position: {}", e);
            WindowManagerError::Other(e.to_string())
        })?;

    log::debug!("Acquired monitor: {:?}", monitor);
...

monitor_from_point returns None,

{ 
  name: Some("Monitor #10145"), 
  size: PhysicalSize { width: 3840, height: 2160 }, 
  position: PhysicalPosition { x: 0, y: 0 }, 
  work_area: PhysicalRect { 
    position: PhysicalPosition { x: 0, y: 0 }, 
    size: PhysicalSize { width: 3840, height: 2110 } 
  }, 
  scale_factor: 2.0 
}
{ 
  name: Some("Monitor #41039"), 
  size: PhysicalSize { width: 3024, height: 1964 }, 
  position: PhysicalPosition { x: 350, y: 2160 }, 
  work_area: PhysicalRect { 
    position: PhysicalPosition { x: 350, y: 2160 }, 
    size: PhysicalSize { width: 3024, height: 1888 } 
  }, 
  scale_factor: 2.0 
}
cursor_position: PhysicalPosition { x: 2125.921875, y: 2774.015625 }

I tried various positions on both monitors and verified that the coordinates match, but I still can’t figure out why it keeps returning None.

safe laurel
#

can you open an issue on github instead? our docs don't say that macos is unsupported and your code looks correct so this probably something on our side.

icy tide
#

should i close this discussion?