Skip to content

[bug] Inconsistent behavior of Monitor::from_point across platforms #12676

Open
tauri-apps/tao
#1057
@dgerhardt

Description

@dgerhardt

Describe the bug

Monitor::from_point treats x and y values as physical on Windows while on macOS the values are treated as logical. Currently, the method cannot be reliably be used across platforms without checking for the platform and converting the values conditionally. The documentation does not specify if the values passed should be physical or logical, so it is unclear which of both behaviors is the correct one.

Reproduction

const monitor = await primaryMonitor();
if (!monitor) {
  console.error('No monitor found.');
  return;
}
if (monitor.scaleFactor <= 1) {
  console.error('Scaling is not enabled for primary monitor.');
  return;
}
console.info('Monitor 1: ' + JSON.stringify(monitor));
const x = monitor.size.width - 1;
const y = monitor.size.height - 1;
console.info(`Monitor 2 <- monitorFromPoint(${x}, ${y})`);
const monitor2 = await monitorFromPoint(x, y);
console.info('Monitor 2: ' + JSON.stringify(monitor2));
if (monitor.name !== monitor2?.name) {
  console.error('Expected point to be on primary monitor.');
} else {
  console.info('The point is on the primary monitor as expected.');
}

Expected behavior

Monitor::from_point should treat passed x and y values the same way across platforms.

Full tauri info output

[✔] Environment
    - OS: Mac OS 15.3.0 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.84.0 (9fc6b4312 2025-01-07)
    ✔ cargo: 1.84.0 (66221abde 2024-11-19)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 23.6.1
    - yarn: 4.6.0
    - npm: 10.9.2

[-] Packages
    - tauri 🦀: 2.2.5
    - tauri-build 🦀: 2.0.5
    - wry 🦀: 0.48.1
    - tao 🦀: 0.31.1
    - @tauri-apps/api : 2.2.0
    - @tauri-apps/cli : 2.2.7

[-] Plugins
    - tauri-plugin-cli 🦀: 2.2.0
    - @tauri-apps/plugin-cli : 2.2.0
    - tauri-plugin-single-instance 🦀: 2.2.1
    - @tauri-apps/plugin-single-instance : not installed!
    - tauri-plugin-store 🦀: 2.2.0
    - @tauri-apps/plugin-store : 2.2.0
    - tauri-plugin-process 🦀: 2.2.0
    - @tauri-apps/plugin-process : 2.2.0
    - tauri-plugin-log 🦀: 2.2.1
    - @tauri-apps/plugin-log : 2.2.1
    - tauri-plugin-shell 🦀: 2.2.0
    - @tauri-apps/plugin-shell : 2.2.0
    - tauri-plugin-updater 🦀: 2.5.0
    - @tauri-apps/plugin-updater : 2.5.0
    - tauri-plugin-deep-link 🦀: 2.2.0
    - @tauri-apps/plugin-deep-link : 2.2.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist/app/browser
    - devUrl: http://localhost:1420/
    - framework: Angular
    - bundler: Webpack

Stack trace


Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions