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:
parent
36bdaa9a43
commit
42235dfaa1
@ -52,12 +52,17 @@ static int spnav_remove_events(int type);
|
|||||||
static SFG_Window *spnav_win;
|
static SFG_Window *spnav_win;
|
||||||
#endif
|
#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)
|
void fgInitialiseSpaceball(void)
|
||||||
{
|
{
|
||||||
if(sball_initialized) {
|
if(sball_initialized != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,10 +71,15 @@ void fgInitialiseSpaceball(void)
|
|||||||
Window w;
|
Window w;
|
||||||
|
|
||||||
if(!fgStructure.CurrentWindow)
|
if(!fgStructure.CurrentWindow)
|
||||||
|
{
|
||||||
|
sball_initialized = -1;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
w = fgStructure.CurrentWindow->Window.Handle;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,9 +97,9 @@ void fgSpaceballClose(void)
|
|||||||
|
|
||||||
int fgHasSpaceball(void)
|
int fgHasSpaceball(void)
|
||||||
{
|
{
|
||||||
if(!sball_initialized) {
|
if(sball_initialized == 0) {
|
||||||
fgInitialiseSpaceball();
|
fgInitialiseSpaceball();
|
||||||
if(!sball_initialized) {
|
if(sball_initialized != 1) {
|
||||||
fgWarning("fgInitialiseSpaceball failed\n");
|
fgWarning("fgInitialiseSpaceball failed\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -107,9 +117,9 @@ int fgHasSpaceball(void)
|
|||||||
|
|
||||||
int fgSpaceballNumButtons(void)
|
int fgSpaceballNumButtons(void)
|
||||||
{
|
{
|
||||||
if(!sball_initialized) {
|
if(sball_initialized == 0) {
|
||||||
fgInitialiseSpaceball();
|
fgInitialiseSpaceball();
|
||||||
if(!sball_initialized) {
|
if(sball_initialized != 1) {
|
||||||
fgWarning("fgInitialiseSpaceball failed\n");
|
fgWarning("fgInitialiseSpaceball failed\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -124,9 +134,9 @@ int fgSpaceballNumButtons(void)
|
|||||||
|
|
||||||
void fgSpaceballSetWindow(SFG_Window *window)
|
void fgSpaceballSetWindow(SFG_Window *window)
|
||||||
{
|
{
|
||||||
if(!sball_initialized) {
|
if(sball_initialized == 0) {
|
||||||
fgInitialiseSpaceball();
|
fgInitialiseSpaceball();
|
||||||
if(!sball_initialized) {
|
if(sball_initialized != 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,7 +160,7 @@ int fgIsSpaceballXEvent(const XEvent *xev)
|
|||||||
fgSpaceballSetWindow(fgStructure.CurrentWindow);
|
fgSpaceballSetWindow(fgStructure.CurrentWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!sball_initialized) {
|
if(sball_initialized != 1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,9 +171,9 @@ void fgSpaceballHandleXEvent(const XEvent *xev)
|
|||||||
{
|
{
|
||||||
spnav_event sev;
|
spnav_event sev;
|
||||||
|
|
||||||
if(!sball_initialized) {
|
if(sball_initialized == 0) {
|
||||||
fgInitialiseSpaceball();
|
fgInitialiseSpaceball();
|
||||||
if(!sball_initialized) {
|
if(sball_initialized != 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user