Browse Source

fix mouse jumping in osx firefox

David Rose 15 years ago
parent
commit
ee9d22148e
1 changed files with 15 additions and 4 deletions
  1. 15 4
      direct/src/plugin/p3dInstance.cxx

+ 15 - 4
direct/src/plugin/p3dInstance.cxx

@@ -3534,7 +3534,7 @@ handle_event_osx_event_record(const P3D_event_data &event) {
     CGPoint cgpt = { pt.h, pt.v };
     CGPoint cgpt = { pt.h, pt.v };
     HIPointConvert(&cgpt, kHICoordSpaceScreenPixel, NULL,
     HIPointConvert(&cgpt, kHICoordSpaceScreenPixel, NULL,
                    kHICoordSpaceWindow, window);
                    kHICoordSpaceWindow, window);
-
+    
     // Then convert to plugin coordinates.
     // Then convert to plugin coordinates.
     pt.h = (short)(cgpt.x - _wparams.get_win_x());
     pt.h = (short)(cgpt.x - _wparams.get_win_x());
     pt.v = (short)(cgpt.y - _wparams.get_win_y());
     pt.v = (short)(cgpt.y - _wparams.get_win_y());
@@ -3547,6 +3547,8 @@ handle_event_osx_event_record(const P3D_event_data &event) {
   swb_event._flags = 0;
   swb_event._flags = 0;
   add_carbon_modifier_flags(swb_event._flags, er->modifiers);
   add_carbon_modifier_flags(swb_event._flags, er->modifiers);
 
 
+  bool trust_mouse_data = true;
+
   switch (er->what) {
   switch (er->what) {
   case mouseDown:
   case mouseDown:
     swb_event._source = SubprocessWindowBuffer::ES_mouse;
     swb_event._source = SubprocessWindowBuffer::ES_mouse;
@@ -3586,14 +3588,23 @@ handle_event_osx_event_record(const P3D_event_data &event) {
     _mouse_active = ((er->modifiers & 1) != 0);
     _mouse_active = ((er->modifiers & 1) != 0);
     break;
     break;
 
 
+  case osEvt:
+    // The mouse data sent with an "os event" seems to be in an
+    // indeterminate space.
+    trust_mouse_data = false;
+    break;
+
   default:
   default:
     break;
     break;
   }
   }
 
 
   if (_mouse_active) {
   if (_mouse_active) {
-    swb_event._x = pt.h;
-    swb_event._y = pt.v;
-    swb_event._flags |= SubprocessWindowBuffer::EF_mouse_position | SubprocessWindowBuffer::EF_has_mouse;
+    swb_event._flags |= SubprocessWindowBuffer::EF_has_mouse;
+    if (trust_mouse_data) {
+      swb_event._x = pt.h;
+      swb_event._y = pt.v;
+      swb_event._flags |= SubprocessWindowBuffer::EF_mouse_position;
+    }
   }
   }
 
 
   if (_swbuffer != NULL) {
   if (_swbuffer != NULL) {