From 674685641391ae030f7a22045110873817ceea22 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 3 Oct 2021 08:25:28 +0300 Subject: [PATCH 45/48] gtk4: Avoid gdk_event_get_scroll_direction() Use gdk_scroll_event_get_direction() instead See osdn #42976 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/gtkcompat.c | 12 ++++++++++++ client/gui-gtk-4.0/gtkcompat.h | 1 + client/gui-gtk-4.0/gui_main.c | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/client/gui-gtk-4.0/gtkcompat.c b/client/gui-gtk-4.0/gtkcompat.c index c8234af3cb..7f85f29ad5 100644 --- a/client/gui-gtk-4.0/gtkcompat.c +++ b/client/gui-gtk-4.0/gtkcompat.c @@ -66,4 +66,16 @@ guint gdk_button_event_get_button(GdkEvent *ev) return button; } +/************************************************************************//** + Version of gdk_scroll_event_get_direction() for gtk < 3.98 +****************************************************************************/ +GdkScrollDirection gdk_scroll_event_get_direction(GdkEvent *ev) +{ + GdkScrollDirection direction; + + gdk_event_get_scroll_direction(ev, &direction); + + return direction; +} + #endif /* GTK version < 3.98 */ diff --git a/client/gui-gtk-4.0/gtkcompat.h b/client/gui-gtk-4.0/gtkcompat.h index b269e8cc7a..830d82e07e 100644 --- a/client/gui-gtk-4.0/gtkcompat.h +++ b/client/gui-gtk-4.0/gtkcompat.h @@ -29,6 +29,7 @@ GtkWidget *compat_window_new_wrapper(void); guint gdk_key_event_get_keyval(GdkEvent *ev); GdkModifierType gdk_event_get_modifier_state(GdkEvent *ev); guint gdk_button_event_get_button(GdkEvent *ev); +GdkScrollDirection gdk_scroll_event_get_direction(GdkEvent *ev); #define gdk_event_get_position(_ev_, _x_, _y_) gdk_event_get_coords(_ev_, _x_, _y_) /* Wrap GtkNative away */ diff --git a/client/gui-gtk-4.0/gui_main.c b/client/gui-gtk-4.0/gui_main.c index 878a8ffaa7..8309449c28 100644 --- a/client/gui-gtk-4.0/gui_main.c +++ b/client/gui-gtk-4.0/gui_main.c @@ -709,7 +709,7 @@ static gboolean mouse_scroll_mapcanvas(GtkWidget *w, GdkEvent *ev) get_mapview_scroll_pos(&scroll_x, &scroll_y); get_mapview_scroll_step(&xstep, &ystep); - gdk_event_get_scroll_direction(ev, &direction); + direction = gdk_scroll_event_get_direction(ev); switch (direction) { case GDK_SCROLL_UP: scroll_y -= ystep*2; -- 2.33.0