testwm2: Fix video modes menu hit detection when highdpi or logical size used (#4936)

* SDLTest_CommonDrawWindowInfo: log SDL_RenderGetScale, SDL_RenderGetLogicalSize

* testwm2: fix video modes menu hit detection in High DPI cases

- also when logical size is specified, e.g.
  `--logical 640x480 --resizable --allow-highdpi`

* add function to determine logical coordinates of renderer point when given window point

* change since to the targeted milestone

* fix typo

* rename for consistency

* Change logical coordinate type to float, since we can render with floating point precision.

* add function to convert logical to window coordinates

* testwm2: use new SDL_RenderWindowToLogical

* SDL_render.c: alternate SDL_RenderWindowToLogical/SDL_RenderLogicalToWindow

Co-authored-by: John Blat <johnblat64@protonmail.com>
Co-authored-by: John Blat <47202511+johnblat64@users.noreply.github.com>
This commit is contained in:
Eric Wasylishen 2021-11-09 22:03:42 -07:00 committed by GitHub
parent 27ce914463
commit 0d98793693
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 103 additions and 2 deletions

View file

@ -2234,6 +2234,7 @@ SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window, int *
SDL_Rect rect;
SDL_DisplayMode mode;
float ddpi, hdpi, vdpi;
float scaleX, scaleY;
Uint32 flags;
const int windowDisplayIndex = SDL_GetWindowDisplayIndex(window);
SDL_RendererInfo info;
@ -2276,6 +2277,17 @@ SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window, int *
SDLTest_DrawString(renderer, 0, textY, text);
textY += lineHeight;
SDL_RenderGetScale(renderer, &scaleX, &scaleY);
SDL_snprintf(text, sizeof(text), "SDL_RenderGetScale: %f,%f",
scaleX, scaleY);
SDLTest_DrawString(renderer, 0, textY, text);
textY += lineHeight;
SDL_RenderGetLogicalSize(renderer, &w, &h);
SDL_snprintf(text, sizeof(text), "SDL_RenderGetLogicalSize: %dx%d", w, h);
SDLTest_DrawString(renderer, 0, textY, text);
textY += lineHeight;
/* Window */
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);