Quellcode durchsuchen

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.
Frank Praznik vor 7 Monaten
Ursprung
Commit
e4f987f299
1 geänderte Dateien mit 4 neuen und 1 gelöschten Zeilen
  1. 4 1
      test/testdropfile.c

+ 4 - 1
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);