Commit d34619d3 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: lock the scroll direction for 0.8 secs, so the user can scroll through...

macosx: lock the scroll direction for 0.8 secs, so the user can scroll through the movie or adjust the volume without affecting the other function (close #6893)

This is especially needed for the multitouch trackpads
parent 77270b99
...@@ -39,6 +39,9 @@ ...@@ -39,6 +39,9 @@
IBOutlet id o_specificTime_sec_lbl; IBOutlet id o_specificTime_sec_lbl;
IBOutlet id o_specificTime_stepper; IBOutlet id o_specificTime_stepper;
IBOutlet id o_specificTime_mi; IBOutlet id o_specificTime_mi;
NSInteger i_lastScrollWheelDirection;
NSTimeInterval t_lastScrollEvent;
} }
- (IBAction)play:(id)sender; - (IBAction)play:(id)sender;
- (IBAction)stop:(id)sender; - (IBAction)stop:(id)sender;
......
...@@ -54,6 +54,8 @@ ...@@ -54,6 +54,8 @@
[o_specificTime_ok_btn setTitle: _NS("OK")]; [o_specificTime_ok_btn setTitle: _NS("OK")];
[o_specificTime_sec_lbl setStringValue: _NS("sec.")]; [o_specificTime_sec_lbl setStringValue: _NS("sec.")];
[o_specificTime_goTo_lbl setStringValue: _NS("Jump to time")]; [o_specificTime_goTo_lbl setStringValue: _NS("Jump to time")];
i_lastScrollWheelDirection = 0;
} }
...@@ -254,6 +256,13 @@ ...@@ -254,6 +256,13 @@
vlc_object_release( p_input ); vlc_object_release( p_input );
} }
- (void)resetScrollWheelDirection
{
/* release the scroll direction 0.8 secs after the last event */
if (([NSDate timeIntervalSinceReferenceDate] - t_lastScrollEvent) >= 0.80)
i_lastScrollWheelDirection = 0;
}
- (void)scrollWheel:(NSEvent *)theEvent - (void)scrollWheel:(NSEvent *)theEvent
{ {
intf_thread_t * p_intf = VLCIntf; intf_thread_t * p_intf = VLCIntf;
...@@ -271,7 +280,8 @@ ...@@ -271,7 +280,8 @@
CGFloat f_yabsvalue = f_deltaY > 0.0f ? f_deltaY : -f_deltaY; CGFloat f_yabsvalue = f_deltaY > 0.0f ? f_deltaY : -f_deltaY;
CGFloat f_xabsvalue = f_deltaX > 0.0f ? f_deltaX : -f_deltaX; CGFloat f_xabsvalue = f_deltaX > 0.0f ? f_deltaX : -f_deltaX;
int i_yvlckey, i_xvlckey;
int i_yvlckey, i_xvlckey = 0;
if (b_invertedEventFromDevice) if (b_invertedEventFromDevice)
{ {
...@@ -298,15 +308,37 @@ ...@@ -298,15 +308,37 @@
i_xvlckey = KEY_MOUSEWHEELLEFT; i_xvlckey = KEY_MOUSEWHEELLEFT;
} }
/* Send multiple key event, depending on the intensity of the event */ /* 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 */
if (f_yabsvalue > 0.05)
{
if (i_lastScrollWheelDirection < 0) // last was a X
return;
i_lastScrollWheelDirection = 1; // Y
for (NSUInteger i = 0; i < (int)(f_yabsvalue/4.+1.) && f_yabsvalue > 0.05 ; i++) for (NSUInteger i = 0; i < (int)(f_yabsvalue/4.+1.) && f_yabsvalue > 0.05 ; i++)
var_SetInteger( p_intf->p_libvlc, "key-pressed", i_yvlckey ); var_SetInteger( p_intf->p_libvlc, "key-pressed", i_yvlckey );
/* Prioritize Y event (sound volume) over X event */ t_lastScrollEvent = [NSDate timeIntervalSinceReferenceDate];
if (f_yabsvalue < 0.05) [self performSelector:@selector(resetScrollWheelDirection)
withObject: NULL
afterDelay:1.00];
return;
}
if (f_xabsvalue > 0.05)
{ {
if (i_lastScrollWheelDirection > 0) // last was a Y
return;
i_lastScrollWheelDirection = -1; // X
for (NSUInteger i = 0; i < (int)(f_xabsvalue/6.+1.) && f_xabsvalue > 0.05; i++) for (NSUInteger i = 0; i < (int)(f_xabsvalue/6.+1.) && f_xabsvalue > 0.05; i++)
var_SetInteger( p_intf->p_libvlc, "key-pressed", i_xvlckey ); var_SetInteger( p_intf->p_libvlc, "key-pressed", i_xvlckey );
t_lastScrollEvent = [NSDate timeIntervalSinceReferenceDate];
[self performSelector:@selector(resetScrollWheelDirection)
withObject: NULL
afterDelay:1.00];
} }
} }
......
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