From patchwork Mon Apr 27 13:39:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 465023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A804D140082 for ; Mon, 27 Apr 2015 23:39:58 +1000 (AEST) Received: from localhost ([::1]:55118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmjGO-0008B8-R4 for incoming@patchwork.ozlabs.org; Mon, 27 Apr 2015 09:39:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmjFn-00072U-D0 for qemu-devel@nongnu.org; Mon, 27 Apr 2015 09:39:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmjFj-0006Gh-Ay for qemu-devel@nongnu.org; Mon, 27 Apr 2015 09:39:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40371) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmjFj-0006GA-6V for qemu-devel@nongnu.org; Mon, 27 Apr 2015 09:39:15 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id CD9D78F2F5; Mon, 27 Apr 2015 13:39:14 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-39.ams2.redhat.com [10.36.116.39]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3RDdCvZ000860; Mon, 27 Apr 2015 09:39:14 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id F1DF8831E3; Mon, 27 Apr 2015 15:39:13 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 27 Apr 2015 15:39:08 +0200 Message-Id: <1430141948-18272-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1430141948-18272-1-git-send-email-kraxel@redhat.com> References: <1430141948-18272-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Jan Kiszka , Gerd Hoffmann Subject: [Qemu-devel] [PULL 5/5] gtk: Avoid accel key leakage into guest on console switch X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jan Kiszka 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 Signed-off-by: Gerd Hoffmann --- ui/gtk.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ui/gtk.c b/ui/gtk.c index 763d97a..51ea1b9 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -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)