Improved handling of window input ranges for single window apps

This commit is contained in:
Robert Osfield 2006-12-27 20:23:34 +00:00
parent c8957b58c8
commit b2a0b50a5a
2 changed files with 14 additions and 2 deletions

View File

@ -105,12 +105,14 @@ void View::setUpViewAcrossAllScreens()
if (gw)
{
osg::notify(osg::INFO)<<" GraphicsWindow has been created successfully."<<std::endl;
gw->getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, width, height );
}
else
{
osg::notify(osg::NOTICE)<<" GraphicsWindow has not been created successfully."<<std::endl;
}
_camera->setViewport(new osg::Viewport(0, 0, width, height));
}
else
@ -147,6 +149,7 @@ void View::setUpViewAcrossAllScreens()
{
osg::notify(osg::INFO)<<" GraphicsWindow has been created successfully."<<gw<<std::endl;
gw->getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, width, height );
gw->getEventQueue()->setUseFixedMouseInputRange(true);
gw->getEventQueue()->getCurrentEventState()->setInputRange(inputRangeMinX, inputRangeMinY, inputRangeMinX+float(width),inputRangeMinY+float(height) );
inputRangeMinX += float(width);

View File

@ -299,8 +299,12 @@ void Viewer::frameEventTraversal()
++itr)
{
osgGA::GUIEventAdapter* event = itr->get();
event->setInputRange(eventState->getXmin(), eventState->getYmin(), eventState->getXmax(), eventState->getYmax());
if (getEventQueue()->getUseFixedMouseInputRange())
{
event->setInputRange(eventState->getXmin(), eventState->getYmin(), eventState->getXmax(), eventState->getYmax());
}
switch(event->getEventType())
{
case(osgGA::GUIEventAdapter::PUSH):
@ -310,12 +314,17 @@ void Viewer::frameEventTraversal()
eventState->setX(event->getX());
eventState->setY(event->getY());
eventState->setButtonMask(event->getButtonMask());
// osg::notify(osg::NOTICE)<<" mouse x = "<<event->getX()<<" y="<<event->getY()<<std::endl;
// osg::notify(osg::NOTICE)<<" mouse Xmin = "<<event->getXmin()<<" Ymin="<<event->getYmin()<<" xMax="<<event->getXmax()<<" Ymax="<<event->getYmax()<<std::endl;
break;
default:
break;
}
}
// osg::notify(osg::NOTICE)<<"mouseEventState Xmin = "<<eventState->getXmin()<<" Ymin="<<eventState->getYmin()<<" xMax="<<eventState->getXmax()<<" Ymax="<<eventState->getYmax()<<std::endl;
_eventQueue->frame( _scene->getFrameStamp()->getReferenceTime() );
_eventQueue->takeEvents(events);