gtk: fill in missing case in scroll_event().

If gdk_event_get_scroll_deltas() return failure for a given
GdkEventScroll, it doesn't follow that that event has no usable
scrolling action in it at all. The fallback is to call
gdk_event_get_scroll_direction() instead, which is less precise but
still gives _something_ you can use. So in that situation, instead of
just returning false, we can fall through to the handling we use for
pre-GTK3 scroll events (which are always imprecise).

In particular, I've noticed recently that if you run GTK 3 PuTTY in
the virtual X display created by vnc4server, and connect to it using
xtightvncviewer, then scroll-wheel actions passed through from the VNC
client will cause scroll_event() to receive low-res GdkEventScroll
structures of exactly this kind. So scroll-wheel activity on the
terminal window wasn't causing a scroll in that environment, and with
this patch, it does.
This commit is contained in:
Simon Tatham 2020-04-03 17:56:30 +01:00
Родитель e4b6a7efd2
Коммит 0fd30113f1
1 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -2185,21 +2185,26 @@ gboolean button_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer data)
{
GtkFrontend *inst = (GtkFrontend *)data;
GdkScrollDirection dir;
#if GTK_CHECK_VERSION(3,4,0)
gdouble dx, dy;
if (gdk_event_get_scroll_deltas((GdkEvent *)event, &dx, &dy)) {
return scroll_internal(inst, dy, event->state, event->x, event->y);
} else
} else if (!gdk_event_get_scroll_direction((GdkEvent *)event, &dir)) {
return false;
}
#else
dir = event->direction;
#endif
guint button;
GdkEventButton *event_button;
gboolean ret;
if (event->direction == GDK_SCROLL_UP)
if (dir == GDK_SCROLL_UP)
button = 4;
else if (event->direction == GDK_SCROLL_DOWN)
else if (dir == GDK_SCROLL_DOWN)
button = 5;
else
return false;
@ -2219,7 +2224,6 @@ gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer data)
ret = button_internal(inst, event_button);
gdk_event_free((GdkEvent *)event_button);
return ret;
#endif
}
#endif