diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2013-07-25 19:49:49 +0200 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2013-08-13 23:05:46 +0200 |
commit | 04cdc205bc4972fff81b32f8d61216d0b13ccc69 (patch) | |
tree | 7178a759f008e2f475d8e79a8e15427ff7225039 /video/out | |
parent | 11dad6d44b7e969f32f00379cea514101a46a0ac (diff) | |
download | mpv-04cdc205bc4972fff81b32f8d61216d0b13ccc69.tar.bz2 mpv-04cdc205bc4972fff81b32f8d61216d0b13ccc69.tar.xz |
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.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/cocoa_common.m | 27 |
1 files 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]); |