diff --git a/include/osgViewer/GraphicsWindow b/include/osgViewer/GraphicsWindow index 6f2b5db02..065c36494 100644 --- a/include/osgViewer/GraphicsWindow +++ b/include/osgViewer/GraphicsWindow @@ -42,6 +42,15 @@ class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgG virtual void checkEvents() {} + /** Set Window decoration.*/ + virtual void setWindowDecoration(bool /*flag*/) {} + + /** Get focus.*/ + virtual void grabFocus() {} + + /** Get focus on if the pointer is in this window.*/ + virtual void grabFocusIfPointerInWindow() {} + public: /** Realise the GraphicsContext implementation, diff --git a/include/osgViewer/GraphicsWindowX11 b/include/osgViewer/GraphicsWindowX11 index 1b5fbd371..42ae4c48c 100644 --- a/include/osgViewer/GraphicsWindowX11 +++ b/include/osgViewer/GraphicsWindowX11 @@ -124,10 +124,18 @@ class GraphicsWindowX11 : public osgViewer::GraphicsWindow /** Check to see if any events have been generated.*/ virtual void checkEvents(); + /** Set Window decoration.*/ + virtual void setWindowDecoration(bool flag); + + /** Get focus.*/ + virtual void grabFocus(); + + /** Get focus on if the pointer is in this window.*/ + virtual void grabFocusIfPointerInWindow(); + protected: bool createVisualInfo(); - void setBorder(bool flag); void init(); void transformMouseXY(float& x, float& y); @@ -184,7 +192,7 @@ bool GraphicsWindowX11::createVisualInfo() return _visualInfo != 0; } -void GraphicsWindowX11::setBorder(bool flag) +void GraphicsWindowX11::setWindowDecoration(bool flag) { Atom atom; if( (atom = XInternAtom( _display, "_MOTIF_WM_HINTS", 0 )) != None ) @@ -239,6 +247,14 @@ void GraphicsWindowX11::setBorder(bool flag) XFlush(_display); XSync(_display,0); + +#if 0 + // now update the window dimensions to account for any size changes made by the window manager, + XGetWindowAttributes( _display, _window, &watt ); + _traits->_width = watt.width; + _traits->_height = watt.height; +#endif + } else osg::notify(osg::NOTICE)<<"Error: GraphicsWindowX11::setBorder(" << flag << ") - couldn't change decorations." << std::endl; @@ -298,7 +314,7 @@ void GraphicsWindowX11::init() XSetWindowAttributes swatt; swatt.colormap = XCreateColormap( _display, _parent, _visualInfo->visual, AllocNone); - //swatt.colormap = DefaultColormap( _dpy, 0 ); + //swatt.colormap = DefaultColormap( _dpy, 10 ); swatt.background_pixel = 0; swatt.border_pixel = 0; swatt.event_mask = 0; @@ -337,14 +353,15 @@ void GraphicsWindowX11::init() sh.height = _traits->_height; XSetStandardProperties( _display, _window, _traits->_windowName.c_str(), _traits->_windowName.c_str(), None, 0, 0, &sh); -#if 1 - setBorder(_traits->_windowDecoration); +#if 0 + setWindowDecoration(_traits->_windowDecoration); #else - setBorder(true); + setWindowDecoration(true); #endif // Create default Cursor _defaultCursor = XCreateFontCursor( _display, XC_left_ptr ); + // Create Null Cursor { Pixmap pixmap; @@ -374,6 +391,14 @@ void GraphicsWindowX11::init() XFlush( _display ); XSync( _display, 0 ); + // now update the window dimensions to account for any size changes made by the window manager, + XGetWindowAttributes( _display, _window, &watt ); + _traits->_width = watt.width; + _traits->_height = watt.height; + + //osg::notify(osg::NOTICE)<<"After sync apply.x = "<getGraphicsContext()->realize(); + osgViewer::GraphicsWindow* gw = dynamic_cast(slave._camera->getGraphicsContext()); + gw->grabFocusIfPointerInWindow(); + } + } + + } }