gtkmenu: ignore emulated scroll events

On X11, we get both smooth and emulated scroll events, whereas other
backends such as wayland will give smooth events only with touchpad
scrolling.

Discard emulated scroll events so that we get consistent behaviours
between backends.

Allow for both horizontal and vertical smooth events for scrolling so
that horizontal scrolling still works without emulated scroll events as
well, again for consistency between gdk backends.

https://bugzilla.gnome.org/show_bug.cgi?id=765939
This commit is contained in:
Olivier Fourdan 2016-05-03 16:44:14 +02:00
parent e405c27eee
commit c134d52dd7

View File

@ -105,6 +105,8 @@
#include <gobject/gvaluecollector.h>
#include <gdk/gdkprivate.h> /* for _gdk_event_get_pointer_emulated() */
#include "gtkaccellabel.h"
#include "gtkaccelmap.h"
#include "gtkadjustment.h"
@ -3554,6 +3556,9 @@ gtk_menu_scroll (GtkWidget *widget,
{
GtkMenu *menu = GTK_MENU (widget);
if (_gdk_event_get_pointer_emulated ((GdkEvent *) event))
return FALSE;
switch (event->direction)
{
case GDK_SCROLL_RIGHT:
@ -3565,7 +3570,7 @@ gtk_menu_scroll (GtkWidget *widget,
gtk_menu_scroll_by (menu, - MENU_SCROLL_STEP2);
break;
case GDK_SCROLL_SMOOTH:
gtk_menu_scroll_by (menu, event->delta_y);
gtk_menu_scroll_by (menu, event->delta_y * MENU_SCROLL_STEP2);
break;
}