contribution from kaweh: restore mousewheel support

This commit is contained in:
David Rose 2007-08-03 20:52:48 +00:00
parent fa8630c8bc
commit 9dc252a9ee

View File

@ -1253,6 +1253,7 @@ OSStatus osxGraphicsWindow::handleKeyInput (EventHandlerCallRef myHandler, Event
return noErr; return noErr;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: // Function:
// Access: // Access:
@ -1263,13 +1264,13 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground)
WindowProperties properties; WindowProperties properties;
properties.set_foreground(forground); properties.set_foreground(forground);
system_changed_properties(properties); system_changed_properties(properties);
}; }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: // Function:
// Access: // Access:
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void osxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) void osxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint)
{ {
if(_osx_window != NULL) if(_osx_window != NULL)
@ -1282,8 +1283,7 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground)
if (portChanged) if (portChanged)
QDSwapPort(savePort, NULL); QDSwapPort(savePort, NULL);
} }
}
};
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: // Function:
@ -1300,6 +1300,8 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground)
Point qdGlobalPoint = {0, 0}; Point qdGlobalPoint = {0, 0};
UInt32 modifiers = 0; UInt32 modifiers = 0;
Rect rectPort; Rect rectPort;
SInt32 wheelDelta;
EventMouseWheelAxis wheelAxis;
// cerr <<" Start Mouse Event " << _ID << "\n"; // cerr <<" Start Mouse Event " << _ID << "\n";
@ -1401,11 +1403,27 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground)
result = noErr; result = noErr;
break; break;
//long wheelDelta = 0;
// case kEventMouseWheelMoved: case kEventMouseWheelMoved:
// result = NoErr; GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(wheelDelta), NULL, &wheelDelta);
// GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(long), NULL, &wheelDelta); GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(wheelAxis), NULL, &wheelAxis );
GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
SystemPointToLocalPoint(qdGlobalPoint);
if (wheelAxis == kEventMouseWheelAxisY)
{
_input_devices[0].set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
if (wheelDelta > 0)
{
_input_devices[0].button_down(MouseButton::wheel_up());
result = noErr;
}
else if (wheelDelta < 0)
{
_input_devices[0].button_down(MouseButton::wheel_down());
}
}
result = noErr;
break; break;
} }
// result = noErr; // result = noErr;
@ -1606,7 +1624,9 @@ if (osxdisplay_cat.is_debug())
CGPoint newCursorPosition = {0, 0}; CGPoint newCursorPosition = {0, 0};
newCursorPosition.x = pt.h; newCursorPosition.x = pt.h;
newCursorPosition.y = pt.v; newCursorPosition.y = pt.v;
mouse_mode_relative();
CGWarpMouseCursorPosition(newCursorPosition); CGWarpMouseCursorPosition(newCursorPosition);
mouse_mode_absolute();
} }
return true; return true;
@ -1757,7 +1777,8 @@ void osxGraphicsWindow::set_properties_now(WindowProperties &properties)
return; return;
} }
//////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
void osxGraphicsWindow::LocalPointToSystemPoint(Point &qdLocalPoint) void osxGraphicsWindow::LocalPointToSystemPoint(Point &qdLocalPoint)
@ -1772,7 +1793,7 @@ void osxGraphicsWindow::LocalPointToSystemPoint(Point &qdLocalPoint)
if (portChanged) if (portChanged)
QDSwapPort(savePort, NULL); QDSwapPort(savePort, NULL);
} }
}; }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////