diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2015-04-26 21:04:21 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2015-04-27 11:00:43 +0200 |
commit | 1a01716a307387e5cf1336f61a96f772dddadc90 (patch) | |
tree | 5317c46979a89f3f1b7ea8d5f74a6208335b7b92 /ui | |
parent | 9d677e1c2fa479336fb7a2b90aea78c10d037e98 (diff) |
gtk: Avoid accel key leakage into guest on console switch
GTK2 sends the accel key to the guest when switching to the graphic
console via that shortcut. Resolve this by ignoring any keys until the
next key-release event. However, do not ignore keys when switching via
the menu or when on GTK3.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gtk.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -231,6 +231,7 @@ struct GtkDisplayState { bool modifier_pressed[ARRAY_SIZE(modifier_keycode)]; bool has_evdev; + bool ignore_keys; }; static void gd_grab_pointer(VirtualConsole *vc); @@ -993,6 +994,11 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) int qemu_keycode; int i; + if (s->ignore_keys) { + s->ignore_keys = (key->type == GDK_KEY_PRESS); + return TRUE; + } + if (key->keyval == GDK_KEY_Pause) { qemu_input_event_send_key_qcode(vc->gfx.dcl.con, Q_KEY_CODE_PAUSE, key->type == GDK_KEY_PRESS); @@ -1069,12 +1075,18 @@ static void gd_menu_switch_vc(GtkMenuItem *item, void *opaque) gtk_notebook_set_current_page(nb, page); gtk_widget_grab_focus(vc->focus); } + s->ignore_keys = false; } static void gd_accel_switch_vc(void *opaque) { VirtualConsole *vc = opaque; + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item), TRUE); +#if !GTK_CHECK_VERSION(3, 0, 0) + /* GTK2 sends the accel key to the target console - ignore this until */ + vc->s->ignore_keys = true; +#endif } static void gd_menu_show_tabs(GtkMenuItem *item, void *opaque) |