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

Add mouse hint to README-highdpi.md #10083

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

expikr
Copy link
Contributor

@expikr expikr commented Jun 22, 2024

Closes #10074

@slouken
Copy link
Collaborator

slouken commented Jun 22, 2024

This hint isn't actually relevant for display scaling handling.

There's a FIXME in WIN_SetEnhancedMouseScale() wondering if we need do anything for displays with different DPI and/or display scale.

@expikr
Copy link
Contributor Author

expikr commented Jun 22, 2024

What unit is SDL's internal mouse position in, Pixel or points?

This needs to be clarified because either SDL's mouse scaling is not faithful due to not matching the OS's DPI scaling, or the motion matches OS but the reported units are mismatched due to DPI scaling.

@slouken
Copy link
Collaborator

slouken commented Jun 22, 2024

They're in window coordinates, which are pixels on Windows and Linux, and points on macOS.

@expikr
Copy link
Contributor Author

expikr commented Jun 22, 2024

I think that's a point worth clarifying in this specific README.. I'll think about how to reword it.

@expikr
Copy link
Contributor Author

expikr commented Jun 23, 2024

Is my understanding in the following table correct?

  • 3840x2160 physical monitor resolution
  • 200% Windows display scale or 2x MacOS display
  • Fullscreen window
Value Default High Density
Mouse coodinate space 3840x2160 3840x2160
Args to SDL_CreateWindow() 3840x2160 1920x1080
SDL_GetWindowSize() 3840x2160 1920x1080
SDL_GetWindowSizeInPixels() 3840x2160 3840x2160
SDL_GetWindowPixelDensity() 1.0 2.0
SDL_GetWindowDisplayScale() 1.0 2.0
SDL_GetDisplayContentScale() 2.0 2.0
SDL_GetWindowDisplayScale() == SDL_GetWindowPixelDensity()
SDL_GetWindowPixelDensity() == SDL_GetWindowSizeInPixels() / SDL_GetWindowSize()

@slouken
Copy link
Collaborator

slouken commented Jun 23, 2024

Is my understanding in the following table correct?

  • 3840x2160 physical monitor resolution
  • 200% Windows display scale or 2x MacOS display
  • Fullscreen window

These are going to vary between macOS and Windows, because they treat high DPI differently. macOS uses virtualized points for the window coordinates and Windows uses pixels.

Here's an updated table for Windows, which doesn't distinguish between default and high density (using SDL's default behavior)

Value
Mouse coordinate space 3840x2160
Args to SDL_CreateWindow() 3840x2160
SDL_GetWindowSize() 3840x2160
SDL_GetWindowSizeInPixels() 3840x2160
SDL_GetWindowPixelDensity() 1.0
SDL_GetWindowDisplayScale() 2.0
SDL_GetDisplayContentScale() 2.0

Here's an updated table for macOS, where the High Density entries are for windows on a 2x display and created with the SDL_WINDOW_HIGH_PIXEL_DENSITY flag.

Value Default High Density
Mouse coordinate space 1920x1080 1920x1080
Args to SDL_CreateWindow() 1920x1080 1920x1080
SDL_GetWindowSize() 1920x1080 1920x1080
SDL_GetWindowSizeInPixels() 1920x1080 3840x2160
SDL_GetWindowPixelDensity() 1.0 2.0
SDL_GetWindowDisplayScale() 1.0 2.0
SDL_GetDisplayContentScale() 1.0 1.0

Here is a correction as well:

SDL_GetWindowPixelDensity() == SDL_GetWindowSizeInPixels() / SDL_GetWindowSize()
SDL_GetWindowDisplayScale() == SDL_GetWindowPixelDensity() * SDL_GetDisplayContentScale()

@slouken
Copy link
Collaborator

slouken commented Jun 23, 2024

By the way, I appreciate your willingness to learn how this all works.

@expikr
Copy link
Contributor Author

expikr commented Jun 24, 2024

Thanks, really appreciate your patience bearing with me. I’ll incorporate the examples as well as think about how to phrase them unambiguously.

@expikr
Copy link
Contributor Author

expikr commented Jun 29, 2024

I tried to interpret the interfaces in terms of advisory factors with respect to memory pixels or native units, please let me know if there are any misunderstandings in what I wrote.

@slouken
Copy link
Collaborator

slouken commented Jun 29, 2024

I have some questions and clarification here. I'll come back to this when I have more time.

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.

Documentation: clarify how hidpi affects mouse scaling
2 participants