예제 #1
0
bool Window::processEvent( const WindowEvent& event )
{
    switch( event.type )
    {
      case Event::WINDOW_POINTER_BUTTON_PRESS:
        if( getIAttribute( IATTR_HINT_GRAB_POINTER ) == ON &&
            getIAttribute( IATTR_HINT_DRAWABLE ) == WINDOW &&
            // If no other button was pressed already, capture the mouse
            event.pointerButtonPress.buttons == event.pointerButtonPress.button)
        {
            const unsigned int eventMask = ButtonPressMask | ButtonReleaseMask |
                                           ButtonMotionMask;
            const int result = XGrabPointer( getXDisplay(), getXDrawable(),
                                             False, eventMask, GrabModeAsync,
                                             GrabModeAsync, None, None,
                                             CurrentTime );
            if( result == GrabSuccess )
            {
                WindowEvent grabEvent = event;
                grabEvent.type = Event::WINDOW_POINTER_GRAB;
                processEvent( grabEvent );
            }
            else
            {
                LBWARN << "Failed to grab mouse: XGrabPointer returned "
                       << result << std::endl;
            }
        }
        break;

      case Event::WINDOW_POINTER_BUTTON_RELEASE:
        if( getIAttribute( IATTR_HINT_GRAB_POINTER ) == ON &&
            getIAttribute( IATTR_HINT_DRAWABLE ) == WINDOW &&
            // If no button is pressed anymore, release the mouse
            event.pointerButtonRelease.buttons == PTR_BUTTON_NONE )
        {
            // Call early for consistent ordering
            const bool result = SystemWindow::processEvent( event );

            WindowEvent ungrabEvent = event;
            ungrabEvent.type = Event::WINDOW_POINTER_UNGRAB;
            processEvent( ungrabEvent );
            XUngrabPointer( getXDisplay(), CurrentTime );
            return result;
        }
        break;
    }
    return SystemWindow::processEvent( event );
}
void RobotDrawComponent::drawObject()
{
	//drawCircle(getXDisplay(rPos.x), getYDisplay(rPos.y), 0.1, 10);	

	//GLUquadric* test = gluNewQuadric();
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	glTranslatef(getXDisplay(rPos.x), getYDisplay(rPos.y), 0.0f);

	for (int i = 0; i < NUM_OF_CONES; i++)
		cones[i]->drawObject();


	glColor4f(1.0, 0.0, 0.0, 0.8f);
	gluPartialDisk(gluNewQuadric(), 0, 0.1, 100, 10, -orientationAngle+100, 340);

	
	glTranslatef(-getXDisplay(rPos.x), -getYDisplay(rPos.y), 0.0f);
}
예제 #3
0
void Pipe::configExit()
{
    Display* xDisplay = getXDisplay();
    if( !xDisplay )
        return;

    setXDisplay( 0 );
    XCloseDisplay( xDisplay );
    LBVERB << "Closed X display " << xDisplay << std::endl;
}
예제 #4
0
void Window::exitEventHandler()
{
    if( _impl->messagePump )
    {
        Display* display = getXDisplay();
        LBASSERT( display );
        _impl->messagePump->deregister( display );
    }

    delete _impl->glXEventHandler;
    _impl->glXEventHandler = 0;
}
예제 #5
0
void Window::initEventHandler()
{
    LBASSERT( !_impl->glXEventHandler );
    _impl->glXEventHandler = new EventHandler( this );

    Display* display = getXDisplay();
    LBASSERT( display );
    if( _impl->messagePump )
        _impl->messagePump->register_( display );
    else
        LBDEBUG << "Using glx::EventHandler without glx::MessagePump, external "
                << "event dispatch assumed" << std::endl;
}
예제 #6
0
	//-------------------------------------------------------------------------------------------------//
	GLXGLSupport::GLXGLSupport() : mGLDisplay(0), mXDisplay(0)
	{
		// A connection that might be shared with the application for GL rendering:
		mGLDisplay = getGLDisplay();
		
		// A connection that is NOT shared to enable independent event processing:
		mXDisplay  = getXDisplay();
		
		int dummy;
		
		if (XQueryExtension(mXDisplay, "RANDR", &dummy, &dummy, &dummy))
		{
			XRRScreenConfiguration *screenConfig;
			
			screenConfig = XRRGetScreenInfo(mXDisplay, DefaultRootWindow(mXDisplay));
			
			if (screenConfig) 
			{
				XRRScreenSize *screenSizes;
				int nSizes = 0;
				Rotation currentRotation;
				int currentSizeID = XRRConfigCurrentConfiguration(screenConfig, &currentRotation);
				
				screenSizes = XRRConfigSizes(screenConfig, &nSizes);
				
				mCurrentMode.first.first = screenSizes[currentSizeID].width;
				mCurrentMode.first.second = screenSizes[currentSizeID].height;
				mCurrentMode.second = XRRConfigCurrentRate(screenConfig);
				
				mOriginalMode = mCurrentMode;
				
				for(int sizeID = 0; sizeID < nSizes; sizeID++) 
				{
					short *rates;
					int nRates = 0;
					
					rates = XRRConfigRates(screenConfig, sizeID, &nRates);
					
					for (int rate = 0; rate < nRates; rate++)
					{
						VideoMode mode;
						
						mode.first.first = screenSizes[sizeID].width;
						mode.first.second = screenSizes[sizeID].height;
						mode.second = rates[rate];
						
						mVideoModes.push_back(mode);
					}
				}
				XRRFreeScreenConfigInfo(screenConfig);
			}
		}
		else
		{
			mCurrentMode.first.first = DisplayWidth(mXDisplay, DefaultScreen(mXDisplay));
			mCurrentMode.first.second = DisplayHeight(mXDisplay, DefaultScreen(mXDisplay));
			mCurrentMode.second = 0;
			
			mOriginalMode = mCurrentMode;
			
			mVideoModes.push_back(mCurrentMode);
		}
		
		GLXFBConfig *fbConfigs;
		int config, nConfigs = 0;
		
		fbConfigs = chooseFBConfig(NULL, &nConfigs);
		
		for (config = 0; config < nConfigs; config++)
		{
			int caveat, samples;
			
			getFBConfigAttrib (fbConfigs[config], GLX_CONFIG_CAVEAT, &caveat);
			
			if (caveat != GLX_SLOW_CONFIG)
			{
				getFBConfigAttrib (fbConfigs[config], GLX_SAMPLES, &samples);
				mSampleLevels.push_back(StringConverter::toString(samples));
			}
		}
		
		XFree (fbConfigs);
		
		remove_duplicates(mSampleLevels);
	}