Merge pull request #381 from macvim-dev/fix/scroll

Fix scroll on 10.12
This commit is contained in:
Kazuki Sakamoto
2016-10-13 21:36:25 -07:00
committed by GitHub
2 changed files with 34 additions and 5 deletions
+2
View File
@@ -35,6 +35,8 @@
NSMutableDictionary *signImages;
BOOL useMouseTime;
NSDate *mouseDownTime;
CGFloat scrollingDeltaX;
CGFloat scrollingDeltaY;
// Input Manager
NSRange imRange;
+32 -5
View File
@@ -280,6 +280,38 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
- (void)scrollWheel:(NSEvent *)event
{
float dx = 0;
float dy = 0;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
if ([event hasPreciseScrollingDeltas]) {
NSSize cellSize = [textView cellSize];
float thresholdX = cellSize.width;
float thresholdY = cellSize.height;
scrollingDeltaX += [event scrollingDeltaX];
if (fabs(scrollingDeltaX) > thresholdX) {
dx = roundf(scrollingDeltaX / thresholdX);
scrollingDeltaX -= thresholdX * dx;
}
scrollingDeltaY += [event scrollingDeltaY];
if (fabs(scrollingDeltaY) > thresholdY) {
dy = roundf(scrollingDeltaY / thresholdY);
scrollingDeltaY -= thresholdY * dy;
}
} else {
scrollingDeltaX = 0;
scrollingDeltaY = 0;
dx = [event scrollingDeltaX];
dy = [event scrollingDeltaY];
}
#else
dx = [event deltaX];
dy = [event deltaY];
#endif
if (dx == 0 && dy == 0)
return;
if ([self hasMarkedText]) {
// We must clear the marked text since the cursor may move if the
// marked text moves outside the view as a result of scrolling.
@@ -288,11 +320,6 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
[[NSTextInputContext currentInputContext] discardMarkedText];
}
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]) {