tests: Fix tests when run with the --high-pixel-density flag

Scales pointer coordinates where needed to fix the following tests when run with the --high-pixel-density flag:

- testaudio
- testaudiostreamdynamicresample
- testhittesting
- testintersections
- testmanymouse
- testoverlay
- testwm
This commit is contained in:
Frank Praznik 2024-09-19 11:47:22 -04:00
parent 745d5e4991
commit fd0ce75e2e
7 changed files with 33 additions and 6 deletions

View file

@ -33,17 +33,25 @@ static SDL_HitTestResult SDLCALL
hitTest(SDL_Window *window, const SDL_Point *pt, void *data)
{
int i;
int w, h;
int w, h, p_w;
SDL_Point adj_pt;
float scale;
SDL_GetWindowSize(window, &w, &h);
SDL_GetWindowSizeInPixels(window, &p_w, NULL);
scale = (float)p_w / (float)w;
adj_pt.x = (int)SDL_floorf(pt->x * scale);
adj_pt.y = (int)SDL_floorf(pt->y * scale);
for (i = 0; i < numareas; i++) {
if (SDL_PointInRect(pt, &areas[i])) {
if (SDL_PointInRect(&adj_pt, &areas[i])) {
SDL_Log("HIT-TEST: DRAGGABLE\n");
return SDL_HITTEST_DRAGGABLE;
}
}
SDL_GetWindowSize(window, &w, &h);
#define REPORT_RESIZE_HIT(name) \
{ \
SDL_Log("HIT-TEST: RESIZE_" #name "\n"); \