diff mbox

[1/2] gtk: Fix VTE focus grabbing

Message ID c5568b8d2b322aa290d3cc716b53960105e026b9.1430075061.git.jan.kiszka@web.de
State New
Headers show

Commit Message

Jan Kiszka April 26, 2015, 7:04 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

At least on GTK2, the VTE terminal has to be specified as target of
gtk_widget_grab_focus. Otherwise, switching from one VTE terminal to
another causes the focus to get lost.

CC: John Snow <jsnow@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 ui/gtk.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/ui/gtk.c b/ui/gtk.c
index 51abac9..76d9b73 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1021,15 +1021,17 @@  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(nb, vc->tab_item);
         gtk_notebook_set_current_page(nb, page);
-        child = gtk_notebook_get_nth_page(nb, page);
-        gtk_widget_grab_focus(child);
+        if (vc->type == GD_VC_VTE) {
+            gtk_widget_grab_focus(vc->vte.terminal);
+        } else {
+            gtk_widget_grab_focus(vc->tab_item);
+        }
     }
 }