tao
tao copied to clipboard
[macOS] `outer_position` and `set_outer_position` may work unexpectedly with multiple monitors in different DPI
Describe the bug
- When calling
outer_position
, tao will get the window's coordination (LogicalPosition
) and then multiply it by the monitor'sscale_factor
which the window currently displays to aPhysicalPosition
. - When we call
set_outer_position
, thescale_factor
is also obtained from the monitor that the window currently displays. - If we call
outer_position
from a monitor andset_outer_position
from another monitor, thePhysicalPostiion
andLogicalPosition
conversions may use differentscale_factor
, and theLogicalPosition
obtained from and given to macOS may be different after conversion.
Let's have an example:
We have 2 monitors:
- M1: 2x, 100x100 (in logical)
- M2: 1x, 100x100 (in logical)
and a window sit in M1 with LogicalPosition(80, 20)
(0 ,0) (100, 0) (200, 0)
┌──────────────────┬──────────────────┐
│ (80, 20)│ │
│ ┌───┐ │ │
│ │ │ │ │
│ │win│ │ │
│ └───┘ │ │
│ │ │
│ │ │
│ │ │
│M1(2x) │M2(1x) │
└──────────────────┴──────────────────┘
- User call
outer_position
, they gotPhysicalPosition(160, 40)
- User call
set_outer_position(PhysicalPosition(160, 40))
when the window is inM1
, tao converts it toLogicalPosition(80, 20)
. - User call
set_outer_position(PhysicalPosition(160, 40))
when the window is inM2
, tao converts it toLogicalPosition(160, 40)
, sinceM2
'sscale_factor
is 1.0. The window will be moved toM2
because the coordination sits within M2's bounds.
Steps To Reproduce Refer to the example above.
Expected behavior To set the window position as expected.
Platform and Versions (please complete the following information): OS: macOS 14.0
Would you want to assign yourself to resolve this bug?
- [ ] Yes
- [ ] No
Additional context
Related issue:
- https://github.com/tauri-apps/tauri/issues/7890
- https://github.com/tauri-apps/tauri/issues/7139
- https://github.com/rust-windowing/winit/issues/2645