* [Qemu-devel] [PATCH] vnc: improve capslock handling.
@ 2009-11-02 11:47 Gerd Hoffmann
2009-12-10 14:05 ` Alexander Graf
0 siblings, 1 reply; 3+ messages in thread
From: Gerd Hoffmann @ 2009-11-02 11:47 UTC (permalink / raw)
To: qemu-devel; +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 <kraxel@redhat.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vnc: improve capslock handling.
2009-11-02 11:47 [Qemu-devel] [PATCH] vnc: improve capslock handling Gerd Hoffmann
@ 2009-12-10 14:05 ` Alexander Graf
2009-12-10 20:32 ` Gerd Hoffmann
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Graf @ 2009-12-10 14:05 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
Gerd Hoffmann wrote:
> 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 <kraxel@redhat.com>
>
This commit breaks the shift key in VNC for me.
Alex
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vnc: improve capslock handling.
2009-12-10 14:05 ` Alexander Graf
@ 2009-12-10 20:32 ` Gerd Hoffmann
0 siblings, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2009-12-10 20:32 UTC (permalink / raw)
To: Alexander Graf; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 549 bytes --]
On 12/10/09 15:05, Alexander Graf wrote:
> Gerd Hoffmann wrote:
>> 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<kraxel@redhat.com>
>>
>
> This commit breaks the shift key in VNC for me.
Does the attached patch fix it for you?
Guess you are using vncviewer?
cheers,
Gerd
[-- Attachment #2: fix --]
[-- Type: text/plain, Size: 650 bytes --]
diff --git a/vnc.c b/vnc.c
index 32c4678..2e4fd40 100644
--- a/vnc.c
+++ b/vnc.c
@@ -1506,11 +1506,12 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym)
static void key_event(VncState *vs, int down, uint32_t sym)
{
int keycode;
+ int lsym = sym;
- if (sym >= 'A' && sym <= 'Z' && is_graphic_console())
- sym = sym - 'A' + 'a';
+ if (lsym >= 'A' && lsym <= 'Z' && is_graphic_console())
+ lsym = lsym - 'A' + 'a';
- keycode = keysym2scancode(vs->vd->kbd_layout, sym & 0xFFFF);
+ keycode = keysym2scancode(vs->vd->kbd_layout, lsym & 0xFFFF);
do_key_event(vs, down, keycode, sym);
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-12-10 20:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-02 11:47 [Qemu-devel] [PATCH] vnc: improve capslock handling Gerd Hoffmann
2009-12-10 14:05 ` Alexander Graf
2009-12-10 20:32 ` 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).