Forráskód Böngészése

MAC Mouse visibility and procedural location control. ala kaweh

Roger Hughston 19 éve
szülő
commit
b03a063028

+ 52 - 10
panda/src/osxdisplay/osxGraphicsWindow.cxx

@@ -1360,10 +1360,26 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground)
 //               may fail if the mouse is not currently within the
 //               may fail if the mouse is not currently within the
 //               window, or if the API doesn't support this operation.
 //               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)
 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..
   // 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
 	// icons
 	if(properties.has_icon_filename())
 	if(properties.has_icon_filename())
@@ -1569,5 +1597,19 @@ void osxGraphicsWindow::set_properties_now(WindowProperties &properties)
 
 
 	return;
 	return;
 }
 }
-
+//////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+
+void osxGraphicsWindow::LocalPointToSystemPoint(Point &qdLocalPoint) 
+ { 
+   if(_osx_window != NULL) 
+   { 
+      GrafPtr savePort;    
+      GetPort( &savePort ); 
+      SetPortWindowPort(_osx_window ); 
+      LocalToGlobal( &qdLocalPoint ); 
+      SetPort( savePort ); 
+   } 
+                
+ }; 
 
 

+ 1 - 1
panda/src/osxdisplay/osxGraphicsWindow.h

@@ -92,7 +92,7 @@ public: // do not call direct ..
   void SystemCloseWindow();	
   void SystemCloseWindow();	
   void SystemSetWindowForground(bool forground);	
   void SystemSetWindowForground(bool forground);	
   void SystemPointToLocalPoint(Point &qdGlobalPoint);
   void SystemPointToLocalPoint(Point &qdGlobalPoint);
-
+  void LocalPointToSystemPoint(Point &qdLocalPoint);
   AGLContext  get_ggs_context(void);
   AGLContext  get_ggs_context(void);
   AGLContext  get_context(void);
   AGLContext  get_context(void);
   OSStatus	  buildGL(bool full_screen);
   OSStatus	  buildGL(bool full_screen);