Add more momentum scroll phases

This commit is contained in:
Luflosi
2018-12-27 15:12:57 +01:00
parent d0da418e49
commit 7652065134
3 changed files with 18 additions and 9 deletions

View File

@@ -925,10 +925,17 @@ is_ascii_control_char(char x) {
switch([event momentumPhase]) {
case NSEventPhaseBegan:
flags |= (1 << 1); break;
case NSEventPhaseChanged:
case NSEventPhaseStationary:
flags |= (2 << 1); break;
case NSEventPhaseEnded:
case NSEventPhaseChanged:
flags |= (3 << 1); break;
case NSEventPhaseEnded:
flags |= (4 << 1); break;
case NSEventPhaseCancelled:
flags |= (5 << 1); break;
case NSEventPhaseMayBegin:
flags |= (6 << 1); break;
case NSEventPhaseNone:
default:
break;
}

7
glfw/glfw3.h vendored
View File

@@ -1383,9 +1383,10 @@ typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
* @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.
* (flags >> 1) & 7 will have value 1 for the start of momentum scrolling,
* value 2 for stationary momentum scrolling, value 3 for momentum scrolling
* in progress, value 4 for momentum scrolling ended, value 5 for momentum
* scrolling cancelled and value 6 if scrolling may begin soon.
*
* @sa @ref scrolling
* @sa @ref glfwSetScrollCallback

View File

@@ -572,17 +572,18 @@ scroll_event(double UNUSED xoffset, double yoffset, int flags) {
int s;
bool is_high_resolution = flags & 1;
Screen *screen = w->render_data.screen;
enum MomentumData { NoMomentumData, StartMomentumPhase, MomentumPhaseActive, MomentumPhaseEnded };
enum MomentumData momentum_data = (flags >> 1) & 3;
enum MomentumData { NoMomentumData, MomentumPhaseBegan, MomentumPhaseStationary, MomentumPhaseActive, MomentumPhaseEnded, MomentumPhaseCancelled, MomentumPhaseMayBegin };
enum MomentumData momentum_data = (flags >> 1) & 7;
switch(momentum_data) {
case StartMomentumPhase:
case MomentumPhaseBegan:
window_for_momentum_scroll = w->id; break;
case MomentumPhaseActive:
if (window_for_momentum_scroll != w->id) return;
break;
case MomentumPhaseEnded:
window_for_momentum_scroll = 0; break;
case NoMomentumData:
default:
break;
}
if (is_high_resolution) {