From fc5e74e45707b78da3c57c9389d5f4f64fbcda7f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 26 Dec 2018 11:03:36 +0530 Subject: [PATCH] Report momentum scrolling status of scroll events on cocoa --- glfw/cocoa_window.m | 11 +++++++++++ glfw/glfw3.h | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 5106586a3..95ef935d4 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -923,6 +923,17 @@ is_ascii_control_char(char x) { if (yscale > 0) deltaY *= yscale; } + switch([event momentumPhase]) { + case NSEventPhaseBegan: + flags |= (1 << 1); break; + case NSEventPhaseChanged: + flags |= (2 << 1); break; + case NSEventPhaseEnded: + flags |= (3 << 1); break; + default: + break; + } + if (fabs(deltaX) > 0.0 || fabs(deltaY) > 0.0) _glfwInputScroll(window, deltaX, deltaY, flags); } diff --git a/glfw/glfw3.h b/glfw/glfw3.h index 9bb691bdd..741cd8f83 100644 --- a/glfw/glfw3.h +++ b/glfw/glfw3.h @@ -1380,7 +1380,12 @@ typedef void (* GLFWcursorenterfun)(GLFWwindow*,int); * @param[in] window The window that received the event. * @param[in] xoffset The scroll offset along the x-axis. * @param[in] yoffset The scroll offset along the y-axis. - * @param[in] flags A bit-mask providing extra data about the event. flags & 1 will be true if and only if the offset values are "high-precision". Typically pixel values. Otherwise the offset values are number of lines. + * @param[in] flags A bit-mask providing extra data about the event. + * flags & 1 will be true if and only if the offset values are "high-precision". + * Typically pixel values. Otherwise the offset values are number of lines. + * (flags >> 1) & 3 will have value 1 for start of momentum scrolling, + * value 2 for momentum scrolling in progress and value 3 for momentum + * scrolling ended. * * @sa @ref scrolling * @sa @ref glfwSetScrollCallback