mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-05-28 00:21:57 +02:00
Send horizontal trackpad events on to Vim
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user