gtk: Fix VTE focus grabbing
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> [ kraxel: fixed build with CONFIG_VTE=n ] Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
779ce88fbd
commit
9d677e1c2f
7
ui/gtk.c
7
ui/gtk.c
@ -170,6 +170,7 @@ typedef struct VirtualConsole {
|
|||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *menu_item;
|
GtkWidget *menu_item;
|
||||||
GtkWidget *tab_item;
|
GtkWidget *tab_item;
|
||||||
|
GtkWidget *focus;
|
||||||
VirtualConsoleType type;
|
VirtualConsoleType type;
|
||||||
union {
|
union {
|
||||||
VirtualGfxConsole gfx;
|
VirtualGfxConsole gfx;
|
||||||
@ -1060,15 +1061,13 @@ static void gd_menu_switch_vc(GtkMenuItem *item, void *opaque)
|
|||||||
GtkDisplayState *s = opaque;
|
GtkDisplayState *s = opaque;
|
||||||
VirtualConsole *vc = gd_vc_find_by_menu(s);
|
VirtualConsole *vc = gd_vc_find_by_menu(s);
|
||||||
GtkNotebook *nb = GTK_NOTEBOOK(s->notebook);
|
GtkNotebook *nb = GTK_NOTEBOOK(s->notebook);
|
||||||
GtkWidget *child;
|
|
||||||
gint page;
|
gint page;
|
||||||
|
|
||||||
gtk_release_modifiers(s);
|
gtk_release_modifiers(s);
|
||||||
if (vc) {
|
if (vc) {
|
||||||
page = gtk_notebook_page_num(nb, vc->tab_item);
|
page = gtk_notebook_page_num(nb, vc->tab_item);
|
||||||
gtk_notebook_set_current_page(nb, page);
|
gtk_notebook_set_current_page(nb, page);
|
||||||
child = gtk_notebook_get_nth_page(nb, page);
|
gtk_widget_grab_focus(vc->focus);
|
||||||
gtk_widget_grab_focus(child);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1588,6 +1587,7 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc,
|
|||||||
|
|
||||||
vc->type = GD_VC_VTE;
|
vc->type = GD_VC_VTE;
|
||||||
vc->tab_item = box;
|
vc->tab_item = box;
|
||||||
|
vc->focus = vc->vte.terminal;
|
||||||
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), vc->tab_item,
|
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), vc->tab_item,
|
||||||
gtk_label_new(vc->label));
|
gtk_label_new(vc->label));
|
||||||
|
|
||||||
@ -1749,6 +1749,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
|
|||||||
|
|
||||||
vc->type = GD_VC_GFX;
|
vc->type = GD_VC_GFX;
|
||||||
vc->tab_item = vc->gfx.drawing_area;
|
vc->tab_item = vc->gfx.drawing_area;
|
||||||
|
vc->focus = vc->gfx.drawing_area;
|
||||||
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook),
|
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook),
|
||||||
vc->tab_item, gtk_label_new(vc->label));
|
vc->tab_item, gtk_label_new(vc->label));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user