Skip to content

Conversation

@Slinetrac
Copy link
Collaborator

描述:
本 PR 修复了多显示器环境下,窗口在不同缩放因子显示器间移动时大小异常的问题。

核心改动

  • 新增 window_manager.rs 模块处理窗口管理。

  • 引入 MonitorInfo 结构体,用于 IPC 通信。

  • 移动窗口时,正确计算源显示器与目标显示器的缩放比例:

let scale_ratio = current_scale_factor / target_scale_factor;
let target_width = (window_size.width as f64 * scale_ratio).round() as u32;
let target_height = (window_size.height as f64 * scale_ratio).round() as u32;
  • 跨平台支持,增强类型安全性。

  • ipc.rs 添加新命令,并在 lib.rs 注册。

使用示例(前端 Tauri IPC 调用):

await invoke('move_window_to_other_monitor', { window, targetMonitorIndex: 1 });
await invoke('center_window', { window });
const monitors = await invoke('get_available_monitors', { window });

效果
确保多显示器环境下,窗口能正确移动和显示,即使显示器缩放设置不同。

@Slinetrac
Copy link
Collaborator Author

#2206 #2343

@Slinetrac Slinetrac merged commit 400d5b9 into libnyanpasu:main Sep 21, 2025
0 of 3 checks passed
@Slinetrac Slinetrac deleted the fix/multi-monitor-scaling branch September 21, 2025 13:50
Slinetrac added a commit that referenced this pull request Oct 8, 2025
@Slinetrac
Copy link
Collaborator Author

revert 了,tauri-apps/tao#1056 已经解决此问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant