mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-02 18:07:40 +00:00
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:
parent
745d5e4991
commit
fd0ce75e2e
7 changed files with 33 additions and 6 deletions
|
@ -184,6 +184,20 @@ static const char *AudioChansToStr(const int channels)
|
|||
return "?";
|
||||
}
|
||||
|
||||
static void scale_mouse_coords(SDL_FPoint *p)
|
||||
{
|
||||
SDL_Window *window = SDL_GetMouseFocus();
|
||||
if (window) {
|
||||
int w, p_w;
|
||||
float scale;
|
||||
SDL_GetWindowSize(window, &w, NULL);
|
||||
SDL_GetWindowSizeInPixels(window, &p_w, NULL);
|
||||
scale = (float)p_w / (float)w;
|
||||
p->x *= scale;
|
||||
p->y *= scale;
|
||||
}
|
||||
}
|
||||
|
||||
static void loop(void)
|
||||
{
|
||||
int i, j;
|
||||
|
@ -228,6 +242,7 @@ static void loop(void)
|
|||
}
|
||||
|
||||
if (SDL_GetMouseState(&p.x, &p.y) & SDL_BUTTON_LMASK) {
|
||||
scale_mouse_coords(&p);
|
||||
if (active_slider == -1) {
|
||||
for (i = 0; i < NUM_SLIDERS; ++i) {
|
||||
if (SDL_PointInRectFloat(&p, &sliders[i].area)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue