From b6182a1239b6e2fdf9687424d0c63fb4831376aa Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 22 Apr 2009 11:12:03 +0000 Subject: [PATCH] From Peter Amstutz, "Here is a simple change to osgViewer::GraphicsWindowWin32 to add a flag to WindowData to specify that the graphics window should not install an event handler of its own, per this discussion thread: http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg23734.html The change is source compatible with current osg code and will not affect current users, it simply adds an additional parameter to the GraphicsWindowWin32::WindowData struct constructor and defaults to the current behavior. Attached are the files "include/osgViewer/api/Win32/GraphicsWindowWin32" and "src/osgViewer/GraphicsWindowWin32.cpp" with my changes, based on svn revision 10045. In addition, I have provided an svn patch file with the same changes for your convenience. I have discussed the matter with my supervisor, and agreed that my company makes no copyright claim over this extremely trivial change (or to put it another way, we assign copyright to the open scene graph community.)" --- .../osgViewer/api/Win32/GraphicsWindowWin32 | 5 +++-- src/osgViewer/GraphicsWindowWin32.cpp | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/osgViewer/api/Win32/GraphicsWindowWin32 b/include/osgViewer/api/Win32/GraphicsWindowWin32 index 1a95464a5..6fd9603fc 100644 --- a/include/osgViewer/api/Win32/GraphicsWindowWin32 +++ b/include/osgViewer/api/Win32/GraphicsWindowWin32 @@ -97,10 +97,11 @@ class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow /** WindowData is used to pass in the Win32 window handle attached the GraphicsContext::Traits structure.*/ struct WindowData : public osg::Referenced { - WindowData(HWND window): - _hwnd(window) {} + WindowData(HWND window, bool installEventHandler = true): + _hwnd(window), _installEventHandler(installEventHandler) {} HWND _hwnd; + bool _installEventHandler; }; /** Get native window.*/ diff --git a/src/osgViewer/GraphicsWindowWin32.cpp b/src/osgViewer/GraphicsWindowWin32.cpp index 525b69036..bb5b2e926 100644 --- a/src/osgViewer/GraphicsWindowWin32.cpp +++ b/src/osgViewer/GraphicsWindowWin32.cpp @@ -1242,14 +1242,19 @@ bool GraphicsWindowWin32::setWindow( HWND handle ) return false; } - if (!registerWindowProcedure()) + WindowData *windowData = _traits.get() ? dynamic_cast(_traits->inheritedWindowData.get()) : 0; + + if (!windowData || windowData->_installEventHandler) { - ::wglDeleteContext(_hglrc); - _hglrc = 0; - ::ReleaseDC(_hwnd, _hdc); - _hdc = 0; - _hwnd = 0; - return false; + if (!registerWindowProcedure()) + { + ::wglDeleteContext(_hglrc); + _hglrc = 0; + ::ReleaseDC(_hwnd, _hdc); + _hdc = 0; + _hwnd = 0; + return false; + } } Win32WindowingSystem::getInterface()->registerWindow(_hwnd, this);