From c4c5cc850bc8f006957592f67fafdaf7393c1b94 Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 4 Oct 2011 09:17:56 +0100 Subject: [PATCH] Adjust cursor-setting code, for better compatibility with Cocoa-Viewer (OSG patch still required, unfortunately) --- src/Main/fg_os_osgviewer.cxx | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Main/fg_os_osgviewer.cxx b/src/Main/fg_os_osgviewer.cxx index 6952195f5..e8ba901a2 100644 --- a/src/Main/fg_os_osgviewer.cxx +++ b/src/Main/fg_os_osgviewer.cxx @@ -45,6 +45,7 @@ #include #include #include +#include #include #include "fg_os.hxx" @@ -313,24 +314,23 @@ void fgOSFullScreen() { } -static void setMouseCursor(osg::Camera* camera, int cursor) +static void setMouseCursor(osgViewer::GraphicsWindow* gw, int cursor) { - if (!camera) + if (!gw) { return; - osg::GraphicsContext* gc = camera->getGraphicsContext(); - if (!gc) - return; - osgViewer::GraphicsWindow* gw; - gw = dynamic_cast(gc); - if (!gw) - return; - + } + osgViewer::GraphicsWindow::MouseCursor mouseCursor; mouseCursor = osgViewer::GraphicsWindow::InheritCursor; - if (cursor == MOUSE_CURSOR_NONE) + if (cursor == MOUSE_CURSOR_NONE) mouseCursor = osgViewer::GraphicsWindow::NoCursor; else if(cursor == MOUSE_CURSOR_POINTER) +#ifdef SG_MAC + // osgViewer-Cocoa lacks RightArrowCursor, use Left + mouseCursor = osgViewer::GraphicsWindow::LeftArrowCursor; +#else mouseCursor = osgViewer::GraphicsWindow::RightArrowCursor; +#endif else if(cursor == MOUSE_CURSOR_WAIT) mouseCursor = osgViewer::GraphicsWindow::WaitCursor; else if(cursor == MOUSE_CURSOR_CROSSHAIR) @@ -362,9 +362,12 @@ static int _cursor = -1; void fgSetMouseCursor(int cursor) { _cursor = cursor; - setMouseCursor(viewer->getCamera(), cursor); - for (unsigned i = 0; i < viewer->getNumSlaves(); ++i) - setMouseCursor(viewer->getSlave(i)._camera.get(), cursor); + + std::vector windows; + viewer->getWindows(windows); + BOOST_FOREACH(osgViewer::GraphicsWindow* gw, windows) { + setMouseCursor(gw, cursor); + } } int fgGetMouseCursor() -- 2.39.5