Control: found 898772 1:3.1+dfsg-4
This bug does affect qemu 1:3.1+dfsg-4, except that the list of
known modifier keys is expanded to include "META_L" and "META_R".
The issue is thus somewhat less severe but still present.
An easy way to see the problem is that if a qemu window is
focused, and the user holds down the "G" key while pressing
Super+Tab, the guest OS will continue to believe that "G" is
pressed even after the window loses focus.
Here is a patch to fix this issue for qemu 3.1:
--- qemu-3.1+dfsg.orig/ui/gtk.c
+++ qemu-3.1+dfsg/ui/gtk.c
@@ -122,17 +122,6 @@
#define HOTKEY_MODIFIERS (GDK_CONTROL_MASK | GDK_MOD1_MASK)
-static const int modifier_keycode[] = {
- Q_KEY_CODE_SHIFT,
- Q_KEY_CODE_SHIFT_R,
- Q_KEY_CODE_CTRL,
- Q_KEY_CODE_CTRL_R,
- Q_KEY_CODE_ALT,
- Q_KEY_CODE_ALT_R,
- Q_KEY_CODE_META_L,
- Q_KEY_CODE_META_R,
-};
-
static const guint16 *keycode_map;
static size_t keycode_maplen;
@@ -187,7 +176,7 @@
bool external_pause_update;
- bool modifier_pressed[ARRAY_SIZE(modifier_keycode)];
+ bool modifier_pressed[Q_KEY_CODE__MAX];
bool ignore_keys;
DisplayOptions *opts;
@@ -432,8 +421,8 @@
!qemu_console_is_graphic(vc->gfx.dcl.con)) {
return;
}
- for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) {
- qcode = modifier_keycode[i];
+ for (i = 0; i < ARRAY_SIZE(s->modifier_pressed); i++) {
+ qcode = i;
if (!s->modifier_pressed[i]) {
continue;
}
@@ -1144,10 +1133,8 @@
trace_gd_key_event(vc->label, key->hardware_keycode, qcode,
(key->type == GDK_KEY_PRESS) ? "down" : "up");
- for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) {
- if (qcode == modifier_keycode[i]) {
- s->modifier_pressed[i] = (key->type == GDK_KEY_PRESS);
- }
+ if (qcode >= 0 && qcode < ARRAY_SIZE(s->modifier_pressed)) {
+ s->modifier_pressed[qcode] = (key->type == GDK_KEY_PRESS);
}
qemu_input_event_send_key_qcode(vc->gfx.dcl.con, qcode,