-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
Describe the bug
I'm trying to implement a workaround for the known Tauri drag & drop limitation (where a window can't accept both plain text and file drops simultaneously — related: #14055).
My approach works well on Windows: when detecting a file drop, I dynamically create a new WebviewWindow with dragDropEnabled: true and overlay the window on the current window position.
However, I cannot get the correct values of the current (main) window to set new window's position properly on macOS.
What happend:
-
Web APIs (
window.screenLeft/window.screenTop):- On macOS: Always return fixed values (in my case, screenLeft = 0, screenTop = 1440), regardless of where the main window is moved (even across multiple monitors).
- On Windows: These values update correctly when moving the window.
-
Tauri API (
getCurrentWebviewWindow().position()):- Returns
{ x: 0, y: 0 }on both Windows and macOS, no matter how I move the window around.
- Returns
-
Linux ?: I don't have a Linux environment to test it right now. :(
Screenshots:
Reproduction
Minimal example (Vue+TS):
In App.vue:
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
import { onMounted } from "vue";
onMounted(async () => {
setInterval(async () => {
console.log("Timestamp:", new Date().toLocaleTimeString());
// Web APIs
console.log("WebAPI screenLeft:", window.screenLeft);
console.log("WebAPI screenTop:", window.screenTop);
// Tauri API
const position = await getCurrentWebviewWindow().position();
console.log("Tauri API position:", position); // always { x: 0, y: 0 }
}, 1000);
});Expected behavior
Both APIs should reflect the actual physical position of the Tauri window on screen.
Full tauri info output
- macOS
[✘] Environment
- OS: Mac OS 15.3.1 arm64 (X64)
✔ Xcode Command Line Tools: installed
✘ Xcode: not installed! (Idk why it doesn't detected)
✔ rustc: 1.86.0 (05f9846f8 2025-03-31)
✔ cargo: 1.86.0 (adf9b6ad1 2025-02-28)
✔ rustup: 1.28.1 (f9edccde0 2025-03-05)
✔ Rust toolchain: stable-aarch64-apple-darwin (default)
- node: 22.15.0
- pnpm: 8.3.1
- npm: 10.9.2
- bun: 1.1.21
[-] Packages
- tauri 🦀: 2.9.5
- tauri-build 🦀: 2.5.3
- wry 🦀: 0.53.5
- tao 🦀: 0.34.5
- @tauri-apps/api ⱼₛ: 2.9.1
- @tauri-apps/cli ⱼₛ: 2.9.1 (outdated, latest: 2.9.6)
[-] Plugins
- tauri-plugin-window-state 🦀: 2.4.1
- @tauri-apps/plugin-window-state ⱼₛ: 2.4.1
- tauri-plugin-fs 🦀: 2.4.4
- @tauri-apps/plugin-fs ⱼₛ: not installed!
- tauri-plugin-dialog 🦀: 2.4.2
- @tauri-apps/plugin-dialog ⱼₛ: 2.4.2
- tauri-plugin-shell 🦀: 2.3.3
- @tauri-apps/plugin-shell ⱼₛ: 2.3.3
[-] App
- build-type: bundle
- CSP: connect-src ipc: http://ipc.localhost http://tauri.localhost tauri://localhost; script-src script-src 'self'; style-src 'unsafe-inline' 'self'; img-src 'self' asset: * blob: data:; default-src 'self' customprotocol: asset:
- frontendDist: ../dist
- devUrl: http://localhost:1420/
- framework: Vue.js
- bundler: Vite
- Windows
[✔] Environment
- OS: Windows 10.0.26200 x86_64 (X64)
✔ WebView2: 143.0.3650.80
✔ MSVC: Visual Studio Professional 2022
✔ rustc: 1.86.0 (05f9846f8 2025-03-31)
✔ cargo: 1.86.0 (adf9b6ad1 2025-02-28)
✔ rustup: 1.28.1 (f9edccde0 2025-03-05)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
- node: 20.17.0
- pnpm: 10.25.0
- yarn: 1.22.17
- npm: 11.7.0
[-] Packages
- tauri 🦀: 2.9.5
- tauri-build 🦀: 2.5.3
- wry 🦀: 0.53.5
- tao 🦀: 0.34.5
- cargo-tauri 🦀: 1.0.5
- @tauri-apps/api ⱼₛ: 2.9.1
- @tauri-apps/cli ⱼₛ: 2.9.6
[-] Plugins
- tauri-plugin-window-state 🦀: 2.4.1
- @tauri-apps/plugin-window-state ⱼₛ: 2.4.1
- tauri-plugin-shell 🦀: 2.3.3
- @tauri-apps/plugin-shell ⱼₛ: 2.3.3
- tauri-plugin-fs 🦀: 2.4.4
- @tauri-apps/plugin-fs ⱼₛ: not installed!
- tauri-plugin-dialog 🦀: 2.4.2
- @tauri-apps/plugin-dialog ⱼₛ: 2.4.2
[-] App
- build-type: bundle
- CSP: img-src 'self' asset: * blob: data:; default-src 'self' customprotocol: asset:; style-src 'unsafe-inline' 'self'; script-src script-src 'self'; connect-src ipc: http://ipc.localhost http://tauri.localhost tauri://localhost
- frontendDist: ../dist
- devUrl: http://localhost:1420/
- framework: Vue.js
- bundler: Vite
Stack trace
Additional context
When dragDropEnabled set to false,
The dragenter event from WebAPI seems also broke on macOS, the dataTransfer won't return any types, count of file or getData("text/plain") won't got any result, these info only obtainable when drop event triggered.
But dragenter event on Windows can get these info without issue.