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 1842 - [patch] SDL_SetWindowPosition sets bad position values when given SDL_WINDOWPOS_CENTERED args
Summary: [patch] SDL_SetWindowPosition sets bad position values when given SDL_WINDOWP...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86_64 Mac OS X 10.7
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-07 23:05 UTC by Alex Szpakowski
Modified: 2013-05-20 01:37 UTC (History)
0 users

See Also:


Attachments
Patch to fix SDL_SetWindowPosition with SDL_WINDOWPOS_CENTERED (1.53 KB, application/octet-stream)
2013-05-07 23:05 UTC, Alex Szpakowski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Szpakowski 2013-05-07 23:05:03 UTC
Created attachment 1133 [details]
Patch to fix SDL_SetWindowPosition with SDL_WINDOWPOS_CENTERED

When calling SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED), the window moves to the correct position but it seems to internally set its x/y position values to the literal value of the SDL_WINDOWPOS_CENTERED define.
This causes all sorts of problems when SDL functions which use the window position (e.g. SDL_SetWindowGrab) are called after the aforementioned SDL_SetWindowPosition call.

Looking at the SDL_SetWindowPosition code, it seems that SDL_SendWindowEvent with the SDL_WINDOWEVENT_MOVED event is called at the end of the function using the literal value of the SDL_WINDOWPOS_CENTERED define, instead of the newly set window->x and window->y values.
SDL_SendWindowEvent then sets the values of window->windowed.x and window->windowed.y to that value (0x2FFF0000, aka 805240832.)

I have attached a patch which changes SDL_SetWindowPosition to make sure SDL_SendWindowEvent is called with the correct coordinate values, if SDL_WINDOWPOS_CENTERED is used (fixes the issue for me.)

Tested with Mac OS 10.8.3.
Comment 1 Sam Lantinga 2013-05-20 01:37:17 UTC
Fixed, thanks!
http://hg.libsdl.org/SDL/rev/d206c3a59b2e