[gtk/gtk-3-24: 1/2] gdk/wayland: Clear modifiers when we lose keyboard focus



commit c27cb675b751fab802405c5517e8631acb7ac857
Author: Jan Alexander Steffens (heftig) <jan steffens gmail com>
Date:   Thu Apr 2 19:31:22 2020 +0200

    gdk/wayland: Clear modifiers when we lose keyboard focus
    
    When we `Alt+Tab` away from a GTK application, it loses keyboard focus.
    If we don't clear the modifiers, events from other devices that we
    receive while unfocused will assume `Alt` is still pressed. This results
    in e.g. Firefox navigating through the history instead of scrolling the
    page when using the mouse wheel on it.
    
    We don't get any information about modifiers while we are missing
    keyboard focus, so assuming no modifiers are active is the best we can
    do.
    
    The shell sends us a modifier update immediately before we regain
    keyboard focus, so the state shouldn't get out of sync.
    
    Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/2112

 gdk/wayland/gdkdevice-wayland.c | 1 +
 1 file changed, 1 insertion(+)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 3d6e4400c8..6b8529d872 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -1986,6 +1986,7 @@ keyboard_handle_leave (void               *data,
   g_object_unref (seat->keyboard_focus);
   seat->keyboard_focus = NULL;
   seat->repeat_key = 0;
+  seat->key_modifiers = 0;
 
   GDK_NOTE (EVENTS,
             g_message ("focus out, seat %p surface %p",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]