From 04cdc205bc4972fff81b32f8d61216d0b13ccc69 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 25 Jul 2013 19:49:49 +0200 Subject: cocoa_common: add precise scrolling support This adds precise scrolling support. I ran some tests and it seems a little bit smoother and well.. precise. The defaults are rebindable using: AXIS_UP, AXIS_DOWN, AXIS_LEFT and AXIS_RIGHT. --- video/out/cocoa_common.m | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 94673d5e94..cc1c51355c 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -869,27 +869,22 @@ int vo_cocoa_cgl_color_size(struct vo *vo) - (void)scrollWheel:(NSEvent *)event { - struct vo_cocoa_state *s = self.videoOutput->cocoa; - + struct vo *vo = self.videoOutput; CGFloat delta; - // Use the dimention with the most delta as the scrolling one - if (FFABS([event deltaY]) > FFABS([event deltaX])) { - delta = [event deltaY]; + int cmd; + + if (FFABS([event deltaY]) >= FFABS([event deltaX])) { + delta = [event deltaY] * 0.1; + cmd = delta > 0 ? MP_AXIS_UP : MP_AXIS_DOWN; + delta = FFABS(delta); } else { - delta = - [event deltaX]; + delta = [event deltaX] * 0.1; + cmd = delta > 0 ? MP_AXIS_RIGHT : MP_AXIS_LEFT; + delta = FFABS(delta); } if ([event hasPreciseScrollingDeltas]) { - s->accumulated_scroll += delta; - static const CGFloat threshold = 10; - while (s->accumulated_scroll >= threshold) { - s->accumulated_scroll -= threshold; - cocoa_put_key_with_modifiers(MP_MOUSE_BTN3, [event modifierFlags]); - } - while (s->accumulated_scroll <= -threshold) { - s->accumulated_scroll += threshold; - cocoa_put_key_with_modifiers(MP_MOUSE_BTN4, [event modifierFlags]); - } + mp_input_put_axis(vo->input_ctx, cmd, delta); } else { if (delta > 0) cocoa_put_key_with_modifiers(MP_MOUSE_BTN3, [event modifierFlags]); -- cgit v1.2.3