From e4f987f299683a1016dd441c860c6aa4bd03bfa1 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Wed, 18 Sep 2024 11:00:19 -0400
Subject: [PATCH] tests: Fix testdropfile on high-DPI displays
Convert the window pointer coordinates to buffer coordinates for rendering, so that the cross-hairs align with the cursor on scaled desktops.
---
test/testdropfile.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/test/testdropfile.c b/test/testdropfile.c
index c25be58e00ca0..d0d611984bdb3 100644
--- a/test/testdropfile.c
+++ b/test/testdropfile.c
@@ -79,11 +79,14 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
const char *typestr = (event->type == SDL_EVENT_DROP_FILE) ? "File" : "Text";
SDL_Log("%s dropped on window %u: %s at (%f, %f)", typestr, (unsigned int)event->drop.windowID, event->drop.data, event->drop.x, event->drop.y);
} else if (event->type == SDL_EVENT_DROP_POSITION) {
+ const float w_x = event->drop.x;
+ const float w_y = event->drop.y;
+ SDL_ConvertEventToRenderCoordinates(SDL_GetRenderer(SDL_GetWindowFromEvent(event)), event);
dialog->is_hover = SDL_TRUE;
dialog->x = event->drop.x;
dialog->y = event->drop.y;
dialog->windowID = event->drop.windowID;
- SDL_Log("Drop position on window %u at (%f, %f) data = %s", (unsigned int)event->drop.windowID, event->drop.x, event->drop.y, event->drop.data);
+ SDL_Log("Drop position on window %u at (%f, %f) data = %s", (unsigned int)event->drop.windowID, w_x, w_y, event->drop.data);
}
return SDLTest_CommonEventMainCallbacks(dialog->state, event);