[gtk/scroll-compression] Address review comments
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/scroll-compression] Address review comments
- Date: Tue, 9 Jun 2020 18:14:30 +0000 (UTC)
commit 4317c008f00da720b52e24573b1bd717270dd423
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jun 9 14:13:22 2020 -0400
Address review comments
We were casting scroll events to motion events
rather carelessly. Don't do that.
gdk/gdkevents.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index e67f5b66cb..b3e379ebe2 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -2912,21 +2912,32 @@ GdkTimeCoord *
gdk_event_get_history (GdkEvent *event,
guint *out_n_coords)
{
- GdkMotionEvent *self = (GdkMotionEvent *) event;
+ GArray *history;
g_return_val_if_fail (GDK_IS_EVENT (event), NULL);
g_return_val_if_fail (GDK_IS_EVENT_TYPE (event, GDK_MOTION_NOTIFY) ||
GDK_IS_EVENT_TYPE (event, GDK_SCROLL), NULL);
g_return_val_if_fail (out_n_coords != NULL, NULL);
- if (self->history && self->history->len > 0)
+ if (GDK_IS_EVENT_TYPE (event, GDK_MOTION_NOTIFY))
+ {
+ GdkMotionEvent *self = (GdkMotionEvent *) event;
+ history = self->history;
+ }
+ else
+ {
+ GdkScrollEvent *self = (GdkScrollEvent *) event;
+ history = self->history;
+ }
+
+ if (history && history->len > 0)
{
GdkTimeCoord *result;
- *out_n_coords = self->history->len;
+ *out_n_coords = history->len;
- result = g_malloc (sizeof (GdkTimeCoord) * self->history->len);
- memcpy (result, self->history->data, sizeof (GdkTimeCoord) * self->history->len);
+ result = g_malloc (sizeof (GdkTimeCoord) * history->len);
+ memcpy (result, history->data, sizeof (GdkTimeCoord) * history->len);
return result;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]