Added support for getting all windows and hiding the cursor
This commit is contained in:
parent
db7df9d6d4
commit
d068f7025a
@ -36,7 +36,7 @@ int main( int argc, char **argv )
|
||||
viewer.setCameraManipulator(new osgGA::TrackballManipulator());
|
||||
viewer.getCamera()->setClearColor(osg::Vec4f(0.6f,0.6f,0.8f,1.0f));
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
|
||||
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
|
||||
if (!wsi)
|
||||
@ -100,8 +100,6 @@ int main( int argc, char **argv )
|
||||
|
||||
viewer.realize();
|
||||
|
||||
gw->requestWarpPointer(100,100);
|
||||
|
||||
bool limitNumberOfFrames = false;
|
||||
unsigned int numFrames = 0;
|
||||
unsigned int maxFrames = 10;
|
||||
|
@ -1580,6 +1580,16 @@ int main( int argc, char **argv )
|
||||
|
||||
viewer.realize();
|
||||
|
||||
// switch off the cursor
|
||||
osgViewer::Viewer::Windows windows;
|
||||
viewer.getWindows(windows);
|
||||
for(osgViewer::Viewer::Windows::iterator itr = windows.begin();
|
||||
itr != windows.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->useCursor(false);
|
||||
}
|
||||
|
||||
// todo for osgViewer - implement warp pointer
|
||||
// viewer.requestWarpPointer(0.5f,0.5f);
|
||||
|
||||
|
@ -51,6 +51,9 @@ class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgG
|
||||
/** Get focus on if the pointer is in this window.*/
|
||||
virtual void grabFocusIfPointerInWindow() {}
|
||||
|
||||
/** Switch on/off the cursor.*/
|
||||
virtual void useCursor(bool /*cursorOn*/) {}
|
||||
|
||||
public:
|
||||
|
||||
/** Realise the GraphicsContext implementation,
|
||||
|
@ -89,6 +89,21 @@ class GraphicsWindowX11 : public osgViewer::GraphicsWindow
|
||||
// Override from GUIActionAdapter
|
||||
virtual void requestWarpPointer(float x,float y);
|
||||
|
||||
/** Switch on/off the cursor.*/
|
||||
virtual void useCursor(bool cursorOn);
|
||||
|
||||
public:
|
||||
|
||||
// X11 specific aces functions
|
||||
|
||||
Display* getDisplay() { return _display; }
|
||||
Window& getParent() { return _parent; }
|
||||
Window& getWindow() { return _window; }
|
||||
|
||||
Cursor& getDefaultCursor() { return _defaultCursor; }
|
||||
Cursor& getNullCursor() { return _nullCursor; }
|
||||
Cursor& getCurrentCursor() { return _nullCursor; }
|
||||
|
||||
protected:
|
||||
|
||||
bool createVisualInfo();
|
||||
|
@ -58,13 +58,16 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
|
||||
osg::Camera* getCameraWithFocus() { return _cameraWithFocus.get(); }
|
||||
const osg::Camera* getCameraWithFocus() const { return _cameraWithFocus.get(); }
|
||||
|
||||
typedef std::vector<osg::GraphicsContext*> Contexts;
|
||||
void getContexts(Contexts& contexts);
|
||||
|
||||
typedef std::vector<osgViewer::GraphicsWindow*> Windows;
|
||||
void getWindows(Windows& windows);
|
||||
|
||||
public:
|
||||
|
||||
void init();
|
||||
|
||||
typedef std::vector<osg::GraphicsContext*> Contexts;
|
||||
void getContexts(Contexts& contexts);
|
||||
|
||||
bool _firstFrame;
|
||||
bool _done;
|
||||
|
||||
|
@ -333,6 +333,25 @@ void GraphicsWindowX11::setWindowDecoration(bool flag)
|
||||
osg::notify(osg::NOTICE)<<"Error: GraphicsWindowX11::setBorder(" << flag << ") - couldn't change decorations." << std::endl;
|
||||
}
|
||||
|
||||
void GraphicsWindowX11::useCursor(bool cursorOn)
|
||||
{
|
||||
if (cursorOn)
|
||||
{
|
||||
_currentCursor = _defaultCursor;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentCursor = _nullCursor;
|
||||
}
|
||||
|
||||
if (_display && _window)
|
||||
{
|
||||
XDefineCursor( _display, _window, _currentCursor );
|
||||
XFlush(_display);
|
||||
XSync(_display,0);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsWindowX11::init()
|
||||
{
|
||||
if (_initialized) return;
|
||||
@ -461,17 +480,7 @@ void GraphicsWindowX11::init()
|
||||
_nullCursor = XCreatePixmapCursor( _display, pixmap, pixmap, &ncol, &ncol, 0, 0 );
|
||||
}
|
||||
|
||||
#if 1
|
||||
_currentCursor = _defaultCursor;
|
||||
#else
|
||||
_currentCursor = _nullCursor;
|
||||
#endif
|
||||
|
||||
{
|
||||
XDefineCursor( _display, _window, _currentCursor );
|
||||
XFlush(_display);
|
||||
XSync(_display,0);
|
||||
}
|
||||
useCursor(true);
|
||||
|
||||
XSelectInput( _display, _window, ExposureMask | StructureNotifyMask |
|
||||
KeyPressMask | KeyReleaseMask |
|
||||
|
@ -94,6 +94,39 @@ void Viewer::getContexts(Contexts& contexts)
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::getWindows(Windows& windows)
|
||||
{
|
||||
typedef std::set<osgViewer::GraphicsWindow*> WindowSet;
|
||||
WindowSet windowSet;
|
||||
|
||||
if (_camera.valid() && _camera->getGraphicsContext())
|
||||
{
|
||||
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(_camera->getGraphicsContext());
|
||||
if (gw) windowSet.insert(gw);
|
||||
}
|
||||
|
||||
for(unsigned int i=0; i<getNumSlaves(); ++i)
|
||||
{
|
||||
Slave& slave = getSlave(i);
|
||||
if (slave._camera.valid() && slave._camera->getGraphicsContext())
|
||||
{
|
||||
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(slave._camera->getGraphicsContext());
|
||||
if (gw) windowSet.insert(gw);
|
||||
}
|
||||
}
|
||||
|
||||
windows.clear();
|
||||
windows.reserve(windowSet.size());
|
||||
|
||||
for(WindowSet::iterator itr = windowSet.begin();
|
||||
itr != windowSet.end();
|
||||
++itr)
|
||||
{
|
||||
windows.push_back(const_cast<osgViewer::GraphicsWindow*>(*itr));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OpenThreads::Mutex mutex;
|
||||
|
||||
// Compile operation, that compile OpenGL objects.
|
||||
|
Loading…
Reference in New Issue
Block a user