Loading ...
Sorry, an error occurred while loading the content.
 

Re: experimental mouse wheel patch

Expand Messages
  • Eckehard Berns
    ... I fixed an issue with split windows. This patch is diffed against 6.2.214. diff -cr ../vim62.214/src/gui_mac.c ./src/gui_mac.c ... *************** ... #
    Message 1 of 2 , Jan 30, 2004
      > I have tried to make the mouse wheel work natively (e.g. without
      > USB overdrive) in Vim for Mac OS X.

      I fixed an issue with split windows. This patch is diffed against
      6.2.214.

      diff -cr ../vim62.214/src/gui_mac.c ./src/gui_mac.c
      *** ../vim62.214/src/gui_mac.c Mon Jan 26 18:16:14 2004
      --- ./src/gui_mac.c Fri Jan 30 20:37:36 2004
      ***************
      *** 82,87 ****
      --- 82,98 ----
      # endif
      #endif

      + #undef USE_MOUSEWHEEL
      + #if defined(MACOS_X) && defined(USE_CARBONIZED)
      + # define USE_MOUSEWHEEL
      + /* TODO: do we need to free these resources later? Where? */
      + static EventHandlerUPP mouseWheelHandlerUPP;
      + static EventHandlerRef mouseWheelHandlerRef;
      + /* TODO: do we need to break out of the WaitNewEventWrp loop or is the
      + * bogus event enough to update the window instantly? */
      + static int had_mouse_wheel = 0;
      + #endif
      +
      /* Debugging feature: start Vim window OFFSETed */
      #undef USE_OFFSETED_WINDOW

      ***************
      *** 2231,2236 ****
      --- 2242,2321 ----
      (MOUSE_RELEASE, thePoint.h, thePoint.v, FALSE, vimModifiers);
      }

      + #ifdef USE_MOUSEWHEEL
      + static pascal OSStatus
      + gui_mac_mouse_wheel(EventHandlerCallRef nextHandler, EventRef theEvent,
      + void *data)
      + {
      + EventRef bogusEvent;
      + Point point;
      + Rect bounds;
      + UInt32 mod;
      + SInt32 delta;
      + int_u vim_mod;
      +
      + /*
      + * TODO: can that ever happen? In theory allow_scrollbar is TRUE
      + * throughout the WaitNextEvent loop and the callback could only
      + * happen when the application called WaitNextEvent first
      + */
      + if (!allow_scrollbar)
      + goto bail;
      +
      + if (noErr != GetEventParameter(theEvent, kEventParamMouseWheelDelta,
      + typeSInt32, NULL, sizeof(SInt32), NULL, &delta))
      + goto bail;
      +
      + if (noErr != GetEventParameter(theEvent, kEventParamMouseLocation,
      + typeQDPoint, NULL, sizeof(Point), NULL, &point))
      + goto bail;
      +
      + if (noErr != GetEventParameter(theEvent, kEventParamKeyModifiers,
      + typeUInt32, NULL, sizeof(UInt32), NULL, &mod))
      + goto bail;
      +
      + vim_mod = 0;
      + if (mod & shiftKey)
      + vim_mod |= MOUSE_SHIFT;
      + if (mod & controlKey)
      + vim_mod |= MOUSE_CTRL;
      + if (mod & optionKey)
      + vim_mod |= MOUSE_ALT;
      +
      + if (noErr != CreateEvent(NULL, kEventClassMouse, kEventMouseMoved, 0,
      + kEventAttributeNone, &bogusEvent))
      + goto bail;
      + if (noErr != PostEventToQueue(GetMainEventQueue(), bogusEvent,
      + kEventPriorityLow))
      + goto bail;
      +
      + if (noErr == GetWindowBounds(gui.VimWindow, kWindowContentRgn, &bounds)) {
      + point.h -= bounds.left;
      + point.v -= bounds.top;
      + }
      +
      + gui_send_mouse_event((delta > 0) ? MOUSE_4 : MOUSE_5,
      + point.h, point.v, FALSE, vim_mod);
      + /*
      + * TODO: do I need to send the MOUSE_RELEASE after a MOUSE_4 event?
      + * And if so, will the bogus mUp event cause this MOUSE_RELEASE for me?
      + */
      + /* gui_send_mouse_event(MOUSE_RELEASE, point.h, point.v,
      + FALSE, vim_mod); */
      + /* TODO: see definition of had_mouse_wheel */
      + had_mouse_wheel = 1;
      +
      + return noErr;
      +
      + bail:
      + /*
      + * when we fail give any additional callback handler a chance to perform
      + * it's actions
      + */
      + return CallNextEventHandler(nextHandler, theEvent);
      + }
      + #endif /* defined(USE_MOUSEWHEEL) */
      +
      #if 0

      /*
      ***************
      *** 2720,2725 ****
      --- 2805,2813 ----
      #ifdef USE_CTRLCLICKMENU
      long gestalt_rc;
      #endif
      + #ifdef USE_MOUSEWHEEL
      + EventTypeSpec eventTypeSpec;
      + #endif
      #if 1
      InitCursor();

      ***************
      *** 2856,2861 ****
      --- 2944,2967 ----
      vim_setenv((char_u *)"QDTEXT_MINSIZE", (char_u *)"1");
      #endif

      + #ifdef USE_MOUSEWHEEL
      + eventTypeSpec.eventClass = kEventClassMouse;
      + eventTypeSpec.eventKind = kEventMouseWheelMoved;
      + /* TODO: do we need to free these handlers at exit? Where? */
      + mouseWheelHandlerUPP = NewEventHandlerUPP(gui_mac_mouse_wheel);
      + #if 0
      + if (noErr != InstallWindowEventHandler(gui.VimWindow,
      + mouseWheelHandlerUPP, 1, &eventTypeSpec, NULL, &mouseWheelHandlerRef))
      + #else
      + if (noErr != InstallApplicationEventHandler(mouseWheelHandlerUPP, 1,
      + &eventTypeSpec, NULL, &mouseWheelHandlerRef))
      + #endif
      + {
      + mouseWheelHandlerRef = NULL;
      + DisposeEventHandlerUPP(mouseWheelHandlerUPP);
      + }
      + #endif /* defined(USE_MOUSEWHEEL) */
      +
      /* TODO: Load bitmap if using TOOLBAR */
      return OK;
      }
      ***************
      *** 3662,3667 ****
      --- 3768,3780 ----
      return OK;
      }
      }
      + #ifdef USE_MOUSEWHEEL
      + /* is this needed? see definition of had_mouse_wheel */
      + if (had_mouse_wheel) {
      + had_mouse_wheel = 0;
      + break;
      + }
      + #endif
      currentTick = TickCount();
      }
      while ((wtime == -1) || ((currentTick - entryTick) < 60*wtime/1000));

      --
      Eckehard Berns
    Your message has been successfully submitted and would be delivered to recipients shortly.