mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Don't coalesce scroll wheel events
Since the backend now pops off all input events at once whenever it tends to the run-loop, it is no longer necessary to coalesce scroll wheel events. In fact, without coalescing the scroll wheel (or track pad) feels a lot smoother.
This commit is contained in:
@@ -30,7 +30,6 @@ enum {
|
||||
BOOL isAutoscrolling;
|
||||
int mouseShape;
|
||||
NSTrackingRectTag trackingRectTag;
|
||||
float scrollWheelAccumulator;
|
||||
}
|
||||
|
||||
- (void)setTextView:(id)view;
|
||||
|
||||
@@ -33,10 +33,6 @@ static NSTimeInterval MMDragTimerMinInterval = 0.01;
|
||||
// The number of pixels in which the drag timer interval changes
|
||||
static float MMDragAreaSize = 73.0f;
|
||||
|
||||
// Number of seconds to delay before sending scroll wheel events. (A delay of
|
||||
// 0.05 seconds equals an update frequency of 20 Hz.)
|
||||
static NSTimeInterval MMScrollWheelDelay = 0.05;
|
||||
|
||||
|
||||
@interface MMTextViewHelper (Private)
|
||||
- (MMWindowController *)windowController;
|
||||
@@ -48,7 +44,6 @@ static NSTimeInterval MMScrollWheelDelay = 0.05;
|
||||
- (void)dragTimerFired:(NSTimer *)timer;
|
||||
- (void)setCursor;
|
||||
- (NSRect)trackingRect;
|
||||
- (void)handleScrollWheelEvent:(id)event;
|
||||
@end
|
||||
|
||||
|
||||
@@ -271,16 +266,20 @@ static NSTimeInterval MMScrollWheelDelay = 0.05;
|
||||
if ([event deltaY] == 0)
|
||||
return;
|
||||
|
||||
// Don't send the event straight away because lots of these events may be
|
||||
// received in rapid succession. Instead, accumulate the events and send
|
||||
// off the scroll total at a predetermined maximum rate. This avoids
|
||||
// clogging up the DO messaging system on faster machines.
|
||||
if (0 == scrollWheelAccumulator)
|
||||
[self performSelector:@selector(handleScrollWheelEvent:)
|
||||
withObject:event
|
||||
afterDelay:MMScrollWheelDelay];
|
||||
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];
|
||||
|
||||
scrollWheelAccumulator += [event deltaY];
|
||||
[data appendBytes:&row length:sizeof(int)];
|
||||
[data appendBytes:&col length:sizeof(int)];
|
||||
[data appendBytes:&flags length:sizeof(int)];
|
||||
[data appendBytes:&dy length:sizeof(float)];
|
||||
|
||||
[[self vimController] sendMessage:ScrollWheelMsgID data:data];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mouseDown:(NSEvent *)event
|
||||
@@ -713,26 +712,4 @@ static NSTimeInterval MMScrollWheelDelay = 0.05;
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (void)handleScrollWheelEvent:(id)event
|
||||
{
|
||||
if (0 == scrollWheelAccumulator)
|
||||
return;
|
||||
|
||||
int row, col;
|
||||
NSPoint pt = [textView convertPoint:[event locationInWindow] fromView:nil];
|
||||
if ([textView convertPoint:pt toRow:&row column:&col]) {
|
||||
int flags = [event modifierFlags];
|
||||
NSMutableData *data = [NSMutableData data];
|
||||
|
||||
[data appendBytes:&row length:sizeof(int)];
|
||||
[data appendBytes:&col length:sizeof(int)];
|
||||
[data appendBytes:&flags length:sizeof(int)];
|
||||
[data appendBytes:&scrollWheelAccumulator length:sizeof(float)];
|
||||
|
||||
[[self vimController] sendMessage:ScrollWheelMsgID data:data];
|
||||
}
|
||||
|
||||
scrollWheelAccumulator = 0;
|
||||
}
|
||||
|
||||
@end // MMTextViewHelper (Private)
|
||||
|
||||
Reference in New Issue
Block a user