Skip to content

SDL_GetGlobalMouseState and SDL_GetWindowPosition inconsistency still present on Emscripten #12770

@vittorioromeo

Description

@vittorioromeo

Follow up from #12667.

This still seems to be broken for me after merging both #12669 and #12575. The relative mouse position is reported incorrectly -- see this GIF:

https://i.imgur.com/sqBYbwe.mp4

This is my logic:

////////////////////////////////////////////////////////////
Vector2i getPosition()
{
    Vector2f result;
    SDL_GetGlobalMouseState(&result.x, &result.y);
    return result.toVector2i();
}


////////////////////////////////////////////////////////////
Vector2i getPosition(const WindowBase& relativeTo)
{
    return getPosition() - relativeTo.getPosition();
//                         ^~~~~~~~~~~~~~~~~~~~~~~~
//                       uses SDL_GetWindowPosition() internally 
}

@Temdog007: my guess here is that SDL_GetWindowPosition is not returning the correct position of the canvas relative to the parent web page shell, but I might be incorrect.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions