Send horizontal trackpad events on to Vim

This commit is contained in:
Bjorn Winckler
2010-06-28 23:50:19 +02:00
parent 73972981a6
commit ff27fbf695
2 changed files with 10 additions and 4 deletions
+6 -2
View File
@@ -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;
+4 -2
View File
@@ -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];
}