From ff27fbf6958d722905cac3fe3faf8dad6fb3414e Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Mon, 28 Jun 2010 23:50:19 +0200 Subject: [PATCH] Send horizontal trackpad events on to Vim --- src/MacVim/MMBackend.m | 8 ++++++-- src/MacVim/MMTextViewHelper.m | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index 2ca9314c09..1d43740e73 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -1829,13 +1829,17 @@ static void netbeansReadCallback(CFSocketRef s, int col = *((int*)bytes); bytes += sizeof(int); int flags = *((int*)bytes); bytes += sizeof(int); float dy = *((float*)bytes); bytes += sizeof(float); + float dx = *((float*)bytes); bytes += sizeof(float); int button = MOUSE_5; - if (dy > 0) button = MOUSE_4; + if (dy < 0) button = MOUSE_5; + else if (dy > 0) button = MOUSE_4; + else if (dx < 0) button = MOUSE_6; + else if (dx > 0) button = MOUSE_7; flags = eventModifierFlagsToVimMouseModMask(flags); - int numLines = (int)round(dy); + int numLines = (dy != 0) ? (int)round(dy) : (int)round(dx); if (numLines < 0) numLines = -numLines; if (numLines == 0) numLines = 1; diff --git a/src/MacVim/MMTextViewHelper.m b/src/MacVim/MMTextViewHelper.m index 95b86b3a59..630a50f333 100644 --- a/src/MacVim/MMTextViewHelper.m +++ b/src/MacVim/MMTextViewHelper.m @@ -332,20 +332,22 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b) [[NSInputManager currentInputManager] markedTextAbandoned:self]; } - if ([event deltaY] == 0) + float dx = [event deltaX]; + float dy = [event deltaY]; + if (dx == 0 && dy == 0) return; int row, col; NSPoint pt = [textView convertPoint:[event locationInWindow] fromView:nil]; if ([textView convertPoint:pt toRow:&row column:&col]) { int flags = [event modifierFlags]; - float dy = [event deltaY]; NSMutableData *data = [NSMutableData data]; [data appendBytes:&row length:sizeof(int)]; [data appendBytes:&col length:sizeof(int)]; [data appendBytes:&flags length:sizeof(int)]; [data appendBytes:&dy length:sizeof(float)]; + [data appendBytes:&dx length:sizeof(float)]; [[self vimController] sendMessage:ScrollWheelMsgID data:data]; }