+ * Grab the pointer to confine it into the window after the calls to
+ * XWrapPointer() which ensure that the pointer really enters the window.
+ *
+ * We also need to wait here until XGrabPointer() returns GrabSuccess,
+ * otherwise the new window is not viewable yet and if the next function
+ * (XSetInputFocus) is called with a not yet viewable window, it will exit
+ * the application which we have to aviod, so wait until it's viewable:
+ */
+ while( GrabSuccess != XGrabPointer(
+ fgDisplay.Display, fgStructure.GameMode->Window.Handle,
+ TRUE,
+ ButtonPressMask | ButtonReleaseMask | ButtonMotionMask
+ | PointerMotionMask,
+ GrabModeAsync, GrabModeAsync,
+ fgStructure.GameMode->Window.Handle, None, CurrentTime) )
+ usleep( 100 );
+
+ /*
+ * Change input focus to the new window. This will exit the application
+ * if the new window is not viewable yet, see the XGrabPointer loop above.