static int spnav_x11_open(Display *display, Window win) { if(IS_OPEN) { return -1; } dpy = display; motion_event = XInternAtom(dpy, "MotionEvent", True); button_press_event = XInternAtom(dpy, "ButtonPressEvent", True); button_release_event = XInternAtom(dpy, "ButtonReleaseEvent", True); command_event = XInternAtom(dpy, "CommandEvent", True); if(!motion_event || !button_press_event || !button_release_event || !command_event) { dpy = 0; return -1; /* daemon not started */ } if(spnav_x11_window(win) == -1) { dpy = 0; return -1; /* daemon not started */ } app_win = win; return 0; }
void fgPlatformSpaceballSetWindow(SFG_Window *window) { if(spnav_win != window) { spnav_x11_window(window->Window.Handle); spnav_win = window; } }
int spnav_close(void) { if(!IS_OPEN) { return -1; } if(sock) { while(ev_queue) { void *tmp = ev_queue; ev_queue = ev_queue->next; free(tmp); } close(sock); sock = 0; return 0; } #ifdef USE_X11 if(dpy) { spnav_x11_window(DefaultRootWindow(dpy)); app_win = 0; dpy = 0; return 0; } #endif return -1; }
static int spnav_close(void) { if(dpy) { spnav_x11_window(DefaultRootWindow(dpy)); app_win = 0; dpy = 0; return 0; } return -1; }
EventHandler::EventHandler( WindowIF* window ) : _window( window ) , _magellanUsed( false ) { LBASSERT( window ); if( !_eventHandlers ) _eventHandlers = new EventHandlers; _eventHandlers->push_back( this ); eq::Pipe* pipe = window->getPipe(); MessagePump* messagePump = dynamic_cast< MessagePump* >( pipe->isThreaded() ? pipe->getMessagePump() : pipe->getConfig()->getMessagePump( )); Display* display = window->getXDisplay(); LBASSERT( display ); if( messagePump ) messagePump->register_( display ); else LBINFO << "Using glx::EventHandler without glx::MessagePump, external " << "event dispatch assumed" << std::endl; #ifdef EQUALIZER_USE_MAGELLAN_GLX lunchbox::ScopedFastWrite mutex( _magellan ); if( !_magellan->display ) { if( spnav_x11_open( display, window->getXDrawable( )) == -1 ) { LBWARN << "Failed to connect to the space navigator daemon" << std::endl; return; } _magellan->display = display; } else if( _magellan->display != display ) { LBINFO << "Multi-display space mouse support incomplete" << std::endl; return; } else if( spnav_x11_window( window->getXDrawable( )) == -1 ) { LBWARN << "Failed to register window with the space navigator daemon" << std::endl; return; } ++_magellan->used; _magellanUsed = true; #endif }
void fgSpaceballSetWindow(SFG_Window *window) { if(!sball_initialized) { fgInitialiseSpaceball(); if(!sball_initialized) { return; } } #if TARGET_HOST_POSIX_X11 if(spnav_win != window) { spnav_x11_window(window->Window.Handle); spnav_win = window; } #endif }
EventHandler::EventHandler( WindowIF* window ) : _window( window ) , _magellanUsed( false ) { LBASSERT( window ); if( !_eventHandlers ) _eventHandlers = new EventHandlers; _eventHandlers->push_back( this ); #ifdef EQUALIZER_USE_MAGELLAN_GLX Display* display = window->getXDisplay(); LBASSERT( display ); lunchbox::ScopedFastWrite mutex( _magellan ); if( !_magellan->display ) { if( spnav_x11_open( display, window->getXDrawable( )) == -1 ) { LBWARN << "Failed to connect to the space navigator daemon" << std::endl; return; } _magellan->display = display; } else if( _magellan->display != display ) { LBINFO << "Multi-display space mouse support incomplete" << std::endl; return; } else if( spnav_x11_window( window->getXDrawable( )) == -1 ) { LBWARN << "Failed to register window with the space navigator daemon" << std::endl; return; } ++_magellan->used; _magellanUsed = true; #endif }