Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] outer_position and set_outer_position may work unexpectedly with multiple monitors in different DPI #816

Open
2 tasks
pewsheen opened this issue Oct 17, 2023 · 0 comments

Comments

@pewsheen
Copy link
Contributor

Describe the bug

  • When calling outer_position, tao will get the window's coordination (LogicalPosition) and then multiply it by the monitor's scale_factor which the window currently displays to a PhysicalPosition.
  • When we call set_outer_position, the scale_factor is also obtained from the monitor that the window currently displays.
  • If we call outer_position from a monitor and set_outer_position from another monitor, the PhysicalPostiion and LogicalPosition conversions may use different scale_factor, and the LogicalPosition 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 got PhysicalPosition(160, 40)
  • User call set_outer_position(PhysicalPosition(160, 40)) when the window is in M1, tao converts it to LogicalPosition(80, 20).
  • User call set_outer_position(PhysicalPosition(160, 40)) when the window is in M2, tao converts it to LogicalPosition(160, 40), since M2's scale_factor is 1.0. The window will be moved to M2 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:

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

No branches or pull requests

1 participant