Skip to content

Commit

Permalink
Fix SDL_SetWindowPosition on fullscreen windows.
Browse files Browse the repository at this point in the history
This reverts http://hg.libsdl.org/SDL/rev/7cdeb64faa72 and fixes it in
the correct way. If you call SDL_SetWindowPosition on a fullscreen
window, it would update the x & y variables for the window, but not
actually move the window (since it was fullscreen). That would make the
internal state of the SDL_Window incorrect, causing
SDL_WarpMouseInWindow to offset incorrectly.

This makes it so SDL_SetWindowPosition updates the `windowed' x & y
coordinates, which take effect when you revert from fullscreen.
  • Loading branch information
jorgenpt committed Oct 7, 2013
1 parent cca0942 commit c455f72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
21 changes: 14 additions & 7 deletions src/video/SDL_video.c
Expand Up @@ -1551,14 +1551,21 @@ SDL_SetWindowPosition(SDL_Window * window, int x, int y)
}
}

if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
window->x = x;
}
if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
window->y = y;
}
if ((window->flags & SDL_WINDOW_FULLSCREEN)) {
if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
window->windowed.x = x;
}
if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
window->windowed.y = y;
}
} else {
if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
window->x = x;
}
if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
window->y = y;
}

if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
if (_this->SetWindowPosition) {
_this->SetWindowPosition(_this, window);
}
Expand Down
8 changes: 1 addition & 7 deletions src/video/cocoa/SDL_cocoamouse.m
Expand Up @@ -204,13 +204,7 @@ + (NSCursor *)invisibleCursor
Cocoa_WarpMouse(SDL_Window * window, int x, int y)
{
SDL_Mouse *mouse = SDL_GetMouse();
CGPoint point = CGPointMake(x, y);

if (!(window->flags & SDL_WINDOW_FULLSCREEN))
{
point.x += window->x;
point.y += window->y;
}
CGPoint point = CGPointMake(x + (float)window->x, y + (float)window->y);

{
/* This makes Cocoa_HandleMouseEvent ignore this delta in the next
Expand Down

0 comments on commit c455f72

Please sign in to comment.