tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.52k stars 2.58k forks source link

[bug] toLogical/toPhysical (JS API) for positions broken since 2.1.0 #11638

Closed dgerhardt closed 2 weeks ago

dgerhardt commented 2 weeks ago

Describe the bug

After updating from Tauri 2.0.6 to 2.1.0, toLogical no longer produces a correct LogicalPosition object when using the JS API. y now always has the same value as x. The same happens when converting PhysicalPosition to LogicalPosition using toPhysical. For toLogical, this is a regression.

Reproduction

  const posTest1 = new PhysicalPosition(10, 25);
  const posTest2 = posTest1.toLogical(1);
  console.log('phyical -> logical', posTest1, posTest2);

  const posTest3 = new LogicalPosition(10, 25);
  const posTest4 = posTest3.toPhysical(1);
  console.log('logical -> phyical', posTest3, posTest4);

Result:

Expected behavior

toLogical/toPhysical should produce a LogicalPosition/PhysicalPosition object with a correct y value.

Full tauri info output

[✔] Environment
    - OS: Ubuntu 24.4.0 x86_64 (X64)
    ✔ webkit2gtk-4.1: 2.44.0
    ✔ rsvg2: 2.58.0
    ✔ rustc: 1.77.2 (25ef9e3d8 2024-04-09)
    ✔ cargo: 1.77.2 (e52e36006 2024-03-26)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
    - node: 20.18.0
    - yarn: 1.22.19
    - npm: 10.8.2

[-] Packages
    - tauri 🦀: 2.1.0
    - tauri-build 🦀: 2.0.3
    - wry 🦀: 0.47.0
    - tao 🦀: 0.30.6
    - @tauri-apps/api : 2.1.0
    - @tauri-apps/cli : 2.1.0

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - bundler: Vite

Stack trace

No response

Additional context

https://github.com/tauri-apps/tauri/blob/5c4b830843ab085f8ff9db9e08d832223b027e4e/packages/api/src/dpi.ts#L312