Clear relative mouse mode and restore when bringing up sdl message box.
authorMichael Sartain <mikesart@valvesoftware.com>
Thu, 14 Feb 2013 13:22:05 -0800
changeset 68763a4f7453da33
parent 6875 6c446c82c583
child 6877 7287d385e6b3
Clear relative mouse mode and restore when bringing up sdl message box.
src/video/SDL_video.c
     1.1 --- a/src/video/SDL_video.c	Wed Feb 13 23:10:29 2013 -0800
     1.2 +++ b/src/video/SDL_video.c	Thu Feb 14 13:22:05 2013 -0800
     1.3 @@ -2991,40 +2991,51 @@
     1.4  SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
     1.5  {
     1.6      int dummybutton;
     1.7 +	int retval = -1;
     1.8 +	SDL_bool relative_mode = SDL_GetRelativeMouseMode();
     1.9 +	int show_cursor_prev = SDL_ShowCursor( 1 );
    1.10 +
    1.11 +	SDL_SetRelativeMouseMode( SDL_FALSE );
    1.12  
    1.13      if (!buttonid) {
    1.14          buttonid = &dummybutton;
    1.15      }
    1.16      if (_this && _this->ShowMessageBox) {
    1.17          if (_this->ShowMessageBox(_this, messageboxdata, buttonid) == 0) {
    1.18 -            return 0;
    1.19 +			retval = 0;
    1.20          }
    1.21      }
    1.22  
    1.23      /* It's completely fine to call this function before video is initialized */
    1.24  #if SDL_VIDEO_DRIVER_WINDOWS
    1.25 -    if (WIN_ShowMessageBox(messageboxdata, buttonid) == 0) {
    1.26 -        return 0;
    1.27 +    if ((retval == -1) && (WIN_ShowMessageBox(messageboxdata, buttonid) == 0)) {
    1.28 +        retval = 0;
    1.29      }
    1.30  #endif
    1.31  #if SDL_VIDEO_DRIVER_COCOA
    1.32 -    if (Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0) {
    1.33 -        return 0;
    1.34 +    if ((retval == -1) && (Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0)) {
    1.35 +        retval = 0;
    1.36      }
    1.37  #endif
    1.38  #if SDL_VIDEO_DRIVER_UIKIT
    1.39 -    if (UIKit_ShowMessageBox(messageboxdata, buttonid) == 0) {
    1.40 -        return 0;
    1.41 +    if ((retval == -1) && (UIKit_ShowMessageBox(messageboxdata, buttonid) == 0)) {
    1.42 +        retval = 0;
    1.43      }
    1.44  #endif
    1.45  #if SDL_VIDEO_DRIVER_X11
    1.46 -    if (X11_ShowMessageBox(messageboxdata, buttonid) == 0) {
    1.47 -        return 0;
    1.48 +    if ((retval == -1) && (X11_ShowMessageBox(messageboxdata, buttonid) == 0)) {
    1.49 +        retval = 0;
    1.50      }
    1.51  #endif
    1.52  
    1.53 -    SDL_SetError("No message system available");
    1.54 -    return -1;
    1.55 +	SDL_ShowCursor( show_cursor_prev );
    1.56 +	SDL_SetRelativeMouseMode( relative_mode );
    1.57 +
    1.58 +	if(retval == -1)
    1.59 +	{
    1.60 +		SDL_SetError("No message system available");
    1.61 +	}
    1.62 +    return retval;
    1.63  }
    1.64  
    1.65  int