We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2078

Summary: SDL_GetWindowPosition() always returns (0, 0) in fullscreen
Product: SDL Reporter: Daniel Gibson <metalcaedes>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: amaranth72, metalcaedes, sdlbug
Version: HG 2.0   
Hardware: x86_64   
OS: All   

Description Daniel Gibson 2013-08-31 23:35:42 UTC
When I have a window on my second (right) screen, the position I get from SDL_GetWindowPosition() is something like (2151, 276), as I would expect - my first (left) screen has a resolution of 1920x1200, so the screen right of it should start with x=1920.

SDL_GetWindowPosition however always returns (0,0) as Window position, which is also quite obvious from the implementation:
"if (window->flags & SDL_WINDOW_FULLSCREEN)" it just sets x and y to 0, because
"/* Fullscreen windows are always at their display's origin */"

This is of course inconsistent: In windowed mode the function returns a global (across all displays) coordinate, but in fullscreen mode the coordinate on the display it's on.. I guess this is a SDL1.2 leftover?

SDL_Window.x and .y contained the expected values (1920, 0), by the way, so at least on my platform (Linux/X11/xrandr) always returning those would be correct.

By the way, SDL_GetWindowBounds(SDL_Window*, SDL_Rect*) that works analogous to SDL_GetDisplayBounds() would be nice :)
Comment 1 Daniel Gibson 2013-08-31 23:38:34 UTC
(In reply to Daniel Gibson from comment #0)
> SDL_GetWindowPosition however always returns (0,0) as Window position, which
> is also quite obvious from the implementation:

This should have been "In fullscreen mode SDL_GetWindowPosition() however always returns (0,0) as Window position, ..."
Comment 2 Alex Szpakowski 2015-09-13 04:09:50 UTC
This should be fixed with this commit: https://hg.libsdl.org/SDL/rev/cfeb59daba69