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 3272

Summary: GetWindowPosition returns wrong position after resize
Product: SDL Reporter: cra0zy <cra0zy>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: icculus, jwyatt
Version: 2.0.4   
Hardware: x86_64   
OS: Linux   
Attachments: Translate to root window coordinates patch.
Translate to root window coordinates patch 2

Description cra0zy@gmail.com 2016-02-26 16:46:30 UTC
Steps to reproduce:
1) Create SDL window which is resizable
2) Setup some code just to get window position
3) Run the app, change window size, but do not move the window
4) Try and get window position

For me it always returned (10, 8) as the window position.

After moving the window, GetWindowPosition starts returning the correct window position.
Comment 1 Jason Wyatt 2016-03-09 11:29:57 UTC
This also happens for fullscreen windows. I think the issue is that GNOME inserts a parent window above the fullscreen or resized window (check the output of xwininfo -root -tree). SDL seems to just take the coordinates directly from the attributes returned by XGetWindowAttributes - these will be relative to this parent window.
Comment 2 Jason Wyatt 2016-03-09 12:25:59 UTC
Created attachment 2389 [details]
Translate to root window coordinates patch.

I haven't tested this much, however it fixes the resize issue for me.
Comment 3 Jason Wyatt 2016-03-09 13:54:34 UTC
(In reply to Jason Wyatt from comment #2)
> Created attachment 2389 [details]
> Translate to root window coordinates patch.
> 
> I haven't tested this much, however it fixes the resize issue for me.

Oops, this patch is very incomplete, and won't resolve the issue. Sorry about that.
Comment 4 Jason Wyatt 2016-03-09 14:43:02 UTC
Created attachment 2390 [details]
Translate to root window coordinates patch 2

Turns out the coordinates in ConfigureNotify can vary depending on whether it is a synthetic event (relative to root) or a real event (relative to parent). See https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.5
Comment 5 cra0zy@gmail.com 2016-03-15 22:18:15 UTC
How long will it take for the fix to get merged upstream?
Comment 6 Ryan C. Gordon 2016-09-30 03:06:26 UTC
(In reply to Jason Wyatt from comment #4)
> Turns out the coordinates in ConfigureNotify can vary depending on whether
> it is a synthetic event (relative to root) or a real event (relative to
> parent). See https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.5

This patch is now https://hg.libsdl.org/SDL/rev/89656c085088, thanks!

--ryan.