diff -uNr SDL-1.2.15/src/video/x11/SDL_x11wm.c SDL-1.2.15.mod/src/video/x11/SDL_x11wm.c
--- SDL-1.2.15/src/video/x11/SDL_x11wm.c	2012-01-19 08:30:06.000000000 +0200
+++ SDL-1.2.15.mod/src/video/x11/SDL_x11wm.c	2018-10-26 23:20:45.235391408 +0300
@@ -352,13 +352,14 @@
 			result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
 						GrabModeAsync, GrabModeAsync,
 						SDL_Window, None, CurrentTime);
-			if ( result == GrabSuccess ) {
+			if ( result == GrabSuccess || result == GrabNotViewable ) {
 				break;
 			}
 			SDL_Delay(100);
 		}
 		if ( result != GrabSuccess ) {
 			/* Uh, oh, what do we do here? */ ;
+			return(SDL_GRAB_OFF);
 		}
 		/* Now grab the keyboard */
 		XGrabKeyboard(SDL_Display, WMwindow, True,
