Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 1165 (SDL_GetMouseState() returns wrong location after swit…
Browse files Browse the repository at this point in the history
…ch to/from fullscreen)

I'm solving this by moving the mouse to the correct location after a fullscreen mode switch.
  • Loading branch information
slouken committed Mar 12, 2011
1 parent 600a0fe commit 2cb4972
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/video/SDL_video.c
Expand Up @@ -1017,6 +1017,17 @@ SDL_GetWindowPixelFormat(SDL_Window * window)
return display->current_mode.format;
}

static void
SDL_RestoreMousePosition(SDL_Window *window)
{
int x, y;

if (window == SDL_GetMouseFocus()) {
SDL_GetMouseState(&x, &y);
SDL_WarpMouseInWindow(window, x, y);
}
}

static void
SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
{
Expand Down Expand Up @@ -1070,6 +1081,8 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
} else {
SDL_OnWindowResized(other);
}

SDL_RestoreMousePosition(other);
return;
}
}
Expand All @@ -1085,6 +1098,9 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)

/* Generate a mode change event here */
SDL_OnWindowResized(window);

/* Restore the cursor position */
SDL_RestoreMousePosition(window);
}

#define CREATE_FLAGS \
Expand Down

0 comments on commit 2cb4972

Please sign in to comment.