From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KX2WD-0001Bj-Cy for qemu-devel@nongnu.org; Sat, 23 Aug 2008 19:27:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KX2WC-0001BL-VA for qemu-devel@nongnu.org; Sat, 23 Aug 2008 19:27:40 -0400 Received: from [199.232.76.173] (port=44125 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KX2WC-0001BF-FL for qemu-devel@nongnu.org; Sat, 23 Aug 2008 19:27:40 -0400 Received: from savannah.gnu.org ([199.232.41.3]:55330 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KX2WC-0004VT-B4 for qemu-devel@nongnu.org; Sat, 23 Aug 2008 19:27:40 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KX2WA-0006Wx-Do for qemu-devel@nongnu.org; Sat, 23 Aug 2008 23:27:38 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KX2WA-0006Wo-4R for qemu-devel@nongnu.org; Sat, 23 Aug 2008 23:27:38 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Sat, 23 Aug 2008 23:27:38 +0000 Subject: [Qemu-devel] [5076] VNC: Support for ExtendedKeyEvent client message Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5076 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5076 Author: aliguori Date: 2008-08-23 23:27:37 +0000 (Sat, 23 Aug 2008) Log Message: ----------- VNC: Support for ExtendedKeyEvent client message This patch adds support for the ExtendedKeyEvent client message. This message allows a client to send raw scan codes directly to the server. If the client and server are using the same keymap, then it's unnecessary to use the '-k' option with QEMU when this extension is supported. This is extension is currently only implemented by gtk-vnc based clients (gvncviewer, virt-manager, vinagre, etc.). Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/vnc.c Modified: trunk/vnc.c =================================================================== --- trunk/vnc.c 2008-08-23 17:22:19 UTC (rev 5075) +++ trunk/vnc.c 2008-08-23 23:27:37 UTC (rev 5076) @@ -939,12 +939,8 @@ kbd_put_keycode(keysym2scancode(vs->kbd_layout, keysym) | 0x80); } -static void do_key_event(VncState *vs, int down, uint32_t sym) +static void do_key_event(VncState *vs, int down, int keycode, int sym) { - int keycode; - - keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF); - /* QEMU console switch */ switch(keycode) { case 0x2a: /* Left Shift */ @@ -1046,11 +1042,25 @@ static void key_event(VncState *vs, int down, uint32_t sym) { + int keycode; + if (sym >= 'A' && sym <= 'Z' && is_graphic_console()) sym = sym - 'A' + 'a'; - do_key_event(vs, down, sym); + + keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF); + do_key_event(vs, down, keycode, sym); } +static void ext_key_event(VncState *vs, int down, + uint32_t sym, uint16_t keycode) +{ + /* if the user specifies a keyboard layout, always use it */ + if (keyboard_layout) + key_event(vs, down, sym); + else + do_key_event(vs, down, keycode, sym); +} + static void framebuffer_update_request(VncState *vs, int incremental, int x_position, int y_position, int w, int h) @@ -1078,6 +1088,15 @@ } } +static void send_ext_key_event_ack(VncState *vs) +{ + vnc_write_u8(vs, 0); + vnc_write_u8(vs, 0); + vnc_write_u16(vs, 1); + vnc_framebuffer_update(vs, 0, 0, vs->ds->width, vs->ds->height, -258); + vnc_flush(vs); +} + static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) { int i; @@ -1105,6 +1124,9 @@ case -257: vs->has_pointer_type_change = 1; break; + case -258: + send_ext_key_event_ack(vs); + break; default: break; } @@ -1256,6 +1278,24 @@ client_cut_text(vs, read_u32(data, 4), data + 8); break; + case 255: + if (len == 1) + return 2; + + switch (read_u8(data, 1)) { + case 0: + if (len == 2) + return 12; + + ext_key_event(vs, read_u16(data, 2), + read_u32(data, 4), read_u32(data, 8)); + break; + default: + printf("Msg: %d\n", read_u16(data, 0)); + vnc_client_error(vs); + break; + } + break; default: printf("Msg: %d\n", data[0]); vnc_client_error(vs); @@ -1974,10 +2014,11 @@ vs->ds = ds; - if (!keyboard_layout) - keyboard_layout = "en-us"; + if (keyboard_layout) + vs->kbd_layout = init_keyboard_layout(keyboard_layout); + else + vs->kbd_layout = init_keyboard_layout("en-us"); - vs->kbd_layout = init_keyboard_layout(keyboard_layout); if (!vs->kbd_layout) exit(1);