Commit a3005d3d authored by David Fuhrmann's avatar David Fuhrmann

macosx: Reset scrolling direction with timer, decrease timeout

Reset the fixed scrolling direction with a timer and decrease
timeout to 0.4 seconds. This makes switching between horizontal
scrolling and vertical scrolling a bit easier.
parent 3eb0885f
......@@ -47,8 +47,8 @@
*****************************************************************************/
@interface VLCVoutView()
{
NSTimer *p_scrollTimer;
NSInteger i_lastScrollWheelDirection;
NSTimeInterval t_lastScrollEvent;
CGFloat f_cumulatedXScrollValue;
CGFloat f_cumulatedYScrollValue;
......@@ -230,11 +230,9 @@
- (void)resetScrollWheelDirection
{
/* release the scroll direction 0.8 secs after the last event */
if (([NSDate timeIntervalSinceReferenceDate] - t_lastScrollEvent) >= 0.80) {
i_lastScrollWheelDirection = 0;
f_cumulatedXScrollValue = f_cumulatedYScrollValue = 0.;
}
i_lastScrollWheelDirection = 0;
f_cumulatedXScrollValue = f_cumulatedYScrollValue = 0.;
msg_Dbg(getIntf(), "Reset scrolling timer");
}
- (void)scrollWheel:(NSEvent *)theEvent
......@@ -266,7 +264,7 @@
/* in the following, we're forwarding either a x or a y event */
/* Multiple key events are send depending on the intensity of the event */
/* the opposite direction is being blocked for 0.8 secs */
/* the opposite direction is being blocked for a couple of milli seconds */
if (f_deltaYAbs > f_directionThreshold) {
if (i_lastScrollWheelDirection < 0) // last was a X
return;
......@@ -281,13 +279,7 @@
msg_Dbg(p_intf, "Scrolling in y direction");
}
t_lastScrollEvent = [NSDate timeIntervalSinceReferenceDate];
[self performSelector:@selector(resetScrollWheelDirection)
withObject: NULL
afterDelay:1.00];
return;
}
if (f_deltaXAbs > f_directionThreshold) {
} else if (f_deltaXAbs > f_directionThreshold) {
if (i_lastScrollWheelDirection > 0) // last was a Y
return;
i_lastScrollWheelDirection = -1; // X
......@@ -300,12 +292,13 @@
var_SetInteger(p_intf->obj.libvlc, "key-pressed", key);
msg_Dbg(p_intf, "Scrolling in x direction");
}
}
t_lastScrollEvent = [NSDate timeIntervalSinceReferenceDate];
[self performSelector:@selector(resetScrollWheelDirection)
withObject: NULL
afterDelay:1.00];
if (p_scrollTimer) {
[p_scrollTimer invalidate];
p_scrollTimer = nil;
}
p_scrollTimer = [NSTimer scheduledTimerWithTimeInterval:0.4 target:self selector:@selector(resetScrollWheelDirection) userInfo:nil repeats:NO];
}
#pragma mark -
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment