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 6876 3a4f7453da33
parent 6875 6c446c82c583
child 6877 7287d385e6b3
Clear relative mouse mode and restore when bringing up sdl message box.
src/video/SDL_video.c
--- a/src/video/SDL_video.c	Wed Feb 13 23:10:29 2013 -0800
+++ b/src/video/SDL_video.c	Thu Feb 14 13:22:05 2013 -0800
@@ -2991,40 +2991,51 @@
 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