Skip to content

Commit 32f7f8d

Browse files
committed
Remove unneeded axis event timestamp
1 parent e825005 commit 32f7f8d

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

glfw/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ void _glfwPlatformRemoveTimer(unsigned long long timer_id);
885885
int _glfwPlatformSetWindowBlur(_GLFWwindow* handle, int value);
886886
MonitorGeometry _glfwPlatformGetMonitorGeometry(_GLFWmonitor* monitor);
887887
bool _glfwPlatformGrabKeyboard(bool grab);
888-
void glfw_handle_scroll_event_for_momentum(_GLFWwindow *w, const GLFWScrollEvent *ev, monotonic_t timestamp, bool stopped, bool is_finger_based);
888+
void glfw_handle_scroll_event_for_momentum(_GLFWwindow *w, const GLFWScrollEvent *ev, bool stopped, bool is_finger_based);
889889

890890
char* _glfw_strdup(const char* source);
891891

glfw/momentum-scroll.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
typedef struct ScrollSample {
1212
double dx, dy;
13-
monotonic_t timestamp, local_timestamp;
13+
monotonic_t timestamp;
1414
} ScrollSample;
1515

1616
#define DEQUE_DATA_TYPE ScrollSample
@@ -59,8 +59,8 @@ cancel_existing_scroll(void) {
5959
}
6060

6161
static void
62-
add_sample(double dx, double dy, monotonic_t timestamp) {
63-
deque_push_back(&s.samples, (ScrollSample){dx, dy, timestamp, monotonic()}, NULL);
62+
add_sample(double dx, double dy) {
63+
deque_push_back(&s.samples, (ScrollSample){dx, dy, monotonic()}, NULL);
6464
}
6565

6666
static void
@@ -73,7 +73,7 @@ last_sample_delta(double *dx, double *dy) {
7373
static void
7474
trim_old_samples(monotonic_t now) {
7575
const ScrollSample *ss;
76-
while ((ss = deque_peek_front(&s.samples)) && (now - ss->local_timestamp) > ms_to_monotonic_t(150))
76+
while ((ss = deque_peek_front(&s.samples)) && (now - ss->timestamp) > ms_to_monotonic_t(150))
7777
deque_pop_front(&s.samples, NULL);
7878
}
7979

@@ -102,12 +102,12 @@ set_velocity_from_samples(void) {
102102

103103
// Use weighted average - more recent samples have higher weight
104104
double total_dx = 0.0, total_dy = 0.0, total_weight = 0.0;
105-
monotonic_t first_time = deque_peek_front(&s.samples)->local_timestamp;
106-
monotonic_t last_time = deque_peek_back(&s.samples)->local_timestamp;
105+
monotonic_t first_time = deque_peek_front(&s.samples)->timestamp;
106+
monotonic_t last_time = deque_peek_back(&s.samples)->timestamp;
107107
double time_span = MAX(1, last_time - first_time);
108108
for (size_t i = 0; i < deque_size(&s.samples); i++) {
109109
const ScrollSample *ss = deque_at(&s.samples, i);
110-
double weight = 1.0 + (ss->local_timestamp - first_time) / time_span;
110+
double weight = 1.0 + (ss->timestamp - first_time) / time_span;
111111
total_dx += ss->dx * weight; total_dy += ss->dy * weight;
112112
total_weight += weight;
113113
}
@@ -154,7 +154,7 @@ start_momentum_scroll(void) {
154154

155155
void
156156
glfw_handle_scroll_event_for_momentum(
157-
_GLFWwindow *w, const GLFWScrollEvent *ev, monotonic_t timestamp, bool stopped, bool is_finger_based
157+
_GLFWwindow *w, const GLFWScrollEvent *ev, bool stopped, bool is_finger_based
158158
) {
159159
if (!w || (w->id != s.window_id && s.window_id) || s.state != PHYSICAL_EVENT_IN_PROGRESS) cancel_existing_scroll();
160160
if (!w) return;
@@ -167,7 +167,7 @@ glfw_handle_scroll_event_for_momentum(
167167
s.window_id = w->id;
168168
s.keyboard_modifiers = ev->keyboard_modifiers;
169169
if (is_finger_based) {
170-
add_sample(ev->x_offset, ev->y_offset, timestamp);
170+
add_sample(ev->x_offset, ev->y_offset);
171171
s.state = stopped ? MOMENTUM_IN_PROGRESS : PHYSICAL_EVENT_IN_PROGRESS;
172172
} else {
173173
s.state = stopped ? NONE : PHYSICAL_EVENT_IN_PROGRESS;

glfw/wl_init.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,7 @@ pointer_handle_frame(void *data UNUSED, struct wl_pointer *pointer UNUSED) {
225225
ev.x_offset *= scale; ev.y_offset *= scale;
226226
ev.x_offset *= -1;
227227
glfw_handle_scroll_event_for_momentum(
228-
window, &ev, MAX(info.y_start_time, info.x_start_time), info.y_stop_received || info.x_stop_received,
229-
info.source_type == WL_POINTER_AXIS_SOURCE_FINGER);
228+
window, &ev, info.y_stop_received || info.x_stop_received, info.source_type == WL_POINTER_AXIS_SOURCE_FINGER);
230229
/* clear pointer_curr_axis_info for next frame */
231230
memset(&info, 0, sizeof(info));
232231
}

0 commit comments

Comments
 (0)