mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
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.
(cherry picked from commit 0fd30113f1
)
This commit is contained in:
parent
9331bb3c57
commit
b267f35cf7
@ -2182,21 +2182,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;
|
||||
@ -2216,7 +2221,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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user