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

Commit

Permalink
Clear relative mouse mode and restore when bringing up sdl message box.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Sartain committed Feb 14, 2013
1 parent 1e08198 commit 4149992
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/video/SDL_video.c
Expand Up @@ -2991,40 +2991,51 @@ int
SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
{
int dummybutton;
int retval = -1;
SDL_bool relative_mode = SDL_GetRelativeMouseMode();
int show_cursor_prev = SDL_ShowCursor( 1 );

SDL_SetRelativeMouseMode( SDL_FALSE );

if (!buttonid) {
buttonid = &dummybutton;
}
if (_this && _this->ShowMessageBox) {
if (_this->ShowMessageBox(_this, messageboxdata, buttonid) == 0) {
return 0;
retval = 0;
}
}

/* It's completely fine to call this function before video is initialized */
#if SDL_VIDEO_DRIVER_WINDOWS
if (WIN_ShowMessageBox(messageboxdata, buttonid) == 0) {
return 0;
if ((retval == -1) && (WIN_ShowMessageBox(messageboxdata, buttonid) == 0)) {
retval = 0;
}
#endif
#if SDL_VIDEO_DRIVER_COCOA
if (Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0) {
return 0;
if ((retval == -1) && (Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0)) {
retval = 0;
}
#endif
#if SDL_VIDEO_DRIVER_UIKIT
if (UIKit_ShowMessageBox(messageboxdata, buttonid) == 0) {
return 0;
if ((retval == -1) && (UIKit_ShowMessageBox(messageboxdata, buttonid) == 0)) {
retval = 0;
}
#endif
#if SDL_VIDEO_DRIVER_X11
if (X11_ShowMessageBox(messageboxdata, buttonid) == 0) {
return 0;
if ((retval == -1) && (X11_ShowMessageBox(messageboxdata, buttonid) == 0)) {
retval = 0;
}
#endif

SDL_SetError("No message system available");
return -1;
SDL_ShowCursor( show_cursor_prev );
SDL_SetRelativeMouseMode( relative_mode );

if(retval == -1)
{
SDL_SetError("No message system available");
}
return retval;
}

int
Expand Down

0 comments on commit 4149992

Please sign in to comment.