Usability fixes for GTK2
cover Usability fixes for GTK2
Two small patches to fix annoying problems on GTK2. Both weren't tested on GTK3 (no working setup at hand). The first one comes with a tiny risk of behaving differently there. The second one may actually be required on GTK3 as well or is at least a nop there and doesn't need the version check.
Jan
Jan Kiszka (2):
gtk: Fix VTE focus grabbing
gtk: Avoid accel key leakage into guest on console switch
ui/gtk.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/2 gtk: Fix VTE focus grabbing
From: Jan Kiszka <[email protected]>
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.
--- ui/gtk.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
ui/gtk.c +5 -3
@@ -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); + } } }
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH 1/2] gtk: Fix VTE focus grabbing
Quoted 5 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
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.
Fails to build with CONFIG_VTE=n, update attached, please verify.
thanks,
Gerd
Quoted 1 line
From
9d677e1c2fa479336fb7a2b90aea78c10d037e98Mon Sep 17 00:00:00 2001
From: Jan Kiszka <[email protected]>
Date: Sun, 26 Apr 2015 21:04:20 +0200
Subject: [PATCH] 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.
[ kraxel: fixed build with CONFIG_VTE=n ]
--- ui/gtk.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
ui/gtk.c +4 -3
@@ -170,6 +170,7 @@ typedef struct VirtualConsole {GtkWidget *window;GtkWidget *menu_item;GtkWidget *tab_item; +GtkWidget *focus;VirtualConsoleType type;union {VirtualGfxConsole gfx;
@@ -1060,15 +1061,13 @@ 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); +gtk_widget_grab_focus (vc->focus); } }
@@ -1588,6 +1587,7 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc, vc->type =GD_VC_VTE ; vc->tab_item = box; + vc->focus = vc->vte.terminal;gtk_notebook_append_page (GTK_NOTEBOOK (s->notebook), vc->tab_item,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->tab_item = vc->gfx.drawing_area; + vc->focus = vc->gfx.drawing_area;gtk_notebook_append_page (GTK_NOTEBOOK (s->notebook), vc->tab_item,gtk_label_new (vc->label));
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 1/2] gtk: Fix VTE focus grabbing
Am 2015-04-27 um 11:23 schrieb Gerd Hoffmann:
Quoted 8 lines · Jan Kiszka
Quoted 5 lines
From: Jan Kiszka <[email protected]>
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.Fails to build with
CONFIG_VTE=n, update attached, please verify.
Works fine, thanks!
Jan
PATCH 2/2 gtk: Avoid accel key leakage into guest on console switch
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
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.
--- ui/gtk.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
ui/gtk.c +12 -0
@@ -230,6 +230,7 @@ struct GtkDisplayState {bool modifier_pressed[ARRAY_SIZE (modifier_keycode)];bool has_evdev; +bool ignore_keys; };static void gd_grab_pointer (VirtualConsole *vc);
@@ -953,6 +954,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 );
@@ -1033,12 +1039,18 @@ static void gd_menu_switch_vc(GtkMenuItem *item, void *opaque)gtk_widget_grab_focus (vc->tab_item); } } + 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)
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH 2/2] gtk: Avoid accel key leakage into guest on console switch
Quoted 4 lines · 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.
Added to gtk queue
thanks,
Gerd