gtk: let pinches through GTK's own scrolling widgets

So it zooms where the program zooms, and the scrolled window that just
took the wheel doesn't keep it.
This commit is contained in:
Daemonratte 2026-10-18 10:47:07 +02:00
commit d580303374
11 changed files with 52 additions and 1 deletions

View file

@ -3178,6 +3178,11 @@ gtk_calendar_scroll (GtkWidget *widget,
{
GtkCalendar *calendar = GTK_CALENDAR (widget);
/* a pinch on a touchpad (Ctrl with the wheel) is for programs that
* zoom, not for scrolling here */
if (gdk_event_get_touchpad_emulated ((GdkEvent *) event))
return FALSE;
if (event->direction == GDK_SCROLL_UP)
{
if (!gtk_widget_has_focus (widget))

View file

@ -2921,6 +2921,11 @@ gtk_combo_box_scroll_event (GtkWidget *widget,
GtkTreeIter iter;
GtkTreeIter new_iter;
/* a pinch on a touchpad (Ctrl with the wheel) is for programs that
* zoom, not for scrolling here */
if (gdk_event_get_touchpad_emulated ((GdkEvent *) event))
return FALSE;
if (!gtk_combo_box_get_active_iter (combo_box, &iter))
return TRUE;

View file

@ -1913,7 +1913,8 @@ gtk_main_do_event (GdkEvent *event)
break;
case GDK_SCROLL:
if (scroll_latch)
/* a pinch on a touchpad goes where the pointer is, to zoom */
if (scroll_latch && !gdk_event_get_touchpad_emulated (event))
grab_widget = scroll_latch_target (grab_widget, event);
if (scroll_event_wanted (grab_widget, event))
gtk_propagate_event (grab_widget, event);

View file

@ -3513,6 +3513,11 @@ gtk_menu_scroll (GtkWidget *widget,
{
GtkMenu *menu = GTK_MENU (widget);
/* a pinch on a touchpad (Ctrl with the wheel) is for programs that
* zoom, not for scrolling here */
if (gdk_event_get_touchpad_emulated ((GdkEvent *) event))
return FALSE;
switch (event->direction)
{
case GDK_SCROLL_RIGHT:

View file

@ -2618,6 +2618,11 @@ gtk_notebook_scroll (GtkWidget *widget,
GtkWidget *child, *event_widget;
gint i;
/* a pinch on a touchpad (Ctrl with the wheel) is for programs that
* zoom, not for scrolling here */
if (gdk_event_get_touchpad_emulated ((GdkEvent *) event))
return FALSE;
if (!notebook->cur_page)
return FALSE;

View file

@ -994,6 +994,11 @@ gtk_option_menu_scroll_event (GtkWidget *widget,
GList *l;
GtkMenuItem *item;
/* a pinch on a touchpad (Ctrl with the wheel) is for programs that
* zoom, not for scrolling here */
if (gdk_event_get_touchpad_emulated ((GdkEvent *) event))
return FALSE;
index = gtk_option_menu_get_history (option_menu);
if (index != -1)

View file

@ -688,6 +688,11 @@ static gboolean
gtk_path_bar_scroll (GtkWidget *widget,
GdkEventScroll *event)
{
/* a pinch on a touchpad (Ctrl with the wheel) is for programs that
* zoom, not for scrolling here */
if (gdk_event_get_touchpad_emulated ((GdkEvent *) event))
return FALSE;
switch (event->direction)
{
case GDK_SCROLL_RIGHT:

View file

@ -2655,6 +2655,11 @@ gtk_range_scroll_event (GtkWidget *widget,
{
GtkRange *range = GTK_RANGE (widget);
/* a pinch on a touchpad (Ctrl with the wheel) is for programs that
* zoom, not for scrolling here */
if (gdk_event_get_touchpad_emulated ((GdkEvent *) event))
return FALSE;
if (gtk_widget_get_realized (widget))
{
GtkAdjustment *adj = GTK_RANGE (range)->adjustment;

View file

@ -861,6 +861,11 @@ gtk_scale_button_scroll (GtkWidget *widget,
GtkAdjustment *adj;
gdouble d;
/* a pinch on a touchpad (Ctrl with the wheel) is for programs that
* zoom, not for scrolling here */
if (gdk_event_get_touchpad_emulated ((GdkEvent *) event))
return FALSE;
button = GTK_SCALE_BUTTON (widget);
priv = button->priv;
adj = priv->adjustment;

View file

@ -1792,6 +1792,11 @@ gtk_scrolled_window_scroll_event (GtkWidget *widget,
gdouble steps_x, steps_y;
gboolean pixels, glide = FALSE, handled = FALSE, moved = FALSE;
/* a pinch on a touchpad (Ctrl with the wheel) is for programs that
* zoom, not for scrolling here */
if (gdk_event_get_touchpad_emulated ((GdkEvent *) event))
return FALSE;
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);

View file

@ -1040,6 +1040,11 @@ gtk_spin_button_scroll (GtkWidget *widget,
{
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
/* a pinch on a touchpad (Ctrl with the wheel) is for programs that
* zoom, not for scrolling here */
if (gdk_event_get_touchpad_emulated ((GdkEvent *) event))
return FALSE;
if (event->direction == GDK_SCROLL_UP)
{
if (!gtk_widget_has_focus (widget))