From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4ZiD-0002ZQ-B0 for qemu-devel@nongnu.org; Tue, 08 Jul 2014 14:02:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4Zi5-0005Fy-RB for qemu-devel@nongnu.org; Tue, 08 Jul 2014 14:01:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Zi5-0005Fk-Jy for qemu-devel@nongnu.org; Tue, 08 Jul 2014 14:01:45 -0400 From: John Snow Date: Tue, 8 Jul 2014 14:01:23 -0400 Message-Id: <1404842483-23612-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH] ui/gtk: Restore keyboard focus after Page change List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, jsnow@redhat.com, stefanha@redhat.com In the GTK UI, after changing focus to the qemu monitor Notebook Page, when restoring focus to the virtual machine page, the keyboard focus is lost to a hidden GTK widget. Focus can only be restored to the virtual machine by pressing "tab" or any of the four directional arrow keys. Clicking in the window or grabbing/ungrabbing input does not restore keyboard focus to the child widget. This patch adjusts the Notebook page switching callback to automatically steal keyboard focus on the Page switch event, so that keyboard input does not appear to break or disappear after tabbing to the QEMU monitor. Signed-off-by: John Snow --- ui/gtk.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index b02fcd6..2345d7e 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -992,13 +992,16 @@ static void gd_menu_switch_vc(GtkMenuItem *item, void *opaque) { GtkDisplayState *s = opaque; VirtualConsole *vc = gd_vc_find_by_menu(s); + GtkNotebook *nb = GTK_NOTEBOOK(s->notebook); + GtkWidget *child; gint page; gtk_release_modifiers(s); if (vc) { - page = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook), - vc->tab_item); - gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), page); + page = gtk_notebook_page_num(nb, vc->tab_item); + gtk_notebook_set_current_page(nb, page); + child = gtk_notebook_get_nth_page(nb, page); + gtk_widget_grab_focus(child); } } -- 1.9.3