From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N4vNe-0005Mr-Gf for qemu-devel@nongnu.org; Mon, 02 Nov 2009 06:47:26 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N4vNZ-0005L4-Oj for qemu-devel@nongnu.org; Mon, 02 Nov 2009 06:47:25 -0500 Received: from [199.232.76.173] (port=37634 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N4vNZ-0005Kv-GE for qemu-devel@nongnu.org; Mon, 02 Nov 2009 06:47:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39796) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N4vNY-00082Y-Uz for qemu-devel@nongnu.org; Mon, 02 Nov 2009 06:47:21 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nA2BlJie016867 for ; Mon, 2 Nov 2009 06:47:20 -0500 From: Gerd Hoffmann Date: Mon, 2 Nov 2009 12:47:06 +0100 Message-Id: <1257162426-10349-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH] vnc: improve capslock handling. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann When capslock is toggled while the vnc window hasn't the focus qemu will miss the state change. Add sanity checks for the capslock state and toggle it if needed, so hosts and guests idea of capslock state stay in sync. Simliar logic for numlock is present in qemu already. Signed-off-by: Gerd Hoffmann --- vnc.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/vnc.c b/vnc.c index 01e8e93..2bb8024 100644 --- a/vnc.c +++ b/vnc.c @@ -1377,6 +1377,27 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) } } + if ((sym >= 'A' && sym <= 'Z') || (sym >= 'a' && sym <= 'z')) { + /* If the capslock state needs to change then simulate an additional + keypress before sending this one. This will happen if the user + toggles capslock away from the VNC window. + */ + int uppercase = !!(sym >= 'A' && sym <= 'Z'); + int shift = !!(vs->modifiers_state[0x2a] | vs->modifiers_state[0x36]); + int capslock = !!(vs->modifiers_state[0x3a]); + if (capslock) { + if (uppercase == shift) { + vs->modifiers_state[0x3a] = 0; + press_key(vs, 0xffe5); + } + } else { + if (uppercase != shift) { + vs->modifiers_state[0x3a] = 1; + press_key(vs, 0xffe5); + } + } + } + if (is_graphic_console()) { if (keycode & 0x80) kbd_put_keycode(0xe0); -- 1.6.2.5