Fixing freeglut's desire to initialize the spaceball every time a window is checked. Now it tries once the first time a spaceball function is called and after that if it fails it doesn't try any more. This is per an e-mail from Diederick Niehorster vintage 6/8/11 at 3:17 AM, referring to feature request 3190319.

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@928 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
fayjf 2011-09-04 03:49:11 +00:00
parent 36bdaa9a43
commit 42235dfaa1

View File

@ -52,12 +52,17 @@ static int spnav_remove_events(int type);
static SFG_Window *spnav_win;
#endif
static int sball_initialized;
/* Flag telling whether we have a spaceball:
* 0 - haven't tried initializing
* 1 - have successfully initialized
* -1 - have tried to initialize but not succeeded
*/
static int sball_initialized = 0;
void fgInitialiseSpaceball(void)
{
if(sball_initialized) {
if(sball_initialized != 0) {
return;
}
@ -66,10 +71,15 @@ void fgInitialiseSpaceball(void)
Window w;
if(!fgStructure.CurrentWindow)
{
sball_initialized = -1;
return;
}
w = fgStructure.CurrentWindow->Window.Handle;
if(spnav_x11_open(fgDisplay.Display, w) == -1) {
if(spnav_x11_open(fgDisplay.Display, w) == -1)
{
sball_initialized = -1;
return;
}
}
@ -87,9 +97,9 @@ void fgSpaceballClose(void)
int fgHasSpaceball(void)
{
if(!sball_initialized) {
if(sball_initialized == 0) {
fgInitialiseSpaceball();
if(!sball_initialized) {
if(sball_initialized != 1) {
fgWarning("fgInitialiseSpaceball failed\n");
return 0;
}
@ -107,9 +117,9 @@ int fgHasSpaceball(void)
int fgSpaceballNumButtons(void)
{
if(!sball_initialized) {
if(sball_initialized == 0) {
fgInitialiseSpaceball();
if(!sball_initialized) {
if(sball_initialized != 1) {
fgWarning("fgInitialiseSpaceball failed\n");
return 0;
}
@ -124,9 +134,9 @@ int fgSpaceballNumButtons(void)
void fgSpaceballSetWindow(SFG_Window *window)
{
if(!sball_initialized) {
if(sball_initialized == 0) {
fgInitialiseSpaceball();
if(!sball_initialized) {
if(sball_initialized != 1) {
return;
}
}
@ -150,7 +160,7 @@ int fgIsSpaceballXEvent(const XEvent *xev)
fgSpaceballSetWindow(fgStructure.CurrentWindow);
}
if(!sball_initialized) {
if(sball_initialized != 1) {
return 0;
}
@ -161,9 +171,9 @@ void fgSpaceballHandleXEvent(const XEvent *xev)
{
spnav_event sev;
if(!sball_initialized) {
if(sball_initialized == 0) {
fgInitialiseSpaceball();
if(!sball_initialized) {
if(sball_initialized != 1) {
return;
}
}