summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2005-11-04 10:24:42 +0000
committerMatthias Melcher <fltk@matthiasm.com>2005-11-04 10:24:42 +0000
commitcd433ac67a0416d26815222bc8066f81c83b3170 (patch)
tree3ed4cca8948bd1008060d9214b16eee70b2a0a8d /src
parentb1d3eae6f25effbdb505e66e21523cd080a3a766 (diff)
STR #1060: first attempt at fixing the dreaded MightyMouse issue on OS X.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4636 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_mac.cxx23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx
index 00725fd6a..1b296e12f 100644
--- a/src/Fl_mac.cxx
+++ b/src/Fl_mac.cxx
@@ -606,6 +606,7 @@ static double do_queued_events( double time = 0.0 )
{ kEventClassMouse, kEventMouseDown },
{ kEventClassMouse, kEventMouseUp },
{ kEventClassMouse, kEventMouseMoved },
+ { kEventClassMouse, 11 }, // MightyMouse wheels
{ kEventClassMouse, kEventMouseWheelMoved },
{ kEventClassMouse, kEventMouseDragged },
{ kEventClassFLTK, kEventFLTKBreakLoop },
@@ -792,13 +793,26 @@ static pascal OSStatus carbonWindowHandler( EventHandlerCallRef nextHandler, Eve
* Carbon Mousewheel handler
* This needs to be linked into all new window event handlers
*/
-static pascal OSStatus carbonMousewheelHandler( EventHandlerCallRef nextHandler, EventRef event, void *userData )
+static pascal OSStatus carbonMousewheelHandler( EventHandlerCallRef nextHandler, EventRef ev, void *userData )
{
- Fl_Window *window = (Fl_Window*)userData;
- EventMouseWheelAxis axis;
+ // Handle the new "MightyMouse" mouse wheel events. Please, someone explaint ot me
+ // why Apple changed the API on this even though the current API supports two wheels
+ // just fine. Matthias,
+ EventRef event;
+ if (GetEventKind(event)==11) {
+ // if this is a "MightyMouse" event, we need to convert it into a regulare MouseWheel event
+ GetEventParameter( ev, kEventParamEventRef, typeEventRef, NULL, sizeof( EventRef ), NULL, &event );
+ } else {
+ // otherwise, we simply copy the event (can we safely do that?)
+ event = ev;
+ }
fl_lock_function();
+ fl_os_event = event;
+ Fl_Window *window = (Fl_Window*)userData;
+
+ EventMouseWheelAxis axis;
GetEventParameter( event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(EventMouseWheelAxis), NULL, &axis );
long delta;
GetEventParameter( event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(long), NULL, &delta );
@@ -1767,8 +1781,9 @@ void Fl_X::make(Fl_Window* w)
OSStatus ret;
EventHandlerUPP mousewheelHandler = NewEventHandlerUPP( carbonMousewheelHandler ); // will not be disposed by Carbon...
static EventTypeSpec mousewheelEvents[] = {
+ { kEventClassMouse, 11 } // "11" is the yet unlabled "MightyMouse" wheel event - sigh!
{ kEventClassMouse, kEventMouseWheelMoved } };
- ret = InstallWindowEventHandler( x->xid, mousewheelHandler, 1, mousewheelEvents, w, 0L );
+ ret = InstallWindowEventHandler( x->xid, mousewheelHandler, 2, mousewheelEvents, w, 0L );
EventHandlerUPP mouseHandler = NewEventHandlerUPP( carbonMouseHandler ); // will not be disposed by Carbon...
static EventTypeSpec mouseEvents[] = {
{ kEventClassMouse, kEventMouseDown },