From b03a0630287e3e9daeb5c3054665dcf23ed74135 Mon Sep 17 00:00:00 2001 From: Roger Hughston Date: Wed, 31 May 2006 20:50:56 +0000 Subject: [PATCH] MAC Mouse visibility and procedural location control. ala kaweh --- panda/src/osxdisplay/osxGraphicsWindow.cxx | 60 ++++++++++++++++++---- panda/src/osxdisplay/osxGraphicsWindow.h | 2 +- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/panda/src/osxdisplay/osxGraphicsWindow.cxx b/panda/src/osxdisplay/osxGraphicsWindow.cxx index bb0502bc5a..95fc430724 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.cxx +++ b/panda/src/osxdisplay/osxGraphicsWindow.cxx @@ -1360,10 +1360,26 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground) // may fail if the mouse is not currently within the // window, or if the API doesn't support this operation. //////////////////////////////////////////////////////////////////// -bool osxGraphicsWindow::move_pointer(int device, int x, int y) -{ - return true; -}; +bool osxGraphicsWindow::move_pointer(int device, int x, int y) +{ + if(_osx_window == NULL) + return false; + +if (osxdisplay_cat.is_debug()) + osxdisplay_cat.debug() << "move_pointer " << device <<" "<< x <<" "<< y <<"\n"; + + Point pt = {0, 0}; + pt.h = x; + pt.v = y; + _input_devices[0].set_pointer_in_window(x, y); + LocalPointToSystemPoint(pt); + CGPoint newCursorPosition = {0, 0}; + newCursorPosition.x = pt.h; + newCursorPosition.y = pt.v; + CGWarpMouseCursorPosition(newCursorPosition); + + return true; +}; bool osxGraphicsWindow::do_reshape_request(int x_origin, int y_origin, bool has_origin,int x_size, int y_size) { @@ -1508,11 +1524,23 @@ void osxGraphicsWindow::set_properties_now(WindowProperties &properties) } // cursor managment.. - if(properties.has_cursor_hidden()) - { - _properties.set_cursor_hidden(properties.get_cursor_hidden()); - properties.clear_cursor_hidden(); - } + //if(properties.has_cursor_hidden()) + //{ +// _properties.set_cursor_hidden(properties.get_cursor_hidden()); +// properties.clear_cursor_hidden(); +// } + +if(properties.has_cursor_hidden()) + { + _properties.set_cursor_hidden(properties.get_cursor_hidden()); + if (properties.get_cursor_hidden()) { + CGDisplayHideCursor(kCGDirectMainDisplay); + } else { + CGDisplayShowCursor(kCGDirectMainDisplay); + } + properties.clear_cursor_hidden(); + } + // // icons if(properties.has_icon_filename()) @@ -1569,5 +1597,19 @@ void osxGraphicsWindow::set_properties_now(WindowProperties &properties) return; } +////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////// +void osxGraphicsWindow::LocalPointToSystemPoint(Point &qdLocalPoint) + { + if(_osx_window != NULL) + { + GrafPtr savePort; + GetPort( &savePort ); + SetPortWindowPort(_osx_window ); + LocalToGlobal( &qdLocalPoint ); + SetPort( savePort ); + } + + }; diff --git a/panda/src/osxdisplay/osxGraphicsWindow.h b/panda/src/osxdisplay/osxGraphicsWindow.h index 8f8a0ecd40..a32dd92d12 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.h +++ b/panda/src/osxdisplay/osxGraphicsWindow.h @@ -92,7 +92,7 @@ public: // do not call direct .. void SystemCloseWindow(); void SystemSetWindowForground(bool forground); void SystemPointToLocalPoint(Point &qdGlobalPoint); - + void LocalPointToSystemPoint(Point &qdLocalPoint); AGLContext get_ggs_context(void); AGLContext get_context(void); OSStatus buildGL(bool full_screen);