From nobody Sun May 5 02:44:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516891132928747.1678218558852; Thu, 25 Jan 2018 06:38:52 -0800 (PST) Received: from localhost ([::1]:44146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeifv-0001p4-1z for importer@patchew.org; Thu, 25 Jan 2018 09:38:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeiZn-0005Tb-6K for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeiZk-0006sK-Nf for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43026) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eeiZk-0006rQ-Gk for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:24 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C408878232 for ; Thu, 25 Jan 2018 14:32:23 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9457960C4D; Thu, 25 Jan 2018 14:32:19 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D099F11ABC; Thu, 25 Jan 2018 15:32:18 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 25 Jan 2018 15:32:11 +0100 Message-Id: <20180125143218.29528-2-kraxel@redhat.com> In-Reply-To: <20180125143218.29528-1-kraxel@redhat.com> References: <20180125143218.29528-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 25 Jan 2018 14:32:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/8] ui: avoid sign extension using client width/height X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Pixman returns a signed int for the image width/height, but the VNC protocol only permits a unsigned int16. Effective framebuffer size is determined by the guest, limited by the video RAM size, so the dimensions are unlikely to exceed the range of an unsigned int16, but this is not currently validated. With the current use of 'int' for client width/height, the calculation of offsets in vnc_update_throttle_offset() suffers from integer size promotion and sign extension, causing coverity warnings *** CID 1385147: Integer handling issues (SIGN_EXTENSION) /ui/vnc.c: 979 in vnc_update_throttle_offset() 973 * than that the client would already suffering awful audio 974 * glitches, so dropping samples is no worse really). 975 */ 976 static void vnc_update_throttle_offset(VncState *vs) 977 { 978 size_t offset =3D >>> CID 1385147: Integer handling issues (SIGN_EXTENSION) >>> Suspicious implicit sign extension: "vs->client_pf.bytes_per_pixel" with type "unsigned char" (8 bits, unsigned) is promoted in "vs->client_width * vs->client_height * vs->client_pf.bytes_per_pixel" to type "int" (32 bits, signed), then sign-extended to type "unsigned long" (64 bits, unsigned). If "vs->client_width * vs->client_height * vs->client_pf.bytes_per_pixel" is greater than 0x7FFFFFFF, the upper bits of the result will all be 1. 979 vs->client_width * vs->client_height * vs->client_pf.bytes_= per_pixel; Change client_width / client_height to be a size_t to avoid sign extension and integer promotion. Then validate that dimensions are in range wrt the RFB protocol u16 limits. Signed-off-by: Daniel P. Berrange Message-id: 20180118155254.17053-1-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- ui/vnc.h | 4 ++-- ui/vnc.c | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ui/vnc.h b/ui/vnc.h index 0c33a5f7fe..bbda0540a7 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -278,8 +278,8 @@ struct VncState int last_x; int last_y; uint32_t last_bmask; - int client_width; - int client_height; + size_t client_width; /* limited to u16 by RFB proto */ + size_t client_height; /* limited to u16 by RFB proto */ VncShareMode share_mode; =20 uint32_t vnc_encoding; diff --git a/ui/vnc.c b/ui/vnc.c index 665a143578..33b087221f 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -672,6 +672,11 @@ static void vnc_desktop_resize(VncState *vs) vs->client_height =3D=3D pixman_image_get_height(vs->vd->server)) { return; } + + assert(pixman_image_get_width(vs->vd->server) < 65536 && + pixman_image_get_width(vs->vd->server) >=3D 0); + assert(pixman_image_get_height(vs->vd->server) < 65536 && + pixman_image_get_height(vs->vd->server) >=3D 0); vs->client_width =3D pixman_image_get_width(vs->vd->server); vs->client_height =3D pixman_image_get_height(vs->vd->server); vnc_lock_output(vs); @@ -2490,6 +2495,10 @@ static int protocol_client_init(VncState *vs, uint8_= t *data, size_t len) return 0; } =20 + assert(pixman_image_get_width(vs->vd->server) < 65536 && + pixman_image_get_width(vs->vd->server) >=3D 0); + assert(pixman_image_get_height(vs->vd->server) < 65536 && + pixman_image_get_height(vs->vd->server) >=3D 0); vs->client_width =3D pixman_image_get_width(vs->vd->server); vs->client_height =3D pixman_image_get_height(vs->vd->server); vnc_write_u16(vs, vs->client_width); --=20 2.9.3 From nobody Sun May 5 02:44:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516890887635152.50546410870504; Thu, 25 Jan 2018 06:34:47 -0800 (PST) Received: from localhost ([::1]:43990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeic2-0006rO-PW for importer@patchew.org; Thu, 25 Jan 2018 09:34:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeiZn-0005Td-6W for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeiZk-0006rs-FT for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43024) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eeiZk-0006qv-7j for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:24 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8A546800A8 for ; Thu, 25 Jan 2018 14:32:23 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95E1B600CC; Thu, 25 Jan 2018 14:32:19 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DD45611ABD; Thu, 25 Jan 2018 15:32:18 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 25 Jan 2018 15:32:12 +0100 Message-Id: <20180125143218.29528-3-kraxel@redhat.com> In-Reply-To: <20180125143218.29528-1-kraxel@redhat.com> References: <20180125143218.29528-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 25 Jan 2018 14:32:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/8] ui: convert the SDL2 frontend to keycodemapdb X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The SDL2 scancodes are conveniently identical to the USB scancodes. Replace the sdl2_scancode_to_qcode table with an automatically generated table. Missing entries in sdl2_scancode_to_qcode now fixed: - 0x32 -> Q_KEY_CODE_BACKSLASH - 0x66 -> Q_KEY_CODE_POWER - 0x67 -> Q_KEY_CODE_KP_EQUALS - 0x74 -> Q_KEY_CODE_OPEN - 0x77 -> Q_KEY_CODE_FRONT - 0x7f -> Q_KEY_CODE_AUDIOMUTE - 0x80 -> Q_KEY_CODE_VOLUMEUP - 0x81 -> Q_KEY_CODE_VOLUMEDOWN - 0x85 -> Q_KEY_CODE_KP_COMMA - 0x87 -> Q_KEY_CODE_RO - 0x89 -> Q_KEY_CODE_YEN - 0x8a -> Q_KEY_CODE_HENKAN - 0x93 -> Q_KEY_CODE_HIRAGANA - 0xe8 -> Q_KEY_CODE_AUDIOPLAY - 0xe9 -> Q_KEY_CODE_AUDIOSTOP - 0xea -> Q_KEY_CODE_AUDIOPREV - 0xeb -> Q_KEY_CODE_AUDIONEXT - 0xed -> Q_KEY_CODE_VOLUMEUP - 0xee -> Q_KEY_CODE_VOLUMEDOWN - 0xef -> Q_KEY_CODE_AUDIOMUTE - 0xf1 -> Q_KEY_CODE_AC_BACK - 0xf2 -> Q_KEY_CODE_AC_FORWARD - 0xf3 -> Q_KEY_CODE_STOP - 0xf4 -> Q_KEY_CODE_FIND - 0xf8 -> Q_KEY_CODE_SLEEP - 0xfa -> Q_KEY_CODE_AC_REFRESH - 0xfb -> Q_KEY_CODE_CALCULATOR And some mistakes corrected: - 0x65 -> Q_KEY_CODE_COMPOSE, not duplicating Q_KEY_CODE_MENU Signed-off-by: Daniel P. Berrange Message-id: 20180117164717.15855-2-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- Makefile | 1 + include/ui/input.h | 3 + ui/sdl2-keymap.h | 267 -------------------------------------------------= ---- ui/input-keymap.c | 1 + ui/sdl2-input.c | 16 +++- 5 files changed, 16 insertions(+), 272 deletions(-) delete mode 100644 ui/sdl2-keymap.h diff --git a/Makefile b/Makefile index d835bb92e7..24ed2b3e63 100644 --- a/Makefile +++ b/Makefile @@ -236,6 +236,7 @@ KEYCODEMAP_FILES =3D \ ui/input-keymap-qcode-to-qnum.c \ ui/input-keymap-qnum-to-qcode.c \ ui/input-keymap-qcode-to-linux.c \ + ui/input-keymap-usb-to-qcode.c \ $(NULL) =20 GENERATED_FILES +=3D $(KEYCODEMAP_FILES) diff --git a/include/ui/input.h b/include/ui/input.h index 5cc76d6e41..0d289e4142 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -80,4 +80,7 @@ extern const guint16 qemu_input_map_qnum_to_qcode[]; extern const guint qemu_input_map_qcode_to_linux_len; extern const guint16 qemu_input_map_qcode_to_linux[]; =20 +extern const guint qemu_input_map_usb_to_qcode_len; +extern const guint16 qemu_input_map_usb_to_qcode[]; + #endif /* INPUT_H */ diff --git a/ui/sdl2-keymap.h b/ui/sdl2-keymap.h deleted file mode 100644 index cbedaa477d..0000000000 --- a/ui/sdl2-keymap.h +++ /dev/null @@ -1,267 +0,0 @@ - -/* map SDL2 scancodes to QKeyCode */ - -static const int sdl2_scancode_to_qcode[SDL_NUM_SCANCODES] =3D { - [SDL_SCANCODE_A] =3D Q_KEY_CODE_A, - [SDL_SCANCODE_B] =3D Q_KEY_CODE_B, - [SDL_SCANCODE_C] =3D Q_KEY_CODE_C, - [SDL_SCANCODE_D] =3D Q_KEY_CODE_D, - [SDL_SCANCODE_E] =3D Q_KEY_CODE_E, - [SDL_SCANCODE_F] =3D Q_KEY_CODE_F, - [SDL_SCANCODE_G] =3D Q_KEY_CODE_G, - [SDL_SCANCODE_H] =3D Q_KEY_CODE_H, - [SDL_SCANCODE_I] =3D Q_KEY_CODE_I, - [SDL_SCANCODE_J] =3D Q_KEY_CODE_J, - [SDL_SCANCODE_K] =3D Q_KEY_CODE_K, - [SDL_SCANCODE_L] =3D Q_KEY_CODE_L, - [SDL_SCANCODE_M] =3D Q_KEY_CODE_M, - [SDL_SCANCODE_N] =3D Q_KEY_CODE_N, - [SDL_SCANCODE_O] =3D Q_KEY_CODE_O, - [SDL_SCANCODE_P] =3D Q_KEY_CODE_P, - [SDL_SCANCODE_Q] =3D Q_KEY_CODE_Q, - [SDL_SCANCODE_R] =3D Q_KEY_CODE_R, - [SDL_SCANCODE_S] =3D Q_KEY_CODE_S, - [SDL_SCANCODE_T] =3D Q_KEY_CODE_T, - [SDL_SCANCODE_U] =3D Q_KEY_CODE_U, - [SDL_SCANCODE_V] =3D Q_KEY_CODE_V, - [SDL_SCANCODE_W] =3D Q_KEY_CODE_W, - [SDL_SCANCODE_X] =3D Q_KEY_CODE_X, - [SDL_SCANCODE_Y] =3D Q_KEY_CODE_Y, - [SDL_SCANCODE_Z] =3D Q_KEY_CODE_Z, - - [SDL_SCANCODE_1] =3D Q_KEY_CODE_1, - [SDL_SCANCODE_2] =3D Q_KEY_CODE_2, - [SDL_SCANCODE_3] =3D Q_KEY_CODE_3, - [SDL_SCANCODE_4] =3D Q_KEY_CODE_4, - [SDL_SCANCODE_5] =3D Q_KEY_CODE_5, - [SDL_SCANCODE_6] =3D Q_KEY_CODE_6, - [SDL_SCANCODE_7] =3D Q_KEY_CODE_7, - [SDL_SCANCODE_8] =3D Q_KEY_CODE_8, - [SDL_SCANCODE_9] =3D Q_KEY_CODE_9, - [SDL_SCANCODE_0] =3D Q_KEY_CODE_0, - - [SDL_SCANCODE_RETURN] =3D Q_KEY_CODE_RET, - [SDL_SCANCODE_ESCAPE] =3D Q_KEY_CODE_ESC, - [SDL_SCANCODE_BACKSPACE] =3D Q_KEY_CODE_BACKSPACE, - [SDL_SCANCODE_TAB] =3D Q_KEY_CODE_TAB, - [SDL_SCANCODE_SPACE] =3D Q_KEY_CODE_SPC, - [SDL_SCANCODE_MINUS] =3D Q_KEY_CODE_MINUS, - [SDL_SCANCODE_EQUALS] =3D Q_KEY_CODE_EQUAL, - [SDL_SCANCODE_LEFTBRACKET] =3D Q_KEY_CODE_BRACKET_LEFT, - [SDL_SCANCODE_RIGHTBRACKET] =3D Q_KEY_CODE_BRACKET_RIGHT, - [SDL_SCANCODE_BACKSLASH] =3D Q_KEY_CODE_BACKSLASH, -#if 0 - [SDL_SCANCODE_NONUSHASH] =3D Q_KEY_CODE_NONUSHASH, -#endif - [SDL_SCANCODE_SEMICOLON] =3D Q_KEY_CODE_SEMICOLON, - [SDL_SCANCODE_APOSTROPHE] =3D Q_KEY_CODE_APOSTROPHE, - [SDL_SCANCODE_GRAVE] =3D Q_KEY_CODE_GRAVE_ACCENT, - [SDL_SCANCODE_COMMA] =3D Q_KEY_CODE_COMMA, - [SDL_SCANCODE_PERIOD] =3D Q_KEY_CODE_DOT, - [SDL_SCANCODE_SLASH] =3D Q_KEY_CODE_SLASH, - [SDL_SCANCODE_CAPSLOCK] =3D Q_KEY_CODE_CAPS_LOCK, - - [SDL_SCANCODE_F1] =3D Q_KEY_CODE_F1, - [SDL_SCANCODE_F2] =3D Q_KEY_CODE_F2, - [SDL_SCANCODE_F3] =3D Q_KEY_CODE_F3, - [SDL_SCANCODE_F4] =3D Q_KEY_CODE_F4, - [SDL_SCANCODE_F5] =3D Q_KEY_CODE_F5, - [SDL_SCANCODE_F6] =3D Q_KEY_CODE_F6, - [SDL_SCANCODE_F7] =3D Q_KEY_CODE_F7, - [SDL_SCANCODE_F8] =3D Q_KEY_CODE_F8, - [SDL_SCANCODE_F9] =3D Q_KEY_CODE_F9, - [SDL_SCANCODE_F10] =3D Q_KEY_CODE_F10, - [SDL_SCANCODE_F11] =3D Q_KEY_CODE_F11, - [SDL_SCANCODE_F12] =3D Q_KEY_CODE_F12, - - [SDL_SCANCODE_PRINTSCREEN] =3D Q_KEY_CODE_PRINT, - [SDL_SCANCODE_SCROLLLOCK] =3D Q_KEY_CODE_SCROLL_LOCK, - [SDL_SCANCODE_PAUSE] =3D Q_KEY_CODE_PAUSE, - [SDL_SCANCODE_INSERT] =3D Q_KEY_CODE_INSERT, - [SDL_SCANCODE_HOME] =3D Q_KEY_CODE_HOME, - [SDL_SCANCODE_PAGEUP] =3D Q_KEY_CODE_PGUP, - [SDL_SCANCODE_DELETE] =3D Q_KEY_CODE_DELETE, - [SDL_SCANCODE_END] =3D Q_KEY_CODE_END, - [SDL_SCANCODE_PAGEDOWN] =3D Q_KEY_CODE_PGDN, - [SDL_SCANCODE_RIGHT] =3D Q_KEY_CODE_RIGHT, - [SDL_SCANCODE_LEFT] =3D Q_KEY_CODE_LEFT, - [SDL_SCANCODE_DOWN] =3D Q_KEY_CODE_DOWN, - [SDL_SCANCODE_UP] =3D Q_KEY_CODE_UP, - [SDL_SCANCODE_NUMLOCKCLEAR] =3D Q_KEY_CODE_NUM_LOCK, - - [SDL_SCANCODE_KP_DIVIDE] =3D Q_KEY_CODE_KP_DIVIDE, - [SDL_SCANCODE_KP_MULTIPLY] =3D Q_KEY_CODE_KP_MULTIPLY, - [SDL_SCANCODE_KP_MINUS] =3D Q_KEY_CODE_KP_SUBTRACT, - [SDL_SCANCODE_KP_PLUS] =3D Q_KEY_CODE_KP_ADD, - [SDL_SCANCODE_KP_ENTER] =3D Q_KEY_CODE_KP_ENTER, - [SDL_SCANCODE_KP_1] =3D Q_KEY_CODE_KP_1, - [SDL_SCANCODE_KP_2] =3D Q_KEY_CODE_KP_2, - [SDL_SCANCODE_KP_3] =3D Q_KEY_CODE_KP_3, - [SDL_SCANCODE_KP_4] =3D Q_KEY_CODE_KP_4, - [SDL_SCANCODE_KP_5] =3D Q_KEY_CODE_KP_5, - [SDL_SCANCODE_KP_6] =3D Q_KEY_CODE_KP_6, - [SDL_SCANCODE_KP_7] =3D Q_KEY_CODE_KP_7, - [SDL_SCANCODE_KP_8] =3D Q_KEY_CODE_KP_8, - [SDL_SCANCODE_KP_9] =3D Q_KEY_CODE_KP_9, - [SDL_SCANCODE_KP_0] =3D Q_KEY_CODE_KP_0, - [SDL_SCANCODE_KP_PERIOD] =3D Q_KEY_CODE_KP_DECIMAL, - - [SDL_SCANCODE_NONUSBACKSLASH] =3D Q_KEY_CODE_LESS, - [SDL_SCANCODE_APPLICATION] =3D Q_KEY_CODE_MENU, -#if 0 - [SDL_SCANCODE_POWER] =3D Q_KEY_CODE_POWER, - [SDL_SCANCODE_KP_EQUALS] =3D Q_KEY_CODE_KP_EQUALS, - - [SDL_SCANCODE_F13] =3D Q_KEY_CODE_F13, - [SDL_SCANCODE_F14] =3D Q_KEY_CODE_F14, - [SDL_SCANCODE_F15] =3D Q_KEY_CODE_F15, - [SDL_SCANCODE_F16] =3D Q_KEY_CODE_F16, - [SDL_SCANCODE_F17] =3D Q_KEY_CODE_F17, - [SDL_SCANCODE_F18] =3D Q_KEY_CODE_F18, - [SDL_SCANCODE_F19] =3D Q_KEY_CODE_F19, - [SDL_SCANCODE_F20] =3D Q_KEY_CODE_F20, - [SDL_SCANCODE_F21] =3D Q_KEY_CODE_F21, - [SDL_SCANCODE_F22] =3D Q_KEY_CODE_F22, - [SDL_SCANCODE_F23] =3D Q_KEY_CODE_F23, - [SDL_SCANCODE_F24] =3D Q_KEY_CODE_F24, - - [SDL_SCANCODE_EXECUTE] =3D Q_KEY_CODE_EXECUTE, -#endif - [SDL_SCANCODE_HELP] =3D Q_KEY_CODE_HELP, - [SDL_SCANCODE_MENU] =3D Q_KEY_CODE_MENU, -#if 0 - [SDL_SCANCODE_SELECT] =3D Q_KEY_CODE_SELECT, -#endif - [SDL_SCANCODE_STOP] =3D Q_KEY_CODE_STOP, - [SDL_SCANCODE_AGAIN] =3D Q_KEY_CODE_AGAIN, - [SDL_SCANCODE_UNDO] =3D Q_KEY_CODE_UNDO, - [SDL_SCANCODE_CUT] =3D Q_KEY_CODE_CUT, - [SDL_SCANCODE_COPY] =3D Q_KEY_CODE_COPY, - [SDL_SCANCODE_PASTE] =3D Q_KEY_CODE_PASTE, - [SDL_SCANCODE_FIND] =3D Q_KEY_CODE_FIND, -#if 0 - [SDL_SCANCODE_MUTE] =3D Q_KEY_CODE_MUTE, - [SDL_SCANCODE_VOLUMEUP] =3D Q_KEY_CODE_VOLUMEUP, - [SDL_SCANCODE_VOLUMEDOWN] =3D Q_KEY_CODE_VOLUMEDOWN, - - [SDL_SCANCODE_KP_COMMA] =3D Q_KEY_CODE_KP_COMMA, - [SDL_SCANCODE_KP_EQUALSAS400] =3D Q_KEY_CODE_KP_EQUALSAS400, - - [SDL_SCANCODE_INTERNATIONAL1] =3D Q_KEY_CODE_INTERNATIONAL1, - [SDL_SCANCODE_INTERNATIONAL2] =3D Q_KEY_CODE_INTERNATIONAL2, - [SDL_SCANCODE_INTERNATIONAL3] =3D Q_KEY_CODE_INTERNATIONAL3, - [SDL_SCANCODE_INTERNATIONAL4] =3D Q_KEY_CODE_INTERNATIONAL4, - [SDL_SCANCODE_INTERNATIONAL5] =3D Q_KEY_CODE_INTERNATIONAL5, - [SDL_SCANCODE_INTERNATIONAL6] =3D Q_KEY_CODE_INTERNATIONAL6, - [SDL_SCANCODE_INTERNATIONAL7] =3D Q_KEY_CODE_INTERNATIONAL7, - [SDL_SCANCODE_INTERNATIONAL8] =3D Q_KEY_CODE_INTERNATIONAL8, - [SDL_SCANCODE_INTERNATIONAL9] =3D Q_KEY_CODE_INTERNATIONAL9, - [SDL_SCANCODE_LANG1] =3D Q_KEY_CODE_LANG1, - [SDL_SCANCODE_LANG2] =3D Q_KEY_CODE_LANG2, - [SDL_SCANCODE_LANG3] =3D Q_KEY_CODE_LANG3, - [SDL_SCANCODE_LANG4] =3D Q_KEY_CODE_LANG4, - [SDL_SCANCODE_LANG5] =3D Q_KEY_CODE_LANG5, - [SDL_SCANCODE_LANG6] =3D Q_KEY_CODE_LANG6, - [SDL_SCANCODE_LANG7] =3D Q_KEY_CODE_LANG7, - [SDL_SCANCODE_LANG8] =3D Q_KEY_CODE_LANG8, - [SDL_SCANCODE_LANG9] =3D Q_KEY_CODE_LANG9, - [SDL_SCANCODE_ALTERASE] =3D Q_KEY_CODE_ALTERASE, -#endif - [SDL_SCANCODE_SYSREQ] =3D Q_KEY_CODE_SYSRQ, -#if 0 - [SDL_SCANCODE_CANCEL] =3D Q_KEY_CODE_CANCEL, - [SDL_SCANCODE_CLEAR] =3D Q_KEY_CODE_CLEAR, - [SDL_SCANCODE_PRIOR] =3D Q_KEY_CODE_PRIOR, - [SDL_SCANCODE_RETURN2] =3D Q_KEY_CODE_RETURN2, - [SDL_SCANCODE_SEPARATOR] =3D Q_KEY_CODE_SEPARATOR, - [SDL_SCANCODE_OUT] =3D Q_KEY_CODE_OUT, - [SDL_SCANCODE_OPER] =3D Q_KEY_CODE_OPER, - [SDL_SCANCODE_CLEARAGAIN] =3D Q_KEY_CODE_CLEARAGAIN, - [SDL_SCANCODE_CRSEL] =3D Q_KEY_CODE_CRSEL, - [SDL_SCANCODE_EXSEL] =3D Q_KEY_CODE_EXSEL, - [SDL_SCANCODE_KP_00] =3D Q_KEY_CODE_KP_00, - [SDL_SCANCODE_KP_000] =3D Q_KEY_CODE_KP_000, - [SDL_SCANCODE_THOUSANDSSEPARATOR] =3D Q_KEY_CODE_THOUSANDSSEPARATOR, - [SDL_SCANCODE_DECIMALSEPARATOR] =3D Q_KEY_CODE_DECIMALSEPARATOR, - [SDL_SCANCODE_CURRENCYUNIT] =3D Q_KEY_CODE_CURRENCYUNIT, - [SDL_SCANCODE_CURRENCYSUBUNIT] =3D Q_KEY_CODE_CURRENCYSUBUNIT, - [SDL_SCANCODE_KP_LEFTPAREN] =3D Q_KEY_CODE_KP_LEFTPAREN, - [SDL_SCANCODE_KP_RIGHTPAREN] =3D Q_KEY_CODE_KP_RIGHTPAREN, - [SDL_SCANCODE_KP_LEFTBRACE] =3D Q_KEY_CODE_KP_LEFTBRACE, - [SDL_SCANCODE_KP_RIGHTBRACE] =3D Q_KEY_CODE_KP_RIGHTBRACE, - [SDL_SCANCODE_KP_TAB] =3D Q_KEY_CODE_KP_TAB, - [SDL_SCANCODE_KP_BACKSPACE] =3D Q_KEY_CODE_KP_BACKSPACE, - [SDL_SCANCODE_KP_A] =3D Q_KEY_CODE_KP_A, - [SDL_SCANCODE_KP_B] =3D Q_KEY_CODE_KP_B, - [SDL_SCANCODE_KP_C] =3D Q_KEY_CODE_KP_C, - [SDL_SCANCODE_KP_D] =3D Q_KEY_CODE_KP_D, - [SDL_SCANCODE_KP_E] =3D Q_KEY_CODE_KP_E, - [SDL_SCANCODE_KP_F] =3D Q_KEY_CODE_KP_F, - [SDL_SCANCODE_KP_XOR] =3D Q_KEY_CODE_KP_XOR, - [SDL_SCANCODE_KP_POWER] =3D Q_KEY_CODE_KP_POWER, - [SDL_SCANCODE_KP_PERCENT] =3D Q_KEY_CODE_KP_PERCENT, - [SDL_SCANCODE_KP_LESS] =3D Q_KEY_CODE_KP_LESS, - [SDL_SCANCODE_KP_GREATER] =3D Q_KEY_CODE_KP_GREATER, - [SDL_SCANCODE_KP_AMPERSAND] =3D Q_KEY_CODE_KP_AMPERSAND, - [SDL_SCANCODE_KP_DBLAMPERSAND] =3D Q_KEY_CODE_KP_DBLAMPERSAND, - [SDL_SCANCODE_KP_VERTICALBAR] =3D Q_KEY_CODE_KP_VERTICALBAR, - [SDL_SCANCODE_KP_DBLVERTICALBAR] =3D Q_KEY_CODE_KP_DBLVERTICALBAR, - [SDL_SCANCODE_KP_COLON] =3D Q_KEY_CODE_KP_COLON, - [SDL_SCANCODE_KP_HASH] =3D Q_KEY_CODE_KP_HASH, - [SDL_SCANCODE_KP_SPACE] =3D Q_KEY_CODE_KP_SPACE, - [SDL_SCANCODE_KP_AT] =3D Q_KEY_CODE_KP_AT, - [SDL_SCANCODE_KP_EXCLAM] =3D Q_KEY_CODE_KP_EXCLAM, - [SDL_SCANCODE_KP_MEMSTORE] =3D Q_KEY_CODE_KP_MEMSTORE, - [SDL_SCANCODE_KP_MEMRECALL] =3D Q_KEY_CODE_KP_MEMRECALL, - [SDL_SCANCODE_KP_MEMCLEAR] =3D Q_KEY_CODE_KP_MEMCLEAR, - [SDL_SCANCODE_KP_MEMADD] =3D Q_KEY_CODE_KP_MEMADD, - [SDL_SCANCODE_KP_MEMSUBTRACT] =3D Q_KEY_CODE_KP_MEMSUBTRACT, - [SDL_SCANCODE_KP_MEMMULTIPLY] =3D Q_KEY_CODE_KP_MEMMULTIPLY, - [SDL_SCANCODE_KP_MEMDIVIDE] =3D Q_KEY_CODE_KP_MEMDIVIDE, - [SDL_SCANCODE_KP_PLUSMINUS] =3D Q_KEY_CODE_KP_PLUSMINUS, - [SDL_SCANCODE_KP_CLEAR] =3D Q_KEY_CODE_KP_CLEAR, - [SDL_SCANCODE_KP_CLEARENTRY] =3D Q_KEY_CODE_KP_CLEARENTRY, - [SDL_SCANCODE_KP_BINARY] =3D Q_KEY_CODE_KP_BINARY, - [SDL_SCANCODE_KP_OCTAL] =3D Q_KEY_CODE_KP_OCTAL, - [SDL_SCANCODE_KP_DECIMAL] =3D Q_KEY_CODE_KP_DECIMAL, - [SDL_SCANCODE_KP_HEXADECIMAL] =3D Q_KEY_CODE_KP_HEXADECIMAL, -#endif - [SDL_SCANCODE_LCTRL] =3D Q_KEY_CODE_CTRL, - [SDL_SCANCODE_LSHIFT] =3D Q_KEY_CODE_SHIFT, - [SDL_SCANCODE_LALT] =3D Q_KEY_CODE_ALT, - [SDL_SCANCODE_LGUI] =3D Q_KEY_CODE_META_L, - [SDL_SCANCODE_RCTRL] =3D Q_KEY_CODE_CTRL_R, - [SDL_SCANCODE_RSHIFT] =3D Q_KEY_CODE_SHIFT_R, - [SDL_SCANCODE_RALT] =3D Q_KEY_CODE_ALT_R, - [SDL_SCANCODE_RGUI] =3D Q_KEY_CODE_META_R, -#if 0 - [SDL_SCANCODE_MODE] =3D Q_KEY_CODE_MODE, - [SDL_SCANCODE_AUDIONEXT] =3D Q_KEY_CODE_AUDIONEXT, - [SDL_SCANCODE_AUDIOPREV] =3D Q_KEY_CODE_AUDIOPREV, - [SDL_SCANCODE_AUDIOSTOP] =3D Q_KEY_CODE_AUDIOSTOP, - [SDL_SCANCODE_AUDIOPLAY] =3D Q_KEY_CODE_AUDIOPLAY, - [SDL_SCANCODE_AUDIOMUTE] =3D Q_KEY_CODE_AUDIOMUTE, - [SDL_SCANCODE_MEDIASELECT] =3D Q_KEY_CODE_MEDIASELECT, - [SDL_SCANCODE_WWW] =3D Q_KEY_CODE_WWW, - [SDL_SCANCODE_MAIL] =3D Q_KEY_CODE_MAIL, - [SDL_SCANCODE_CALCULATOR] =3D Q_KEY_CODE_CALCULATOR, - [SDL_SCANCODE_COMPUTER] =3D Q_KEY_CODE_COMPUTER, - [SDL_SCANCODE_AC_SEARCH] =3D Q_KEY_CODE_AC_SEARCH, - [SDL_SCANCODE_AC_HOME] =3D Q_KEY_CODE_AC_HOME, - [SDL_SCANCODE_AC_BACK] =3D Q_KEY_CODE_AC_BACK, - [SDL_SCANCODE_AC_FORWARD] =3D Q_KEY_CODE_AC_FORWARD, - [SDL_SCANCODE_AC_STOP] =3D Q_KEY_CODE_AC_STOP, - [SDL_SCANCODE_AC_REFRESH] =3D Q_KEY_CODE_AC_REFRESH, - [SDL_SCANCODE_AC_BOOKMARKS] =3D Q_KEY_CODE_AC_BOOKMARKS, - [SDL_SCANCODE_BRIGHTNESSDOWN] =3D Q_KEY_CODE_BRIGHTNESSDOWN, - [SDL_SCANCODE_BRIGHTNESSUP] =3D Q_KEY_CODE_BRIGHTNESSUP, - [SDL_SCANCODE_DISPLAYSWITCH] =3D Q_KEY_CODE_DISPLAYSWITCH, - [SDL_SCANCODE_KBDILLUMTOGGLE] =3D Q_KEY_CODE_KBDILLUMTOGGLE, - [SDL_SCANCODE_KBDILLUMDOWN] =3D Q_KEY_CODE_KBDILLUMDOWN, - [SDL_SCANCODE_KBDILLUMUP] =3D Q_KEY_CODE_KBDILLUMUP, - [SDL_SCANCODE_EJECT] =3D Q_KEY_CODE_EJECT, - [SDL_SCANCODE_SLEEP] =3D Q_KEY_CODE_SLEEP, - [SDL_SCANCODE_APP1] =3D Q_KEY_CODE_APP1, - [SDL_SCANCODE_APP2] =3D Q_KEY_CODE_APP2, -#endif -}; diff --git a/ui/input-keymap.c b/ui/input-keymap.c index 663986a17b..3be6dedea5 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -9,6 +9,7 @@ #include "ui/input-keymap-qcode-to-qnum.c" #include "ui/input-keymap-qnum-to-qcode.c" #include "ui/input-keymap-qcode-to-linux.c" +#include "ui/input-keymap-usb-to-qcode.c" =20 int qemu_input_linux_to_qcode(unsigned int lnx) { diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c index 6e315ae800..605d781971 100644 --- a/ui/sdl2-input.c +++ b/ui/sdl2-input.c @@ -30,8 +30,6 @@ #include "ui/sdl2.h" #include "sysemu/sysemu.h" =20 -#include "sdl2-keymap.h" - static uint8_t modifiers_state[SDL_NUM_SCANCODES]; =20 void sdl2_reset_keys(struct sdl2_console *scon) @@ -39,9 +37,11 @@ void sdl2_reset_keys(struct sdl2_console *scon) QemuConsole *con =3D scon ? scon->dcl.con : NULL; int i; =20 - for (i =3D 0; i < SDL_NUM_SCANCODES; i++) { + for (i =3D 0 ; + i < SDL_NUM_SCANCODES && i < qemu_input_map_usb_to_qcode_len ; + i++) { if (modifiers_state[i]) { - int qcode =3D sdl2_scancode_to_qcode[i]; + int qcode =3D qemu_input_map_usb_to_qcode[i]; qemu_input_event_send_key_qcode(con, qcode, false); modifiers_state[i] =3D 0; } @@ -51,9 +51,15 @@ void sdl2_reset_keys(struct sdl2_console *scon) void sdl2_process_key(struct sdl2_console *scon, SDL_KeyboardEvent *ev) { - int qcode =3D sdl2_scancode_to_qcode[ev->keysym.scancode]; + int qcode; QemuConsole *con =3D scon ? scon->dcl.con : NULL; =20 + if (ev->keysym.scancode >=3D qemu_input_map_usb_to_qcode_len) { + return; + } + + qcode =3D qemu_input_map_usb_to_qcode[ev->keysym.scancode]; + if (!qemu_console_is_graphic(con)) { if (ev->type =3D=3D SDL_KEYDOWN) { switch (ev->keysym.scancode) { --=20 2.9.3 From nobody Sun May 5 02:44:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516890973161486.5366191673129; Thu, 25 Jan 2018 06:36:13 -0800 (PST) Received: from localhost ([::1]:44005 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeidQ-000827-B1 for importer@patchew.org; Thu, 25 Jan 2018 09:36:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeiZn-0005Tv-OS for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeiZk-0006ri-6n for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42346) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eeiZj-0006qT-Sp for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:24 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2B6026516B for ; Thu, 25 Jan 2018 14:32:23 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id A75B3608F3; Thu, 25 Jan 2018 14:32:19 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 03E4D11ABE; Thu, 25 Jan 2018 15:32:19 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 25 Jan 2018 15:32:13 +0100 Message-Id: <20180125143218.29528-4-kraxel@redhat.com> In-Reply-To: <20180125143218.29528-1-kraxel@redhat.com> References: <20180125143218.29528-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 25 Jan 2018 14:32:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/8] ui: convert GTK and SDL1 frontends to keycodemapdb X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The x_keycode_to_pc_keycode and evdev_keycode_to_pc_keycode tables are replaced with automatically generated tables. In addition the X11 heuristics are improved to detect running on XQuartz and XWin X11 servers, to activate the correct OS-X and Win32 keycode maps. Signed-off-by: Daniel P. Berrange Message-id: 20180117164717.15855-3-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- Makefile | 7 ++ include/ui/input.h | 21 +++++ ui/x_keymap.h | 8 +- ui/gtk.c | 205 +++++++++++++++++++++++++------------------ ui/input-keymap.c | 7 ++ ui/sdl.c | 105 +++++++--------------- ui/x_keymap.c | 250 ++++++++++++++++++++-----------------------------= ---- ui/Makefile.objs | 5 +- ui/trace-events | 9 +- 9 files changed, 300 insertions(+), 317 deletions(-) diff --git a/Makefile b/Makefile index 24ed2b3e63..af31e8981f 100644 --- a/Makefile +++ b/Makefile @@ -232,11 +232,18 @@ KEYCODEMAP_GEN =3D $(SRC_PATH)/ui/keycodemapdb/tools/= keymap-gen KEYCODEMAP_CSV =3D $(SRC_PATH)/ui/keycodemapdb/data/keymaps.csv =20 KEYCODEMAP_FILES =3D \ + ui/input-keymap-atset1-to-qcode.c \ ui/input-keymap-linux-to-qcode.c \ ui/input-keymap-qcode-to-qnum.c \ ui/input-keymap-qnum-to-qcode.c \ ui/input-keymap-qcode-to-linux.c \ ui/input-keymap-usb-to-qcode.c \ + ui/input-keymap-win32-to-qcode.c \ + ui/input-keymap-x11-to-qcode.c \ + ui/input-keymap-xorgevdev-to-qcode.c \ + ui/input-keymap-xorgkbd-to-qcode.c \ + ui/input-keymap-xorgxquartz-to-qcode.c \ + ui/input-keymap-xorgxwin-to-qcode.c \ $(NULL) =20 GENERATED_FILES +=3D $(KEYCODEMAP_FILES) diff --git a/include/ui/input.h b/include/ui/input.h index 0d289e4142..05aab2db5c 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -68,6 +68,9 @@ void qemu_input_check_mode_change(void); void qemu_add_mouse_mode_change_notifier(Notifier *notify); void qemu_remove_mouse_mode_change_notifier(Notifier *notify); =20 +extern const guint qemu_input_map_atset1_to_qcode_len; +extern const guint16 qemu_input_map_atset1_to_qcode[]; + extern const guint qemu_input_map_linux_to_qcode_len; extern const guint16 qemu_input_map_linux_to_qcode[]; =20 @@ -83,4 +86,22 @@ extern const guint16 qemu_input_map_qcode_to_linux[]; extern const guint qemu_input_map_usb_to_qcode_len; extern const guint16 qemu_input_map_usb_to_qcode[]; =20 +extern const guint qemu_input_map_win32_to_qcode_len; +extern const guint16 qemu_input_map_win32_to_qcode[]; + +extern const guint qemu_input_map_x11_to_qcode_len; +extern const guint16 qemu_input_map_x11_to_qcode[]; + +extern const guint qemu_input_map_xorgevdev_to_qcode_len; +extern const guint16 qemu_input_map_xorgevdev_to_qcode[]; + +extern const guint qemu_input_map_xorgkbd_to_qcode_len; +extern const guint16 qemu_input_map_xorgkbd_to_qcode[]; + +extern const guint qemu_input_map_xorgxquartz_to_qcode_len; +extern const guint16 qemu_input_map_xorgxquartz_to_qcode[]; + +extern const guint qemu_input_map_xorgxwin_to_qcode_len; +extern const guint16 qemu_input_map_xorgxwin_to_qcode[]; + #endif /* INPUT_H */ diff --git a/ui/x_keymap.h b/ui/x_keymap.h index afde2e94bf..0395e335ff 100644 --- a/ui/x_keymap.h +++ b/ui/x_keymap.h @@ -1,7 +1,7 @@ /* - * QEMU SDL display driver + * QEMU X11 keymaps * - * Copyright (c) 2003 Fabrice Bellard + * Copyright (c) 2017 Red Hat, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a= copy * of this software and associated documentation files (the "Software"), t= o deal @@ -25,8 +25,8 @@ #ifndef QEMU_X_KEYMAP_H #define QEMU_X_KEYMAP_H =20 -uint8_t translate_xfree86_keycode(const int key); +#include =20 -uint8_t translate_evdev_keycode(const int key); +const guint16 *qemu_xkeymap_mapping_table(Display *dpy, size_t *maplen); =20 #endif diff --git a/ui/gtk.c b/ui/gtk.c index f3b7567984..1217160724 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -52,7 +52,6 @@ #include "ui/input.h" #include "sysemu/sysemu.h" #include "qmp-commands.h" -#include "x_keymap.h" #include "keymaps.h" #include "chardev/char.h" #include "qom/object.h" @@ -65,6 +64,48 @@ #define VC_SCALE_MIN 0.25 #define VC_SCALE_STEP 0.25 =20 +#ifdef GDK_WINDOWING_X11 +#include "ui/x_keymap.h" + +/* Gtk2 compat */ +#ifndef GDK_IS_X11_DISPLAY +#define GDK_IS_X11_DISPLAY(dpy) (dpy !=3D NULL) +#endif +#endif + + +#ifdef GDK_WINDOWING_WAYLAND +/* Gtk2 compat */ +#ifndef GDK_IS_WAYLAND_DISPLAY +#define GDK_IS_WAYLAND_DISPLAY(dpy) (dpy !=3D NULL) +#endif +#endif + + +#ifdef GDK_WINDOWING_WIN32 +/* Gtk2 compat */ +#ifndef GDK_IS_WIN32_DISPLAY +#define GDK_IS_WIN32_DISPLAY(dpy) (dpy !=3D NULL) +#endif +#endif + + +#ifdef GDK_WINDOWING_BROADWAY +/* Gtk2 compat */ +#ifndef GDK_IS_BROADWAY_DISPLAY +#define GDK_IS_BROADWAY_DISPLAY(dpy) (dpy !=3D NULL) +#endif +#endif + + +#ifdef GDK_WINDOWING_QUARTZ +/* Gtk2 compat */ +#ifndef GDK_IS_QUARTZ_DISPLAY +#define GDK_IS_QUARTZ_DISPLAY(dpy) (dpy !=3D NULL) +#endif +#endif + + #if !defined(CONFIG_VTE) # define VTE_CHECK_VERSION(a, b, c) 0 #endif @@ -123,10 +164,19 @@ #define HOTKEY_MODIFIERS (GDK_CONTROL_MASK | GDK_MOD1_MASK) =20 static const int modifier_keycode[] =3D { - /* shift, control, alt keys, meta keys, both left & right */ - 0x2a, 0x36, 0x1d, 0x9d, 0x38, 0xb8, 0xdb, 0xdd, + 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, }; =20 +static const guint16 *keycode_map; +static size_t keycode_maplen; + struct GtkDisplayState { GtkWidget *window; =20 @@ -178,7 +228,6 @@ struct GtkDisplayState { bool external_pause_update; =20 bool modifier_pressed[ARRAY_SIZE(modifier_keycode)]; - bool has_evdev; bool ignore_keys; }; =20 @@ -412,18 +461,18 @@ static void gd_update_full_redraw(VirtualConsole *vc) static void gtk_release_modifiers(GtkDisplayState *s) { VirtualConsole *vc =3D gd_vc_find_current(s); - int i, keycode; + int i, qcode; =20 if (vc->type !=3D GD_VC_GFX || !qemu_console_is_graphic(vc->gfx.dcl.con)) { return; } for (i =3D 0; i < ARRAY_SIZE(modifier_keycode); i++) { - keycode =3D modifier_keycode[i]; + qcode =3D modifier_keycode[i]; if (!s->modifier_pressed[i]) { continue; } - qemu_input_event_send_key_number(vc->gfx.dcl.con, keycode, false); + qemu_input_event_send_key_qcode(vc->gfx.dcl.con, qcode, false); s->modifier_pressed[i] =3D false; } } @@ -1057,47 +1106,75 @@ static gboolean gd_scroll_event(GtkWidget *widget, = GdkEventScroll *scroll, return TRUE; } =20 -static int gd_map_keycode(GtkDisplayState *s, GdkDisplay *dpy, int gdk_key= code) + +static const guint16 *gd_get_keymap(size_t *maplen) { - int qemu_keycode; + GdkDisplay *dpy =3D gdk_display_get_default(); + +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_X11_DISPLAY(dpy)) { + trace_gd_keymap_windowing("x11"); + return qemu_xkeymap_mapping_table( + gdk_x11_display_get_xdisplay(dpy), maplen); + } +#endif + +#ifdef GDK_WINDOWING_WAYLAND + if (GDK_IS_WAYLAND_DISPLAY(dpy)) { + trace_gd_keymap_windowing("wayland"); + *maplen =3D qemu_input_map_xorgevdev_to_qcode_len; + return qemu_input_map_xorgevdev_to_qcode; + } +#endif =20 #ifdef GDK_WINDOWING_WIN32 if (GDK_IS_WIN32_DISPLAY(dpy)) { - qemu_keycode =3D MapVirtualKey(gdk_keycode, MAPVK_VK_TO_VSC); - switch (qemu_keycode) { - case 103: /* alt gr */ - qemu_keycode =3D 56 | SCANCODE_GREY; - break; - } - return qemu_keycode; + trace_gd_keymap_windowing("win32"); + *maplen =3D qemu_input_map_win32_to_qcode_len; + return qemu_input_map_win32_to_qcode; } #endif =20 - if (gdk_keycode < 9) { - qemu_keycode =3D 0; - } else if (gdk_keycode < 97) { - qemu_keycode =3D gdk_keycode - 8; -#ifdef GDK_WINDOWING_X11 - } else if (GDK_IS_X11_DISPLAY(dpy) && gdk_keycode < 158) { - if (s->has_evdev) { - qemu_keycode =3D translate_evdev_keycode(gdk_keycode - 97); - } else { - qemu_keycode =3D translate_xfree86_keycode(gdk_keycode - 97); - } +#ifdef GDK_WINDOWING_QUARTZ + if (GDK_IS_QUARTZ_DISPLAY(dpy)) { + trace_gd_keymap_windowing("quartz"); + *maplen =3D qemu_input_map_osx_to_qcode_len; + return qemu_input_map_osx_to_qcode; + } #endif -#ifdef GDK_WINDOWING_WAYLAND - } else if (GDK_IS_WAYLAND_DISPLAY(dpy) && gdk_keycode < 158) { - qemu_keycode =3D translate_evdev_keycode(gdk_keycode - 97); + +#ifdef GDK_WINDOWING_BROADWAY + if (GDK_IS_BROADWAY_DISPLAY(dpy)) { + trace_gd_keymap_windowing("broadway"); + g_warning("experimental: using broadway, x11 virtual keysym\n" + "mapping - with very limited support. See also\n" + "https://bugzilla.gnome.org/show_bug.cgi?id=3D700105"); + *maplen =3D qemu_input_map_x11_to_qcode_len; + return qemu_input_map_x11_to_qcode; + } #endif - } else if (gdk_keycode =3D=3D 208) { /* Hiragana_Katakana */ - qemu_keycode =3D 0x70; - } else if (gdk_keycode =3D=3D 211) { /* backslash */ - qemu_keycode =3D 0x73; - } else { - qemu_keycode =3D 0; + + g_warning("Unsupported GDK Windowing platform.\n" + "Disabling extended keycode tables.\n" + "Please report to qemu-devel@nongnu.org\n" + "including the following information:\n" + "\n" + " - Operating system\n" + " - GDK Windowing system build\n"); + return NULL; +} + + +static int gd_map_keycode(int scancode) +{ + if (!keycode_map) { + return 0; + } + if (scancode > keycode_maplen) { + return 0; } =20 - return qemu_keycode; + return keycode_map[scancode]; } =20 static gboolean gd_text_key_down(GtkWidget *widget, @@ -1111,9 +1188,7 @@ static gboolean gd_text_key_down(GtkWidget *widget, } else if (key->length) { kbd_put_string_console(con, key->string, key->length); } else { - int num =3D gd_map_keycode(vc->s, gtk_widget_get_display(widget), - key->hardware_keycode); - int qcode =3D qemu_input_key_number_to_qcode(num); + int qcode =3D gd_map_keycode(key->hardware_keycode); kbd_put_qcode_console(con, qcode); } return TRUE; @@ -1123,8 +1198,7 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEv= entKey *key, void *opaque) { VirtualConsole *vc =3D opaque; GtkDisplayState *s =3D vc->s; - int gdk_keycode =3D key->hardware_keycode; - int qemu_keycode; + int qcode; int i; =20 if (s->ignore_keys) { @@ -1138,20 +1212,19 @@ static gboolean gd_key_event(GtkWidget *widget, Gdk= EventKey *key, void *opaque) return TRUE; } =20 - qemu_keycode =3D gd_map_keycode(s, gtk_widget_get_display(widget), - gdk_keycode); + qcode =3D gd_map_keycode(key->hardware_keycode); =20 - trace_gd_key_event(vc->label, gdk_keycode, qemu_keycode, + trace_gd_key_event(vc->label, key->hardware_keycode, qcode, (key->type =3D=3D GDK_KEY_PRESS) ? "down" : "up"); =20 for (i =3D 0; i < ARRAY_SIZE(modifier_keycode); i++) { - if (qemu_keycode =3D=3D modifier_keycode[i]) { + if (qcode =3D=3D modifier_keycode[i]) { s->modifier_pressed[i] =3D (key->type =3D=3D GDK_KEY_PRESS); } } =20 - qemu_input_event_send_key_number(vc->gfx.dcl.con, qemu_keycode, - key->type =3D=3D GDK_KEY_PRESS); + qemu_input_event_send_key_qcode(vc->gfx.dcl.con, qcode, + key->type =3D=3D GDK_KEY_PRESS); =20 return TRUE; } @@ -2200,38 +2273,6 @@ static void gd_create_menus(GtkDisplayState *s) gtk_window_add_accel_group(GTK_WINDOW(s->window), s->accel_group); } =20 -static void gd_set_keycode_type(GtkDisplayState *s) -{ -#ifdef GDK_WINDOWING_X11 - GdkDisplay *display =3D gtk_widget_get_display(s->window); - if (GDK_IS_X11_DISPLAY(display)) { - Display *x11_display =3D gdk_x11_display_get_xdisplay(display); - XkbDescPtr desc =3D XkbGetMap(x11_display, XkbGBN_AllComponentsMas= k, - XkbUseCoreKbd); - char *keycodes =3D NULL; - - if (desc && - (XkbGetNames(x11_display, XkbKeycodesNameMask, desc) =3D=3D Su= ccess)) { - keycodes =3D XGetAtomName(x11_display, desc->names->keycodes); - } - if (keycodes =3D=3D NULL) { - fprintf(stderr, "could not lookup keycode name\n"); - } else if (strstart(keycodes, "evdev", NULL)) { - s->has_evdev =3D true; - } else if (!strstart(keycodes, "xfree86", NULL)) { - fprintf(stderr, "unknown keycodes `%s', please report to " - "qemu-devel@nongnu.org\n", keycodes); - } - - if (desc) { - XkbFreeKeyboard(desc, XkbGBN_AllComponentsMask, True); - } - if (keycodes) { - XFree(keycodes); - } - } -#endif -} =20 static gboolean gtkinit; =20 @@ -2339,8 +2380,6 @@ void gtk_display_init(DisplayState *ds, bool full_scr= een, bool grab_on_hover) if (grab_on_hover) { gtk_menu_item_activate(GTK_MENU_ITEM(s->grab_on_hover_item)); } - - gd_set_keycode_type(s); } =20 void early_gtk_display_init(int opengl) @@ -2387,6 +2426,8 @@ void early_gtk_display_init(int opengl) break; } =20 + keycode_map =3D gd_get_keymap(&keycode_maplen); + #if defined(CONFIG_VTE) type_register(&char_gd_vc_type_info); #endif diff --git a/ui/input-keymap.c b/ui/input-keymap.c index 3be6dedea5..95b1e0cbfa 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -5,11 +5,18 @@ =20 #include "standard-headers/linux/input.h" =20 +#include "ui/input-keymap-atset1-to-qcode.c" #include "ui/input-keymap-linux-to-qcode.c" #include "ui/input-keymap-qcode-to-qnum.c" #include "ui/input-keymap-qnum-to-qcode.c" #include "ui/input-keymap-qcode-to-linux.c" #include "ui/input-keymap-usb-to-qcode.c" +#include "ui/input-keymap-win32-to-qcode.c" +#include "ui/input-keymap-x11-to-qcode.c" +#include "ui/input-keymap-xorgevdev-to-qcode.c" +#include "ui/input-keymap-xorgkbd-to-qcode.c" +#include "ui/input-keymap-xorgxquartz-to-qcode.c" +#include "ui/input-keymap-xorgxwin-to-qcode.c" =20 int qemu_input_linux_to_qcode(unsigned int lnx) { diff --git a/ui/sdl.c b/ui/sdl.c index 7b71a9ac58..afb4992da2 100644 --- a/ui/sdl.c +++ b/ui/sdl.c @@ -34,7 +34,9 @@ #include "ui/console.h" #include "ui/input.h" #include "sysemu/sysemu.h" +#ifndef WIN32 #include "x_keymap.h" +#endif #include "sdl_zoom.h" =20 static DisplayChangeListener *dcl; @@ -63,6 +65,8 @@ static SDL_PixelFormat host_format; static int scaling_active =3D 0; static Notifier mouse_mode_notifier; static int idle_counter; +static const guint16 *keycode_map; +static size_t keycode_maplen; =20 #define SDL_REFRESH_INTERVAL_BUSY 10 #define SDL_MAX_IDLE_COUNT (2 * GUI_REFRESH_INTERVAL_DEFAULT \ @@ -208,95 +212,46 @@ static uint8_t sdl_keyevent_to_keycode_generic(const = SDL_KeyboardEvent *ev) return keysym2scancode(kbd_layout, keysym) & SCANCODE_KEYMASK; } =20 -/* specific keyboard conversions from scan codes */ =20 -#if defined(_WIN32) - -static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev) +static const guint16 *sdl_get_keymap(size_t *maplen) { - return ev->keysym.scancode; -} - +#if defined(WIN32) + *maplen =3D qemu_input_map_atset1_to_qcode_len; + return qemu_input_map_atset1_to_qcode; #else - #if defined(SDL_VIDEO_DRIVER_X11) -#include - -static int check_for_evdev(void) -{ SDL_SysWMinfo info; - XkbDescPtr desc =3D NULL; - int has_evdev =3D 0; - char *keycodes =3D NULL; =20 SDL_VERSION(&info.version); - if (!SDL_GetWMInfo(&info)) { - return 0; + if (SDL_GetWMInfo(&info) > 0) { + return qemu_xkeymap_mapping_table( + info.info.x11.display, maplen); } - desc =3D XkbGetMap(info.info.x11.display, - XkbGBN_AllComponentsMask, - XkbUseCoreKbd); - if (desc && - (XkbGetNames(info.info.x11.display, - XkbKeycodesNameMask, desc) =3D=3D Success)) { - keycodes =3D XGetAtomName(info.info.x11.display, desc->names->keyc= odes); - if (keycodes =3D=3D NULL) { - fprintf(stderr, "could not lookup keycode name\n"); - } else if (strstart(keycodes, "evdev", NULL)) { - has_evdev =3D 1; - } else if (!strstart(keycodes, "xfree86", NULL)) { - fprintf(stderr, "unknown keycodes `%s', please report to " - "qemu-devel@nongnu.org\n", keycodes); - } - } - - if (desc) { - XkbFreeKeyboard(desc, XkbGBN_AllComponentsMask, True); - } - if (keycodes) { - XFree(keycodes); - } - return has_evdev; -} -#else -static int check_for_evdev(void) -{ - return 0; -} #endif + g_warning("Unsupported SDL video driver / platform.\n" + "Assuming Linux KBD scancodes, but probably wrong.\n" + "Please report to qemu-devel@nongnu.org\n" + "including the following information:\n" + "\n" + " - Operating system\n" + " - SDL video driver\n"); + *maplen =3D qemu_input_map_xorgkbd_to_qcode_len; + return qemu_input_map_xorgkbd_to_qcode; +#endif +} =20 static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev) { - int keycode; - static int has_evdev =3D -1; - - if (has_evdev =3D=3D -1) - has_evdev =3D check_for_evdev(); - - keycode =3D ev->keysym.scancode; - - if (keycode < 9) { - keycode =3D 0; - } else if (keycode < 97) { - keycode -=3D 8; /* just an offset */ - } else if (keycode < 158) { - /* use conversion table */ - if (has_evdev) - keycode =3D translate_evdev_keycode(keycode - 97); - else - keycode =3D translate_xfree86_keycode(keycode - 97); - } else if (keycode =3D=3D 208) { /* Hiragana_Katakana */ - keycode =3D 0x70; - } else if (keycode =3D=3D 211) { /* backslash */ - keycode =3D 0x73; - } else { - keycode =3D 0; + if (!keycode_map) { + return 0; } - return keycode; + if (ev->keysym.scancode > keycode_maplen) { + return 0; + } + + return keycode_map[ev->keysym.scancode]; } =20 -#endif - static void reset_keys(void) { int i; @@ -995,6 +950,8 @@ void sdl_display_init(DisplayState *ds, int full_screen= , int no_frame) vi =3D SDL_GetVideoInfo(); host_format =3D *(vi->vfmt); =20 + keycode_map =3D sdl_get_keymap(&keycode_maplen); + /* Load a 32x32x4 image. White pixels are transparent. */ filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp"); if (filename) { diff --git a/ui/x_keymap.c b/ui/x_keymap.c index 27884851de..22e0e77c4d 100644 --- a/ui/x_keymap.c +++ b/ui/x_keymap.c @@ -1,169 +1,111 @@ /* - * QEMU SDL display driver + * QEMU X11 keymaps * - * Copyright (c) 2003 Fabrice Bellard + * Copyright (C) 2009-2010 Daniel P. Berrange + * Copyright (C) 2017 Red Hat, Inc * - * Permission is hereby granted, free of charge, to any person obtaining a= copy - * of this software and associated documentation files (the "Software"), t= o deal - * in the Software without restriction, including without limitation the r= ights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included= in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN - * THE SOFTWARE. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2 as + * published by the Free Software Foundation. */ + #include "qemu/osdep.h" -#include "qemu-common.h" + #include "x_keymap.h" +#include "trace.h" +#include "qemu/notify.h" +#include "ui/input.h" =20 -static const uint8_t x_keycode_to_pc_keycode[115] =3D { - 0xc7, /* 97 Home */ - 0xc8, /* 98 Up */ - 0xc9, /* 99 PgUp */ - 0xcb, /* 100 Left */ - 0x4c, /* 101 KP-5 */ - 0xcd, /* 102 Right */ - 0xcf, /* 103 End */ - 0xd0, /* 104 Down */ - 0xd1, /* 105 PgDn */ - 0xd2, /* 106 Ins */ - 0xd3, /* 107 Del */ - 0x9c, /* 108 Enter */ - 0x9d, /* 109 Ctrl-R */ - 0x0, /* 110 Pause */ - 0xb7, /* 111 Print */ - 0xb5, /* 112 Divide */ - 0xb8, /* 113 Alt-R */ - 0xc6, /* 114 Break */ - 0x0, /* 115 */ - 0x0, /* 116 */ - 0x0, /* 117 */ - 0x0, /* 118 */ - 0x0, /* 119 */ - 0x0, /* 120 */ - 0x0, /* 121 */ - 0x0, /* 122 */ - 0x0, /* 123 */ - 0x0, /* 124 */ - 0x0, /* 125 */ - 0x0, /* 126 */ - 0x0, /* 127 */ - 0x0, /* 128 */ - 0x79, /* 129 Henkan */ - 0x0, /* 130 */ - 0x7b, /* 131 Muhenkan */ - 0x0, /* 132 */ - 0x7d, /* 133 Yen */ - 0x0, /* 134 */ - 0x0, /* 135 */ - 0x47, /* 136 KP_7 */ - 0x48, /* 137 KP_8 */ - 0x49, /* 138 KP_9 */ - 0x4b, /* 139 KP_4 */ - 0x4c, /* 140 KP_5 */ - 0x4d, /* 141 KP_6 */ - 0x4f, /* 142 KP_1 */ - 0x50, /* 143 KP_2 */ - 0x51, /* 144 KP_3 */ - 0x52, /* 145 KP_0 */ - 0x53, /* 146 KP_. */ - 0x47, /* 147 KP_HOME */ - 0x48, /* 148 KP_UP */ - 0x49, /* 149 KP_PgUp */ - 0x4b, /* 150 KP_Left */ - 0x4c, /* 151 KP_ */ - 0x4d, /* 152 KP_Right */ - 0x4f, /* 153 KP_End */ - 0x50, /* 154 KP_Down */ - 0x51, /* 155 KP_PgDn */ - 0x52, /* 156 KP_Ins */ - 0x53, /* 157 KP_Del */ -}; +#include =20 -/* This table is generated based off the xfree86 -> scancode mapping above - * and the keycode mappings in /usr/share/X11/xkb/keycodes/evdev - * and /usr/share/X11/xkb/keycodes/xfree86 - */ +static gboolean check_for_xwin(Display *dpy) +{ + const char *vendor =3D ServerVendor(dpy); + + trace_xkeymap_vendor(vendor); =20 -static const uint8_t evdev_keycode_to_pc_keycode[61] =3D { - 0x73, /* 97 EVDEV - RO ("Internet" Keyboards) */ - 0, /* 98 EVDEV - KATA (Katakana) */ - 0, /* 99 EVDEV - HIRA (Hiragana) */ - 0x79, /* 100 EVDEV - HENK (Henkan) */ - 0x70, /* 101 EVDEV - HKTG (Hiragana/Katakana toggle) */ - 0x7b, /* 102 EVDEV - MUHE (Muhenkan) */ - 0, /* 103 EVDEV - JPCM (KPJPComma) */ - 0x9c, /* 104 KPEN */ - 0x9d, /* 105 RCTL */ - 0xb5, /* 106 KPDV */ - 0xb7, /* 107 PRSC */ - 0xb8, /* 108 RALT */ - 0, /* 109 EVDEV - LNFD ("Internet" Keyboards) */ - 0xc7, /* 110 HOME */ - 0xc8, /* 111 UP */ - 0xc9, /* 112 PGUP */ - 0xcb, /* 113 LEFT */ - 0xcd, /* 114 RGHT */ - 0xcf, /* 115 END */ - 0xd0, /* 116 DOWN */ - 0xd1, /* 117 PGDN */ - 0xd2, /* 118 INS */ - 0xd3, /* 119 DELE */ - 0, /* 120 EVDEV - I120 ("Internet" Keyboards) */ - 0, /* 121 EVDEV - MUTE */ - 0, /* 122 EVDEV - VOL- */ - 0, /* 123 EVDEV - VOL+ */ - 0, /* 124 EVDEV - POWR */ - 0, /* 125 EVDEV - KPEQ */ - 0, /* 126 EVDEV - I126 ("Internet" Keyboards) */ - 0, /* 127 EVDEV - PAUS */ - 0, /* 128 EVDEV - ???? */ - 0x7e, /* 129 EVDEV - KP_COMMA (brazilian) */ - 0xf1, /* 130 EVDEV - HNGL (Korean Hangul Latin toggle) */ - 0xf2, /* 131 EVDEV - HJCV (Korean Hangul Hanja toggle) */ - 0x7d, /* 132 AE13 (Yen)*/ - 0xdb, /* 133 EVDEV - LWIN */ - 0xdc, /* 134 EVDEV - RWIN */ - 0xdd, /* 135 EVDEV - MENU */ - 0, /* 136 EVDEV - STOP */ - 0, /* 137 EVDEV - AGAI */ - 0, /* 138 EVDEV - PROP */ - 0, /* 139 EVDEV - UNDO */ - 0, /* 140 EVDEV - FRNT */ - 0, /* 141 EVDEV - COPY */ - 0, /* 142 EVDEV - OPEN */ - 0, /* 143 EVDEV - PAST */ - 0, /* 144 EVDEV - FIND */ - 0, /* 145 EVDEV - CUT */ - 0, /* 146 EVDEV - HELP */ - 0, /* 147 EVDEV - I147 */ - 0, /* 148 EVDEV - I148 */ - 0, /* 149 EVDEV - I149 */ - 0, /* 150 EVDEV - I150 */ - 0, /* 151 EVDEV - I151 */ - 0, /* 152 EVDEV - I152 */ - 0, /* 153 EVDEV - I153 */ - 0, /* 154 EVDEV - I154 */ - 0, /* 155 EVDEV - I156 */ - 0, /* 156 EVDEV - I157 */ - 0, /* 157 EVDEV - I158 */ -}; + if (strstr(vendor, "Cygwin/X")) { + return TRUE; + } + + return FALSE; +} =20 -uint8_t translate_xfree86_keycode(const int key) +static gboolean check_for_xquartz(Display *dpy) { - return x_keycode_to_pc_keycode[key]; + int nextensions; + int i; + gboolean match =3D FALSE; + char **extensions =3D XListExtensions(dpy, &nextensions); + for (i =3D 0 ; extensions !=3D NULL && i < nextensions ; i++) { + trace_xkeymap_extension(extensions[i]); + if (strcmp(extensions[i], "Apple-WM") =3D=3D 0 || + strcmp(extensions[i], "Apple-DRI") =3D=3D 0) { + match =3D TRUE; + } + } + if (extensions) { + XFreeExtensionList(extensions); + } + + return match; } =20 -uint8_t translate_evdev_keycode(const int key) +const guint16 *qemu_xkeymap_mapping_table(Display *dpy, size_t *maplen) { - return evdev_keycode_to_pc_keycode[key]; + XkbDescPtr desc; + const gchar *keycodes =3D NULL; + + /* There is no easy way to determine what X11 server + * and platform & keyboard driver is in use. Thus we + * do best guess heuristics. + * + * This will need more work for people with other + * X servers..... patches welcomed. + */ + + desc =3D XkbGetMap(dpy, + XkbGBN_AllComponentsMask, + XkbUseCoreKbd); + if (desc) { + if (XkbGetNames(dpy, XkbKeycodesNameMask, desc) =3D=3D Success) { + keycodes =3D XGetAtomName (dpy, desc->names->keycodes); + if (!keycodes) { + g_warning("could not lookup keycode name"); + } else { + trace_xkeymap_keycodes(keycodes); + } + } + XkbFreeKeyboard(desc, XkbGBN_AllComponentsMask, True); + } + + if (check_for_xwin(dpy)) { + trace_xkeymap_keymap("xwin"); + *maplen =3D qemu_input_map_xorgxwin_to_qcode_len; + return qemu_input_map_xorgxwin_to_qcode; + } else if (check_for_xquartz(dpy)) { + trace_xkeymap_keymap("xquartz"); + *maplen =3D qemu_input_map_xorgxquartz_to_qcode_len; + return qemu_input_map_xorgxquartz_to_qcode; + } else if (keycodes && g_str_has_prefix(keycodes, "evdev")) { + trace_xkeymap_keymap("evdev"); + *maplen =3D qemu_input_map_xorgevdev_to_qcode_len; + return qemu_input_map_xorgevdev_to_qcode; + } else if (keycodes && g_str_has_prefix(keycodes, "xfree86")) { + trace_xkeymap_keymap("kbd"); + *maplen =3D qemu_input_map_xorgkbd_to_qcode_len; + return qemu_input_map_xorgkbd_to_qcode; + } else { + trace_xkeymap_keymap("NULL"); + g_warning("Unknown X11 keycode mapping '%s'.\n" + "Please report to qemu-devel@nongnu.org\n" + "including the following information:\n" + "\n" + " - Operating system\n" + " - X11 Server\n" + " - xprop -root\n" + " - xdpyinfo\n", + keycodes ? keycodes : ""); + return NULL; + } } diff --git a/ui/Makefile.objs b/ui/Makefile.objs index ec8533d6d9..99195884b0 100644 --- a/ui/Makefile.objs +++ b/ui/Makefile.objs @@ -11,11 +11,12 @@ common-obj-y +=3D keymaps.o console.o cursor.o qemu-pix= man.o common-obj-y +=3D input.o input-keymap.o input-legacy.o common-obj-$(CONFIG_LINUX) +=3D input-linux.o common-obj-$(CONFIG_SPICE) +=3D spice-core.o spice-input.o spice-display.o -common-obj-$(CONFIG_SDL) +=3D sdl.mo x_keymap.o +common-obj-$(CONFIG_SDL) +=3D sdl.mo common-obj-$(CONFIG_COCOA) +=3D cocoa.o common-obj-$(CONFIG_CURSES) +=3D curses.o common-obj-$(CONFIG_VNC) +=3D $(vnc-obj-y) -common-obj-$(CONFIG_GTK) +=3D gtk.o x_keymap.o +common-obj-$(CONFIG_GTK) +=3D gtk.o +common-obj-$(if $(CONFIG_WIN32),n,$(if $(CONFIG_SDL),y,$(CONFIG_GTK))) += =3D x_keymap.o =20 ifeq ($(CONFIG_SDLABI),1.2) sdl.mo-objs :=3D sdl.o sdl_zoom.o diff --git a/ui/trace-events b/ui/trace-events index 85f74f948b..34229e6747 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -18,9 +18,10 @@ ppm_save(const char *filename, void *display_surface) "%= s surface=3D%p" # ui/gtk.c gd_switch(const char *tab, int width, int height) "tab=3D%s, width=3D%d, h= eight=3D%d" gd_update(const char *tab, int x, int y, int w, int h) "tab=3D%s, x=3D%d, = y=3D%d, w=3D%d, h=3D%d" -gd_key_event(const char *tab, int gdk_keycode, int qemu_keycode, const cha= r *action) "tab=3D%s, translated GDK keycode %d to QEMU keycode %d (%s)" +gd_key_event(const char *tab, int gdk_keycode, int qkeycode, const char *a= ction) "tab=3D%s, translated GDK keycode %d to QKeyCode %d (%s)" gd_grab(const char *tab, const char *device, const char *reason) "tab=3D%s= , dev=3D%s, reason=3D%s" gd_ungrab(const char *tab, const char *device) "tab=3D%s, dev=3D%s" +gd_keymap_windowing(const char *name) "backend=3D%s" =20 # ui/vnc.c vnc_key_guest_leds(bool caps, bool num, bool scroll) "caps %d, num %d, scr= oll %d" @@ -79,3 +80,9 @@ qemu_spice_create_update(uint32_t left, uint32_t right, u= int32_t top, uint32_t b keymap_parse(const char *file) "file %s" keymap_add(const char *type, int sym, int code, const char *line) "%-6s sy= m=3D0x%04x code=3D0x%04x (line: %s)" keymap_unmapped(int sym) "sym=3D0x%04x" + +# ui/x_keymap.c +xkeymap_extension(const char *name) "extension '%s'" +xkeymap_vendor(const char *name) "vendor '%s'" +xkeymap_keycodes(const char *name) "keycodes '%s'" +xkeymap_keymap(const char *name) "keymap '%s'" --=20 2.9.3 From nobody Sun May 5 02:44:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516891067316621.4100386389434; Thu, 25 Jan 2018 06:37:47 -0800 (PST) Received: from localhost ([::1]:44065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeiet-0000v0-Mv for importer@patchew.org; Thu, 25 Jan 2018 09:37:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeiZn-0005Ta-6I for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeiZj-0006rB-TE for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47414) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eeiZj-0006qK-OD for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:23 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 08227C0567A2 for ; Thu, 25 Jan 2018 14:32:23 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF7E75D960; Thu, 25 Jan 2018 14:32:19 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 0C1CF16E03; Thu, 25 Jan 2018 15:32:19 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 25 Jan 2018 15:32:14 +0100 Message-Id: <20180125143218.29528-5-kraxel@redhat.com> In-Reply-To: <20180125143218.29528-1-kraxel@redhat.com> References: <20180125143218.29528-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 25 Jan 2018 14:32:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/8] ui: add fix for GTK Pause key handling on Win32 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Versions of GTK prior to 3.22 did not correctly set the keyval field when VK_PAUSE was received on Windows. Signed-off-by: Daniel P. Berrange Message-id: 20180117164717.15855-4-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- ui/gtk.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/gtk.c b/ui/gtk.c index 1217160724..188c40eef5 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1206,7 +1206,14 @@ static gboolean gd_key_event(GtkWidget *widget, GdkE= ventKey *key, void *opaque) return TRUE; } =20 - if (key->keyval =3D=3D GDK_KEY_Pause) { + if (key->keyval =3D=3D GDK_KEY_Pause +#ifdef G_OS_WIN32 + /* for some reason GDK does not fill keyval for VK_PAUSE + * See https://bugzilla.gnome.org/show_bug.cgi?id=3D769214 + */ + || key->hardware_keycode =3D=3D VK_PAUSE +#endif + ) { qemu_input_event_send_key_qcode(vc->gfx.dcl.con, Q_KEY_CODE_PAUSE, key->type =3D=3D GDK_KEY_PRESS); return TRUE; --=20 2.9.3 From nobody Sun May 5 02:44:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516890997247685.2665123182666; Thu, 25 Jan 2018 06:36:37 -0800 (PST) Received: from localhost ([::1]:44031 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeido-0008P4-Ga for importer@patchew.org; Thu, 25 Jan 2018 09:36:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeiZn-0005Te-6Y for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeiZl-0006tJ-8w for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44108) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eeiZl-0006s4-40 for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:25 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73579C0528DC for ; Thu, 25 Jan 2018 14:32:24 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF4B260471; Thu, 25 Jan 2018 14:32:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 144BF17442; Thu, 25 Jan 2018 15:32:19 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 25 Jan 2018 15:32:15 +0100 Message-Id: <20180125143218.29528-6-kraxel@redhat.com> In-Reply-To: <20180125143218.29528-1-kraxel@redhat.com> References: <20180125143218.29528-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 25 Jan 2018 14:32:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/8] ui: ignore hardware keycode 255 on win32 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" It is a reserved value and doesn't have a corresponding valid scancode. Signed-off-by: Daniel P. Berrange Message-id: 20180117164717.15855-5-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- ui/gtk.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/gtk.c b/ui/gtk.c index 188c40eef5..f0ad63e431 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1206,6 +1206,12 @@ static gboolean gd_key_event(GtkWidget *widget, GdkE= ventKey *key, void *opaque) return TRUE; } =20 +#ifdef WIN32 + /* on windows, we ought to ignore the reserved key event? */ + if (key->hardware_keycode =3D=3D 0xff) + return false; +#endif + if (key->keyval =3D=3D GDK_KEY_Pause #ifdef G_OS_WIN32 /* for some reason GDK does not fill keyval for VK_PAUSE --=20 2.9.3 From nobody Sun May 5 02:44:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516891175115702.7401696498097; Thu, 25 Jan 2018 06:39:35 -0800 (PST) Received: from localhost ([::1]:44163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeigg-0002OL-Fx for importer@patchew.org; Thu, 25 Jan 2018 09:39:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeiZp-0005U6-AU for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeiZl-0006t2-5r for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58150) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eeiZl-0006s0-12 for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:25 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D93212E4FC for ; Thu, 25 Jan 2018 14:32:24 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04B8B60C9D; Thu, 25 Jan 2018 14:32:24 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1E5AD17443; Thu, 25 Jan 2018 15:32:19 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 25 Jan 2018 15:32:16 +0100 Message-Id: <20180125143218.29528-7-kraxel@redhat.com> In-Reply-To: <20180125143218.29528-1-kraxel@redhat.com> References: <20180125143218.29528-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 25 Jan 2018 14:32:24 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 6/8] ui: deprecate use of SDL 1.2 in favour of 2.0 series X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The SDL 2.0 release was made in Aug, 2013: https://www.libsdl.org/release/ That will soon be 4 + 1/2 years ago, which is enough time to consider the 2.0 series widely supported. Thus we deprecate the SDL 1.2 support, which will allow us to delete it in the last release of 2018. By this time, SDL 2.0 will be more than 5 years old. Signed-off-by: Daniel P. Berrange Reviewed-by: Marc-Andr=C3=A9 Lureau Message-id: 20180115142533.24585-1-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- configure | 6 ++++++ ui/sdl.c | 3 +++ qemu-doc.texi | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/configure b/configure index 044c6fafe2..96dee6572c 100755 --- a/configure +++ b/configure @@ -5668,6 +5668,12 @@ if test "$gtkabi" =3D "2.0"; then echo "WARNING: future releases. Please switch to using GTK 3.0" fi =20 +if test "$sdlabi" =3D "1.2"; then + echo + echo "WARNING: Use of SDL 1.2 is deprecated and will be removed in" + echo "WARNING: future releases. Please switch to using SDL 2.0" +fi + if test "$supported_cpu" =3D "no"; then echo echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEAS= ES!" diff --git a/ui/sdl.c b/ui/sdl.c index afb4992da2..f26048d3a2 100644 --- a/ui/sdl.c +++ b/ui/sdl.c @@ -918,6 +918,9 @@ void sdl_display_init(DisplayState *ds, int full_screen= , int no_frame) exit(1); } =20 + g_printerr("Running QEMU with SDL 1.2 is deprecated, and will be remov= ed\n" + "in a future release. Please switch to SDL 2.0 instead\n"); + if (no_frame) gui_noframe =3D 1; =20 diff --git a/qemu-doc.texi b/qemu-doc.texi index 3e9eb819a6..79d08b3f04 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -2596,6 +2596,13 @@ and 3.x series APIs. Support for the GTK 2.x builds = will be discontinued, so maintainers should switch to using GTK 3.x, which is the default. =20 +@subsection SDL 1.2 + +Previously QEMU has supported building against both SDL 1.2 +and 2.0 series APIs. Support for the SDL 1.2 builds will be +discontinued, so maintainers should switch to using SDL 2.0, +which is the default. + @section System emulator command line arguments =20 @subsection -tdf (since 1.3.0) --=20 2.9.3 From nobody Sun May 5 02:44:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151689088530977.0673022159416; Thu, 25 Jan 2018 06:34:45 -0800 (PST) Received: from localhost ([::1]:43989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeic0-0006oR-0X for importer@patchew.org; Thu, 25 Jan 2018 09:34:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeiZn-0005TZ-6L for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeiZl-0006tv-Ib for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51082) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eeiZl-0006sQ-9g for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:25 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9BA06A0C53 for ; Thu, 25 Jan 2018 14:32:24 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED456600CC; Thu, 25 Jan 2018 14:32:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 27EAD17444; Thu, 25 Jan 2018 15:32:19 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 25 Jan 2018 15:32:17 +0100 Message-Id: <20180125143218.29528-8-kraxel@redhat.com> In-Reply-To: <20180125143218.29528-1-kraxel@redhat.com> References: <20180125143218.29528-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 25 Jan 2018 14:32:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 7/8] sdl: use ctrl-alt-g as grab hotkey X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Be consistent with gtk and cocoa. Signed-off-by: Gerd Hoffmann Message-id: 20180115154855.30850-2-kraxel@redhat.com --- ui/sdl.c | 30 +++++++++++++----------------- ui/sdl2.c | 27 +++++++++++---------------- 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/ui/sdl.c b/ui/sdl.c index f26048d3a2..0017b4a912 100644 --- a/ui/sdl.c +++ b/ui/sdl.c @@ -323,11 +323,11 @@ static void sdl_update_caption(void) status =3D " [Stopped]"; else if (gui_grab) { if (alt_grab) - status =3D " - Press Ctrl-Alt-Shift to exit mouse grab"; + status =3D " - Press Ctrl-Alt-Shift-G to exit mouse grab"; else if (ctrl_grab) - status =3D " - Press Right-Ctrl to exit mouse grab"; + status =3D " - Press Right-Ctrl-G to exit mouse grab"; else - status =3D " - Press Ctrl-Alt to exit mouse grab"; + status =3D " - Press Ctrl-Alt-G to exit mouse grab"; } =20 if (qemu_name) { @@ -531,6 +531,16 @@ static void handle_keydown(SDL_Event *ev) toggle_full_screen(); gui_keysym =3D 1; break; + case 0x22: /* 'g' key */ + if (!gui_grab) { + if (qemu_console_is_graphic(NULL)) { + sdl_grab_start(); + } + } else if (!gui_fullscreen) { + sdl_grab_end(); + } + gui_keysym =3D 1; + break; case 0x16: /* 'u' key on US keyboard */ if (scaling_active) { scaling_active =3D 0; @@ -666,20 +676,6 @@ static void handle_keyup(SDL_Event *ev) } if (!mod_state && gui_key_modifier_pressed) { gui_key_modifier_pressed =3D 0; - if (gui_keysym =3D=3D 0) { - /* exit/enter grab if pressing Ctrl-Alt */ - if (!gui_grab) { - if (qemu_console_is_graphic(NULL)) { - sdl_grab_start(); - } - } else if (!gui_fullscreen) { - sdl_grab_end(); - } - /* SDL does not send back all the modifiers key, so we must - * correct it. */ - reset_keys(); - return; - } gui_keysym =3D 0; } if (qemu_console_is_graphic(NULL) && !gui_keysym) { diff --git a/ui/sdl2.c b/ui/sdl2.c index 89c6a2633c..1db5dd6f5f 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -141,11 +141,11 @@ static void sdl_update_caption(struct sdl2_console *s= con) status =3D " [Stopped]"; } else if (gui_grab) { if (alt_grab) { - status =3D " - Press Ctrl-Alt-Shift to exit grab"; + status =3D " - Press Ctrl-Alt-Shift-G to exit grab"; } else if (ctrl_grab) { - status =3D " - Press Right-Ctrl to exit grab"; + status =3D " - Press Right-Ctrl-G to exit grab"; } else { - status =3D " - Press Ctrl-Alt to exit grab"; + status =3D " - Press Ctrl-Alt-G to exit grab"; } } =20 @@ -364,6 +364,14 @@ static void handle_keydown(SDL_Event *ev) toggle_full_screen(scon); gui_keysym =3D 1; break; + case SDL_SCANCODE_G: + gui_keysym =3D 1; + if (!gui_grab) { + sdl_grab_start(scon); + } else if (!gui_fullscreen) { + sdl_grab_end(scon); + } + break; case SDL_SCANCODE_U: sdl2_window_destroy(scon); sdl2_window_create(scon); @@ -416,19 +424,6 @@ static void handle_keyup(SDL_Event *ev) } if (!mod_state && gui_key_modifier_pressed) { gui_key_modifier_pressed =3D 0; - if (gui_keysym =3D=3D 0) { - /* exit/enter grab if pressing Ctrl-Alt */ - if (!gui_grab) { - sdl_grab_start(scon); - } else if (!gui_fullscreen) { - sdl_grab_end(scon); - } - /* SDL does not send back all the modifiers key, so we must - * correct it. */ - sdl2_reset_keys(scon); - return; - } - sdl2_reset_keys(scon); gui_keysym =3D 0; } if (!gui_keysym) { --=20 2.9.3 From nobody Sun May 5 02:44:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516891240924852.5818881344533; Thu, 25 Jan 2018 06:40:40 -0800 (PST) Received: from localhost ([::1]:44191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeihk-0003B3-8O for importer@patchew.org; Thu, 25 Jan 2018 09:40:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeiZn-0005Tc-6W for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeiZl-0006th-D5 for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43038) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eeiZl-0006sB-6B for qemu-devel@nongnu.org; Thu, 25 Jan 2018 09:32:25 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7C96F78257 for ; Thu, 25 Jan 2018 14:32:24 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2D895D9CD; Thu, 25 Jan 2018 14:32:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 33DD617445; Thu, 25 Jan 2018 15:32:19 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 25 Jan 2018 15:32:18 +0100 Message-Id: <20180125143218.29528-9-kraxel@redhat.com> In-Reply-To: <20180125143218.29528-1-kraxel@redhat.com> References: <20180125143218.29528-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 25 Jan 2018 14:32:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 8/8] sdl: reorganize -no-frame support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Drop no_frame flag from sdl_display_init argument list, use a global variable instead. This is temporary until -no-frame support is dropped altogether when we remove sdl1 support. Remove any traces of noframe from sdl2 code. It is just dead code as sdl2 doesn't support the SDL_NOFRAME window flag any more. Signed-off-by: Gerd Hoffmann Message-id: 20180115154855.30850-3-kraxel@redhat.com --- include/sysemu/sysemu.h | 1 + include/ui/console.h | 5 ++--- ui/sdl.c | 9 +++------ ui/sdl2.c | 7 +------ vl.c | 4 ++-- 5 files changed, 9 insertions(+), 17 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 31612caf10..1c925309e3 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -112,6 +112,7 @@ extern const char *keyboard_layout; extern int win2k_install_hack; extern int alt_grab; extern int ctrl_grab; +extern int no_frame; extern int smp_cpus; extern unsigned int max_cpus; extern int cursor_hide; diff --git a/include/ui/console.h b/include/ui/console.h index 580dfc57ee..7b35778444 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -436,7 +436,7 @@ void surface_gl_setup_viewport(QemuGLShader *gls, /* sdl.c */ #ifdef CONFIG_SDL void sdl_display_early_init(int opengl); -void sdl_display_init(DisplayState *ds, int full_screen, int no_frame); +void sdl_display_init(DisplayState *ds, int full_screen); #else static inline void sdl_display_early_init(int opengl) { @@ -444,8 +444,7 @@ static inline void sdl_display_early_init(int opengl) error_report("SDL support is disabled"); abort(); } -static inline void sdl_display_init(DisplayState *ds, int full_screen, - int no_frame) +static inline void sdl_display_init(DisplayState *ds, int full_screen) { /* This must never be called if CONFIG_SDL is disabled */ error_report("SDL support is disabled"); diff --git a/ui/sdl.c b/ui/sdl.c index 0017b4a912..c8f102bb9f 100644 --- a/ui/sdl.c +++ b/ui/sdl.c @@ -50,7 +50,6 @@ static int gui_saved_width; static int gui_saved_height; static int gui_saved_grab; static int gui_fullscreen; -static int gui_noframe; static int gui_key_modifier_pressed; static int gui_keysym; static int gui_grab_code =3D KMOD_LALT | KMOD_LCTRL; @@ -118,8 +117,9 @@ static void do_sdl_resize(int width, int height, int bp= p) } else { flags |=3D SDL_RESIZABLE; } - if (gui_noframe) + if (no_frame) { flags |=3D SDL_NOFRAME; + } =20 tmp_screen =3D SDL_SetVideoMode(width, height, bpp, flags); if (!real_screen) { @@ -895,7 +895,7 @@ void sdl_display_early_init(int opengl) } } =20 -void sdl_display_init(DisplayState *ds, int full_screen, int no_frame) +void sdl_display_init(DisplayState *ds, int full_screen) { int flags; uint8_t data =3D 0; @@ -917,9 +917,6 @@ void sdl_display_init(DisplayState *ds, int full_screen= , int no_frame) g_printerr("Running QEMU with SDL 1.2 is deprecated, and will be remov= ed\n" "in a future release. Please switch to SDL 2.0 instead\n"); =20 - if (no_frame) - gui_noframe =3D 1; - if (!full_screen) { setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0); } diff --git a/ui/sdl2.c b/ui/sdl2.c index 1db5dd6f5f..812c315891 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -38,7 +38,6 @@ static int gui_grab; /* if true, all keyboard/mouse event= s are grabbed */ =20 static int gui_saved_grab; static int gui_fullscreen; -static int gui_noframe; static int gui_key_modifier_pressed; static int gui_keysym; static int gui_grab_code =3D KMOD_LALT | KMOD_LCTRL; @@ -767,7 +766,7 @@ void sdl_display_early_init(int opengl) } } =20 -void sdl_display_init(DisplayState *ds, int full_screen, int no_frame) +void sdl_display_init(DisplayState *ds, int full_screen) { int flags; uint8_t data =3D 0; @@ -775,10 +774,6 @@ void sdl_display_init(DisplayState *ds, int full_scree= n, int no_frame) int i; SDL_SysWMinfo info; =20 - if (no_frame) { - gui_noframe =3D 1; - } - #ifdef __linux__ /* on Linux, SDL may use fbcon|directfb|svgalib when run without * accessible $DISPLAY to open X11 window. This is often the case diff --git a/vl.c b/vl.c index e725ecbc08..6ab232095c 100644 --- a/vl.c +++ b/vl.c @@ -150,7 +150,7 @@ static int rtc_date_offset =3D -1; /* -1 means no chang= e */ QEMUClockType rtc_clock; int vga_interface_type =3D VGA_NONE; static int full_screen =3D 0; -static int no_frame =3D 0; +int no_frame; int no_quit =3D 0; static bool grab_on_hover; Chardev *serial_hds[MAX_SERIAL_PORTS]; @@ -4694,7 +4694,7 @@ int main(int argc, char **argv, char **envp) curses_display_init(ds, full_screen); break; case DT_SDL: - sdl_display_init(ds, full_screen, no_frame); + sdl_display_init(ds, full_screen); break; case DT_COCOA: cocoa_display_init(ds, full_screen); --=20 2.9.3