Use the term "points" instead of "screen coordinates"

It turns out that screen coordinates were confusing people, thinking that meant pixels, when instead they are virtual coordinates; device independent units defined as pixels scaled by the display scale. We'll use the term "points" for this going forward, to reduce confusion.
This commit is contained in:
Sam Lantinga
2023-05-15 11:16:46 -07:00
parent 78251f973d
commit 4de7433a9e
7 changed files with 31 additions and 37 deletions

View File

@@ -599,7 +599,7 @@ static void display_handle_done(void *data,
driverdata->screen_height /= (int)driverdata->scale_factor;
}
} else {
/* Calculate the screen coordinates from the pixel values, if xdg-output isn't present.
/* Calculate the points from the pixel values, if xdg-output isn't present.
* Use the native mode pixel values since they are pre-transformed.
*/
driverdata->screen_width = native_mode.pixel_w / (int)driverdata->scale_factor;

View File

@@ -597,7 +597,7 @@ void WIN_ScreenPointFromSDLFloat(float x, float y, LONG *xOut, LONG *yOut, int *
goto passthrough;
}
/* Can't use MonitorFromPoint for this because we currently have SDL coordinates, not pixels */
/* Can't use MonitorFromPoint for this because we currently have SDL points, not pixels */
displayID = SDL_GetDisplayForPoint(&point);
if (displayID == 0) {
goto passthrough;

View File

@@ -139,7 +139,7 @@ static int WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL m
UINT frame_dpi;
#endif
/* Client rect, in SDL screen coordinates */
/* Client rect, in points */
SDL_RelativeToGlobalForWindow(window,
(use_current ? window->x : window->windowed.x),
(use_current ? window->y : window->windowed.y),
@@ -147,7 +147,7 @@ static int WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL m
*width = (use_current ? window->w : window->windowed.w);
*height = (use_current ? window->h : window->windowed.h);
/* Convert client rect from SDL coordinates to pixels (no-op if DPI scaling not enabled) */
/* Convert client rect from points to pixels (no-op if DPI scaling not enabled) */
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
WIN_ScreenPointFromSDL(x, y, &dpi);
#endif

View File

@@ -379,10 +379,8 @@ void WINRT_ProcessMouseMovedEvent(SDL_Window *window, Windows::Devices::Input::M
//
// There may be some room for a workaround whereby OnPointerMoved's values
// are compared to the values from OnMouseMoved in order to detect
// when this bug is active. A suitable transformation could then be made to
// OnMouseMoved's values. For now, however, the system-reported values are sent
// to SDL with minimal transformation: from native screen coordinates (in DIPs)
// to SDL window coordinates.
// when this bug is active. A suitable transformation could then be made to
// OnMouseMoved's values.
//
const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs, TransformToSDLWindowSize);