* [Qemu-devel] [PATCH 0/2] Usability fixes for GTK2
@ 2015-04-26 19:04 Jan Kiszka
2015-04-26 19:04 ` [Qemu-devel] [PATCH 1/2] gtk: Fix VTE focus grabbing Jan Kiszka
2015-04-26 19:04 ` [Qemu-devel] [PATCH 2/2] gtk: Avoid accel key leakage into guest on console switch Jan Kiszka
0 siblings, 2 replies; 6+ messages in thread
From: Jan Kiszka @ 2015-04-26 19:04 UTC (permalink / raw)
To: qemu-devel, Gerd Hoffmann; +Cc: John Snow
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
CC: John Snow <jsnow@redhat.com>
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(-)
--
2.1.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 1/2] gtk: Fix VTE focus grabbing
2015-04-26 19:04 [Qemu-devel] [PATCH 0/2] Usability fixes for GTK2 Jan Kiszka
@ 2015-04-26 19:04 ` Jan Kiszka
2015-04-27 9:23 ` Gerd Hoffmann
2015-04-26 19:04 ` [Qemu-devel] [PATCH 2/2] gtk: Avoid accel key leakage into guest on console switch Jan Kiszka
1 sibling, 1 reply; 6+ messages in thread
From: Jan Kiszka @ 2015-04-26 19:04 UTC (permalink / raw)
To: qemu-devel, Gerd Hoffmann; +Cc: John Snow
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 --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);
+ }
}
}
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/2] gtk: Avoid accel key leakage into guest on console switch
2015-04-26 19:04 [Qemu-devel] [PATCH 0/2] Usability fixes for GTK2 Jan Kiszka
2015-04-26 19:04 ` [Qemu-devel] [PATCH 1/2] gtk: Fix VTE focus grabbing Jan Kiszka
@ 2015-04-26 19:04 ` Jan Kiszka
2015-04-27 9:24 ` Gerd Hoffmann
1 sibling, 1 reply; 6+ messages in thread
From: Jan Kiszka @ 2015-04-26 19:04 UTC (permalink / raw)
To: qemu-devel, Gerd Hoffmann
From: Jan Kiszka <jan.kiszka@siemens.com>
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 <jan.kiszka@siemens.com>
---
ui/gtk.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/ui/gtk.c b/ui/gtk.c
index 76d9b73..0ef03e7 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -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)
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] gtk: Fix VTE focus grabbing
2015-04-26 19:04 ` [Qemu-devel] [PATCH 1/2] gtk: Fix VTE focus grabbing Jan Kiszka
@ 2015-04-27 9:23 ` Gerd Hoffmann
2015-04-27 12:26 ` Jan Kiszka
0 siblings, 1 reply; 6+ messages in thread
From: Gerd Hoffmann @ 2015-04-27 9:23 UTC (permalink / raw)
To: Jan Kiszka; +Cc: John Snow, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 364 bytes --]
On So, 2015-04-26 at 21:04 +0200, Jan Kiszka wrote:
> 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.
Fails to build with CONFIG_VTE=n, update attached, please verify.
thanks,
Gerd
[-- Attachment #2: 0001-gtk-Fix-VTE-focus-grabbing.patch --]
[-- Type: text/x-patch, Size: 2165 bytes --]
>From 9d677e1c2fa479336fb7a2b90aea78c10d037e98 Mon Sep 17 00:00:00 2001
From: Jan Kiszka <jan.kiszka@siemens.com>
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.
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>
---
ui/gtk.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index 7180066..763d97a 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -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));
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] gtk: Avoid accel key leakage into guest on console switch
2015-04-26 19:04 ` [Qemu-devel] [PATCH 2/2] gtk: Avoid accel key leakage into guest on console switch Jan Kiszka
@ 2015-04-27 9:24 ` Gerd Hoffmann
0 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2015-04-27 9:24 UTC (permalink / raw)
To: Jan Kiszka; +Cc: qemu-devel
On So, 2015-04-26 at 21:04 +0200, Jan Kiszka wrote:
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] gtk: Fix VTE focus grabbing
2015-04-27 9:23 ` Gerd Hoffmann
@ 2015-04-27 12:26 ` Jan Kiszka
0 siblings, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2015-04-27 12:26 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: John Snow, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 446 bytes --]
Am 2015-04-27 um 11:23 schrieb Gerd Hoffmann:
> On So, 2015-04-26 at 21:04 +0200, Jan Kiszka wrote:
>> 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.
>
> Fails to build with CONFIG_VTE=n, update attached, please verify.
Works fine, thanks!
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-04-27 12:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-26 19:04 [Qemu-devel] [PATCH 0/2] Usability fixes for GTK2 Jan Kiszka
2015-04-26 19:04 ` [Qemu-devel] [PATCH 1/2] gtk: Fix VTE focus grabbing Jan Kiszka
2015-04-27 9:23 ` Gerd Hoffmann
2015-04-27 12:26 ` Jan Kiszka
2015-04-26 19:04 ` [Qemu-devel] [PATCH 2/2] gtk: Avoid accel key leakage into guest on console switch Jan Kiszka
2015-04-27 9:24 ` Gerd Hoffmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).