SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Add mouse hint to README-highdpi.md

Open expikr opened this issue 1 year ago • 10 comments

Closes #10074

expikr avatar Jun 22 '24 02:06 expikr

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.

slouken avatar Jun 22 '24 03:06 slouken

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.

expikr avatar Jun 22 '24 03:06 expikr

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

slouken avatar Jun 22 '24 05:06 slouken

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

expikr avatar Jun 22 '24 10:06 expikr

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()

expikr avatar Jun 23 '24 12:06 expikr

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 avatar Jun 23 '24 17:06 slouken

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

slouken avatar Jun 23 '24 17:06 slouken

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

expikr avatar Jun 24 '24 13:06 expikr

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.

expikr avatar Jun 29 '24 16:06 expikr

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

slouken avatar Jun 29 '24 17:06 slouken

Merged, thanks!

slouken avatar Oct 11 '24 20:10 slouken