pioneerspacesim/pioneer — pull request #1892 by robn (2012-12-31 22:46:15+00:00)
Title: Disable DGA mouse on Linux by default

Its been discovered that SDL_VIDEO_X11_DGAMOUSE=0 fixes the broken mouse grab on Linux that we've known about forever.

There's anecdotal evidence to suggest this is a bug in the evdev kernel driver - it doesn't implement parts of DGA correctly.

http://en.gentoo-wiki.com/wiki/X.Org/Mouse#Uncontrollable_mouse_in_SDL_apps
http://www.quakelive.com/forum/showthread.php?5507-Raw-mouse-input-under-Linux
https://bugs.freedesktop.org/show_bug.cgi?id=20770
https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-input-evdev/+bug/205480

Since DGA is ancient and deprecated, I'm not entirely surprised that it hasn't been fixed. SDL2 uses a different mechanism for mouse grabs (`XGrabPointer`) which shouldn't have any of these problems.

With this environment variable, SDL uses an alternate implementation to mouse grabbing, which isn't really much more than just turning off the mouse pointer and sending mouse warp events to X to keep the mouse inside the window.

So this patch sets that environment variable early on Linux only, and also adds a little tracking to resotre the mouse pointer to its pre-grab location (which SDL's alternate grab implementation doesn't do). It also adds a config item, `SDLUseDGAMouse` to use the default behaviour on the off chance a user prefers it.