private void SetCursorVisible(bool visible) { // If the mouse is outside the window and we want to hide it, // move it inside the window first. // Otherwise, if we are making the cursor visible again, // we place it in the same spot as reported in the current // MouseState to avoid sudden jumps. if (!visible && !Bounds.Contains(new Point(MouseState.X, MouseState.Y))) { Mouse.SetPosition( (Bounds.Left + Bounds.Right) / 2, (Bounds.Top + Bounds.Bottom) / 2); } else if (visible) { var p = PointToScreen(new Point(MouseState.X, MouseState.Y)); Mouse.SetPosition((int)p.X, (int)p.Y); } CG.AssociateMouseAndMouseCursorPosition(visible); Cocoa.SendVoid(NSCursor, visible ? selUnhide : selHide); }