-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Describe the bug
Tauri Multi-Monitor Window Placement Issue
Description
In our application, we are attempting to create overlay windows on each available monitor in a multi-monitor setup using Tauri. Despite multiple approaches to position the windows on different monitors, all overlay windows continue to open on the same monitor (typically the primary monitor).
This issue aligns with the existing feature request #6394 for the ability to programmatically assign windows to specific monitors/displays. However, we would like to provide additional context and request assistance or updates on this functionality.
Environment
- Operating System: Linux (Fedora 41, Kernel 6.15.6)
- Tauri Version: 2 (as per Cargo.toml)
- Application: Algenius (a screenshot capture tool)
Problem Details
We are developing a screenshot capture tool that requires overlay windows to be displayed on each monitor for user interaction. The goal is to have one overlay window per monitor, positioned and sized according to each monitor's dimensions and location.
Steps Taken
We've tried several approaches to achieve multi-monitor window placement:
- Explicit Positioning: Setting the window position using monitor coordinates (
window.set_position(PhysicalPosition { x: monitor_pos.x, y: monitor_pos.y })
). - Offset Positioning: Applying a small offset for each window to encourage placement on different monitors.
- Delayed Showing: Spawning windows hidden, positioning them, and only showing them after a delay to ensure proper placement.
- Maximized Property: Using
.maximized(true)
to attempt full-screen overlays on each monitor. - Size Matching: Setting window size to match monitor dimensions (
.inner_size(monitor_size.width, monitor_size.height)
).
Despite these efforts, all overlay windows open on the same monitor. We've adjusted delays between window creation and showing (from 50ms to 500ms) to account for initialization timing, but this did not resolve the issue.
Current Code Snippet
#[tauri::command]
pub async fn take_screenshot(app: AppHandle, _screenshot_type: String) -> Result<String, String> {
// ... (monitor detection code) ...
// Create overlay on each monitor
for (i, monitor) in monitors_vec.iter().enumerate() {
let overlay_label = if i == 0 { base_overlay_label.to_string() } else { format!("{}_{}", base_overlay_label, i) };
let m_size = monitor.size();
let m_pos = monitor.position();
println!("Creating overlay on monitor {}: pos=({},{}), size=({},{})",
i, m_pos.x, m_pos.y, m_size.width, m_size.height);
println!("Monitor {} name: {:?}", i, monitor.name());
let window_builder = WebviewWindowBuilder::new(&app, &overlay_label, WebviewUrl::App("overlay.html".into()))
.title("Overlay")
.inner_size(m_size.width as f64, m_size.height as f64)
.resizable(false)
.decorations(false)
.transparent(true)
.always_on_top(true)
.skip_taskbar(true)
.visible(false); // Start hidden to avoid flicker
let window = window_builder.build()?;
window.set_position(tauri::PhysicalPosition { x: m_pos.x + (i as i32 * 100), y: m_pos.y })?;
// Show the window after positioning with a delay to ensure proper placement
tokio::time::sleep(Duration::from_millis(500)).await;
window.show()?;
}
Ok(format!("Overlays displayed on {} monitors", monitors_vec.len()))
}
Expected Behavior
- Each overlay window should appear on a different monitor in a multi-monitor setup.
- Windows should be positioned according to the coordinates and dimensions of each monitor as reported by
app.available_monitors()
.
Actual Behavior
- All overlay windows open on the same monitor (typically the primary monitor), regardless of the positioning attempts or monitor-specific coordinates used.
Request
We are seeking any workarounds, updates, or planned features in Tauri that would allow us to assign windows to specific monitors in a multi-monitor environment. This functionality is critical for applications like ours that require user interaction across multiple displays.
If there are temporary solutions or alternative approaches within the current Tauri framework, we would appreciate guidance on implementing them. Additionally, if this feature is planned for a future release, an estimated timeline would be helpful for our planning.
Additional Context
- Our application detects multiple monitors correctly (as evidenced by logs showing different positions and sizes for each monitor).
- The issue persists across different window properties (size, decorations, transparency, etc.) and timing adjustments.
Thank you for considering this issue. We are eager to collaborate or test any potential solutions to improve multi-monitor support in Tauri.
Reproduction
No response
Expected behavior
No response
Full tauri info
output
[✔] Environment
- OS: Fedora 41.0.0 x86_64 (X64) (gnome on wayland)
✔ webkit2gtk-4.1: 2.48.3
✔ rsvg2: 2.59.2
✔ rustc: 1.87.0 (17067e9ac 2025-05-09)
✔ cargo: 1.87.0 (99624be96 2025-05-06)
✔ rustup: 1.28.2 (e4f3ad6f8 2025-04-28)
✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
- node: 22.17.0
- pnpm: 9.15.1
- yarn: 1.22.22
- npm: 11.0.0
[-] Packages
- tauri 🦀: 2.5.1, (outdated, latest: 2.7.0)
- tauri-build 🦀: 2.2.0, (outdated, latest: 2.3.1)
- wry 🦀: 0.51.2, (outdated, latest: 0.53.1)
- tao 🦀: 0.33.0, (outdated, latest: 0.34.0)
- @tauri-apps/api : 2.5.0 (outdated, latest: 2.7.0)
- @tauri-apps/cli : 2.5.0 (outdated, latest: 2.7.1)
[-] Plugins
- tauri-plugin-fs 🦀: 2.3.0, (outdated, latest: 2.4.1)
- @tauri-apps/plugin-fs : 2.3.0 (outdated, latest: 2.4.1)
- tauri-plugin-clipboard-manager 🦀: 2.2.2, (outdated, latest: 2.3.0)
- @tauri-apps/plugin-clipboard-manager : 2.2.2 (outdated, latest: 2.3.0)
- tauri-plugin-dialog 🦀: 2.2.2, (outdated, latest: 2.3.2)
- @tauri-apps/plugin-dialog : 2.2.2 (outdated, latest: 2.3.2)
- tauri-plugin-window-state 🦀: 2.2.2, (outdated, latest: 2.4.0)
- @tauri-apps/plugin-window-state : 2.2.2 (outdated, latest: 2.4.0)
- tauri-plugin-opener 🦀: 2.2.7, (outdated, latest: 2.4.0)
- @tauri-apps/plugin-opener : 2.2.7 (outdated, latest: 2.4.0)
- tauri-plugin-shell 🦀: 2.2.1, (outdated, latest: 2.3.0)
- @tauri-apps/plugin-shell : 2.2.1 (outdated, latest: 2.3.0)
[-] App
- build-type: bundle
- CSP: unset
- frontendDist: ../dist
- devUrl: http://localhost:1420/
- framework: React (Next.js)
- bundler: Vite
Stack trace
Additional context
No response