From 4f5379389db9a833326588367d4e7bc06bcf6f80 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 7 Nov 2008 10:23:57 +0000 Subject: [PATCH] From Martins Innus, "Here is a fix to add requestWarpPointer for OS X. It seems to work for me, I just took what osgProducer had. These are updated files to 2.7.3" --- .../osgViewer/api/Carbon/GraphicsWindowCarbon | 3 +++ src/osgViewer/GraphicsWindowCarbon.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/osgViewer/api/Carbon/GraphicsWindowCarbon b/include/osgViewer/api/Carbon/GraphicsWindowCarbon index 910eb56d3..7e9458406 100644 --- a/include/osgViewer/api/Carbon/GraphicsWindowCarbon +++ b/include/osgViewer/api/Carbon/GraphicsWindowCarbon @@ -92,6 +92,9 @@ class GraphicsWindowCarbon : public osgViewer::GraphicsWindow /** Set Window decoration.*/ virtual bool setWindowDecorationImplementation(bool flag); + // Override from GUIActionAdapter + virtual void requestWarpPointer( float x, float y); + /** Get focus.*/ virtual void grabFocus(); diff --git a/src/osgViewer/GraphicsWindowCarbon.cpp b/src/osgViewer/GraphicsWindowCarbon.cpp index faf00cc7e..31f4ff58f 100644 --- a/src/osgViewer/GraphicsWindowCarbon.cpp +++ b/src/osgViewer/GraphicsWindowCarbon.cpp @@ -1259,6 +1259,24 @@ void GraphicsWindowCarbon::setWindowName (const std::string& name) } } +void GraphicsWindowCarbon::requestWarpPointer(float x,float y) +{ + + OSXCarbonWindowingSystemInterface* wsi = dynamic_cast(osg::GraphicsContext::getWindowingSystemInterface()); + if (wsi == NULL) { + osg::notify(osg::WARN) << "GraphicsWindowCarbon::useCursor :: could not get OSXCarbonWindowingSystemInterface" << std::endl; + return; + } + + CGDirectDisplayID displayId = wsi->getDisplayID((*_traits)); + + CGPoint point; + point.x = x; + point.y = y; + CGDisplayMoveCursorToPoint(displayId, point); + + getEventQueue()->mouseWarped(x,y); +} void GraphicsWindowCarbon::transformMouseXY(float& x, float& y)