From nobody Wed Oct 22 06:32:27 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151929514322063.93349491186768; Thu, 22 Feb 2018 02:25:43 -0800 (PST) Received: from localhost ([::1]:37161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo4H-0004fq-2d for importer@patchew.org; Thu, 22 Feb 2018 05:25:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo2E-0003J6-Lx for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoo2B-00020B-F1 for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:30 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54764 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoo2B-0001yM-6U for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:27 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D4CEF40FB639 for ; Thu, 22 Feb 2018 10:23:24 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-147.ams2.redhat.com [10.36.116.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BA5FA9F46; Thu, 22 Feb 2018 10:23:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D83B91751D; Thu, 22 Feb 2018 11:23:17 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 22 Feb 2018 11:23:09 +0100 Message-Id: <20180222102317.25776-2-kraxel@redhat.com> In-Reply-To: <20180222102317.25776-1-kraxel@redhat.com> References: <20180222102317.25776-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 22 Feb 2018 10:23:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 22 Feb 2018 10:23:24 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' 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: 66.187.233.73 Subject: [Qemu-devel] [PULL 1/9] sdl2: fix hotkey keyup 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" After some hotkey was pressed sdl2 doesn't forward the first modifier keyup event to the guest, resulting in stuck modifier keys. Fix the logic in handle_keyup(). Also gui_key_modifier_pressed doesn't need to be a global variable. Reported-by: Howard Spoelstra Tested-by: Howard Spoelstra Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrang=C3=A9 Message-id: 20180220150444.784-1-kraxel@redhat.com --- ui/sdl2.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/ui/sdl2.c b/ui/sdl2.c index 6e96a4a24c..b5a0fa1d13 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -39,7 +39,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_key_modifier_pressed; static int gui_keysym; static int gui_grab_code =3D KMOD_LALT | KMOD_LCTRL; static SDL_Cursor *sdl_cursor_normal; @@ -331,8 +330,7 @@ static void handle_keydown(SDL_Event *ev) { int win; struct sdl2_console *scon =3D get_scon_from_window(ev->key.windowID); - - gui_key_modifier_pressed =3D get_mod_state(); + int gui_key_modifier_pressed =3D get_mod_state(); =20 if (!scon->ignore_hotkeys && gui_key_modifier_pressed && !ev->key.repe= at) { switch (ev->key.keysym.scancode) { @@ -413,18 +411,12 @@ static void handle_keydown(SDL_Event *ev) =20 static void handle_keyup(SDL_Event *ev) { - int mod_state; struct sdl2_console *scon =3D get_scon_from_window(ev->key.windowID); + int gui_key_modifier_pressed =3D get_mod_state(); =20 scon->ignore_hotkeys =3D false; =20 - if (!alt_grab) { - mod_state =3D (ev->key.keysym.mod & gui_grab_code); - } else { - mod_state =3D (ev->key.keysym.mod & (gui_grab_code | KMOD_LSHIFT)); - } - if (!mod_state && gui_key_modifier_pressed) { - gui_key_modifier_pressed =3D 0; + if (!gui_key_modifier_pressed) { gui_keysym =3D 0; } if (!gui_keysym) { --=20 2.9.3 From nobody Wed Oct 22 06:32:27 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151929561820594.30473950824546; Thu, 22 Feb 2018 02:33:38 -0800 (PST) Received: from localhost ([::1]:37218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eooC1-0002G0-F0 for importer@patchew.org; Thu, 22 Feb 2018 05:33:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo2E-0003J2-J4 for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoo2B-0001zN-Av for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:30 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54604 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoo2B-0001yN-50 for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:27 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 05AB4EB6ED for ; Thu, 22 Feb 2018 10:23:23 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-147.ams2.redhat.com [10.36.116.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BBD3217B409; Thu, 22 Feb 2018 10:23:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E2B741751E; Thu, 22 Feb 2018 11:23:17 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 22 Feb 2018 11:23:10 +0100 Message-Id: <20180222102317.25776-3-kraxel@redhat.com> In-Reply-To: <20180222102317.25776-1-kraxel@redhat.com> References: <20180222102317.25776-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 22 Feb 2018 10:23:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 22 Feb 2018 10:23:23 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 2/9] console/opengl: split up dpy_gl_cursor ops 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" Split the cursor callback into two, one for setting the dmabuf, one for setting the position. Also add hotspot information. Signed-off-by: Gerd Hoffmann Message-id: 20180220110433.20353-2-kraxel@redhat.com --- include/ui/console.h | 13 ++++++++----- ui/console.c | 18 ++++++++++++++---- ui/egl-headless.c | 17 ++++++++++++----- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index e6b1227bef..f29bacd625 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -230,8 +230,10 @@ typedef struct DisplayChangeListenerOps { void (*dpy_gl_scanout_dmabuf)(DisplayChangeListener *dcl, QemuDmaBuf *dmabuf); void (*dpy_gl_cursor_dmabuf)(DisplayChangeListener *dcl, - QemuDmaBuf *dmabuf, - uint32_t pos_x, uint32_t pos_y); + QemuDmaBuf *dmabuf, bool have_hot, + uint32_t hot_x, uint32_t hot_y); + void (*dpy_gl_cursor_position)(DisplayChangeListener *dcl, + uint32_t pos_x, uint32_t pos_y); void (*dpy_gl_release_dmabuf)(DisplayChangeListener *dcl, QemuDmaBuf *dmabuf); void (*dpy_gl_update)(DisplayChangeListener *dcl, @@ -304,9 +306,10 @@ void dpy_gl_scanout_texture(QemuConsole *con, uint32_t x, uint32_t y, uint32_t w, uint32_t h= ); void dpy_gl_scanout_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf); -void dpy_gl_cursor_dmabuf(QemuConsole *con, - QemuDmaBuf *dmabuf, - uint32_t pos_x, uint32_t pos_y); +void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf, + bool have_hot, uint32_t hot_x, uint32_t hot_y); +void dpy_gl_cursor_position(QemuConsole *con, + uint32_t pos_x, uint32_t pos_y); void dpy_gl_release_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf); void dpy_gl_update(QemuConsole *con, diff --git a/ui/console.c b/ui/console.c index 36584d039e..e22931a396 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1760,14 +1760,24 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con, con->gl->ops->dpy_gl_scanout_dmabuf(con->gl, dmabuf); } =20 -void dpy_gl_cursor_dmabuf(QemuConsole *con, - QemuDmaBuf *dmabuf, - uint32_t pos_x, uint32_t pos_y) +void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf, + bool have_hot, uint32_t hot_x, uint32_t hot_y) { assert(con->gl); =20 if (con->gl->ops->dpy_gl_cursor_dmabuf) { - con->gl->ops->dpy_gl_cursor_dmabuf(con->gl, dmabuf, pos_x, pos_y); + con->gl->ops->dpy_gl_cursor_dmabuf(con->gl, dmabuf, + have_hot, hot_x, hot_y); + } +} + +void dpy_gl_cursor_position(QemuConsole *con, + uint32_t pos_x, uint32_t pos_y) +{ + assert(con->gl); + + if (con->gl->ops->dpy_gl_cursor_position) { + con->gl->ops->dpy_gl_cursor_position(con->gl, pos_x, pos_y); } } =20 diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 38b3766548..00ff2c036a 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -84,14 +84,11 @@ static void egl_scanout_dmabuf(DisplayChangeListener *d= cl, } =20 static void egl_cursor_dmabuf(DisplayChangeListener *dcl, - QemuDmaBuf *dmabuf, - uint32_t pos_x, uint32_t pos_y) + QemuDmaBuf *dmabuf, bool have_hot, + uint32_t hot_x, uint32_t hot_y) { egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); =20 - edpy->pos_x =3D pos_x; - edpy->pos_y =3D pos_y; - egl_dmabuf_import_texture(dmabuf); if (!dmabuf->texture) { return; @@ -101,6 +98,15 @@ static void egl_cursor_dmabuf(DisplayChangeListener *dc= l, dmabuf->texture, false); } =20 +static void egl_cursor_position(DisplayChangeListener *dcl, + uint32_t pos_x, uint32_t pos_y) +{ + egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); + + edpy->pos_x =3D pos_x; + edpy->pos_y =3D pos_y; +} + static void egl_release_dmabuf(DisplayChangeListener *dcl, QemuDmaBuf *dmabuf) { @@ -150,6 +156,7 @@ static const DisplayChangeListenerOps egl_ops =3D { .dpy_gl_scanout_texture =3D egl_scanout_texture, .dpy_gl_scanout_dmabuf =3D egl_scanout_dmabuf, .dpy_gl_cursor_dmabuf =3D egl_cursor_dmabuf, + .dpy_gl_cursor_position =3D egl_cursor_position, .dpy_gl_release_dmabuf =3D egl_release_dmabuf, .dpy_gl_update =3D egl_scanout_flush, }; --=20 2.9.3 From nobody Wed Oct 22 06:32:27 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519295552649400.1353405080904; Thu, 22 Feb 2018 02:32:32 -0800 (PST) Received: from localhost ([::1]:37212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eooAo-0001b6-Rh for importer@patchew.org; Thu, 22 Feb 2018 05:32:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo2E-0003J0-Ii for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoo2B-0001ze-CW for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:30 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38390 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoo2B-0001yP-5y for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:27 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F94F404085A for ; Thu, 22 Feb 2018 10:23:24 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-147.ams2.redhat.com [10.36.116.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BAB010A9700; Thu, 22 Feb 2018 10:23:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EF3CF17528; Thu, 22 Feb 2018 11:23:17 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 22 Feb 2018 11:23:11 +0100 Message-Id: <20180222102317.25776-4-kraxel@redhat.com> In-Reply-To: <20180222102317.25776-1-kraxel@redhat.com> References: <20180222102317.25776-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 22 Feb 2018 10:23:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 22 Feb 2018 10:23:24 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 3/9] egl-headless: cursor_dmabuf: handle NULL cursor 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" The cursor dmabuf can be NULL, in case no cursor defined by the guest. Happens for example when linux guests show the framebuffer console. Signed-off-by: Gerd Hoffmann Message-id: 20180220110433.20353-3-kraxel@redhat.com --- ui/egl-headless.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 00ff2c036a..b33e0b21fd 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -89,13 +89,16 @@ static void egl_cursor_dmabuf(DisplayChangeListener *dc= l, { egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); =20 - egl_dmabuf_import_texture(dmabuf); - if (!dmabuf->texture) { - return; + if (dmabuf) { + egl_dmabuf_import_texture(dmabuf); + if (!dmabuf->texture) { + return; + } + egl_fb_setup_for_tex(&edpy->cursor_fb, dmabuf->width, dmabuf->heig= ht, + dmabuf->texture, false); + } else { + egl_fb_destroy(&edpy->cursor_fb); } - - egl_fb_setup_for_tex(&edpy->cursor_fb, dmabuf->width, dmabuf->height, - dmabuf->texture, false); } =20 static void egl_cursor_position(DisplayChangeListener *dcl, --=20 2.9.3 From nobody Wed Oct 22 06:32:27 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519295143228763.2464038181378; Thu, 22 Feb 2018 02:25:43 -0800 (PST) Received: from localhost ([::1]:37160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo4E-0004bT-0f for importer@patchew.org; Thu, 22 Feb 2018 05:25:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo2E-0003J4-KS for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoo2B-0001zu-EY for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:30 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40140 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoo2B-0001yJ-62 for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:27 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E3440857F9 for ; Thu, 22 Feb 2018 10:23:22 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-147.ams2.redhat.com [10.36.116.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BBA0217B400; Thu, 22 Feb 2018 10:23:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 01D3C17533; Thu, 22 Feb 2018 11:23:18 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 22 Feb 2018 11:23:12 +0100 Message-Id: <20180222102317.25776-5-kraxel@redhat.com> In-Reply-To: <20180222102317.25776-1-kraxel@redhat.com> References: <20180222102317.25776-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 22 Feb 2018 10:23:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 22 Feb 2018 10:23:22 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 4/9] egl-helpers: add alpha channel to texture format 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" Needed when rendering cursers which (unlike framebuffers) actually are transparent. Signed-off-by: Gerd Hoffmann Message-id: 20180220110433.20353-4-kraxel@redhat.com --- ui/egl-helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 5fa60ef4e8..16dc3ded36 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -83,7 +83,7 @@ void egl_fb_setup_new_tex(egl_fb *fb, int width, int heig= ht) =20 glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0); =20 egl_fb_setup_for_tex(fb, width, height, texture, true); --=20 2.9.3 From nobody Wed Oct 22 06:32:27 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519295142827746.5598983074863; Thu, 22 Feb 2018 02:25:42 -0800 (PST) Received: from localhost ([::1]:37163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo4I-0004hb-Hs for importer@patchew.org; Thu, 22 Feb 2018 05:25:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo2E-0003J1-JN for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoo2B-0001zf-Cy for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:30 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38388 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoo2B-0001yO-5R for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:27 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8AFF4040855 for ; Thu, 22 Feb 2018 10:23:23 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-147.ams2.redhat.com [10.36.116.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 574F82024CA9; Thu, 22 Feb 2018 10:23:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 0BC9317534; Thu, 22 Feb 2018 11:23:18 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 22 Feb 2018 11:23:13 +0100 Message-Id: <20180222102317.25776-6-kraxel@redhat.com> In-Reply-To: <20180222102317.25776-1-kraxel@redhat.com> References: <20180222102317.25776-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 22 Feb 2018 10:23:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 22 Feb 2018 10:23:23 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' 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: 66.187.233.73 Subject: [Qemu-devel] [PULL 5/9] keymap: make struct kbd_layout_t private to ui/keymaps.c 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" Also use kbd_layout_t pointers instead of void pointers. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrang=C3=A9 Message-id: 20180222070513.8740-2-kraxel@redhat.com --- ui/keymaps.h | 29 ++++++----------------------- ui/keymaps.c | 32 +++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/ui/keymaps.h b/ui/keymaps.h index 8757465529..17ec03387a 100644 --- a/ui/keymaps.h +++ b/ui/keymaps.h @@ -32,25 +32,6 @@ typedef struct { int keysym; } name2keysym_t; =20 -struct key_range { - int start; - int end; - struct key_range *next; -}; - -#define MAX_NORMAL_KEYCODE 512 -#define MAX_EXTRA_COUNT 256 -typedef struct { - uint16_t keysym2keycode[MAX_NORMAL_KEYCODE]; - struct { - int keysym; - uint16_t keycode; - } keysym2keycode_extra[MAX_EXTRA_COUNT]; - int extra_count; - struct key_range *keypad_range; - struct key_range *numlock_range; -} kbd_layout_t; - /* scancode without modifiers */ #define SCANCODE_KEYMASK 0xff /* scancode without grey or up bit */ @@ -69,10 +50,12 @@ typedef struct { #define SCANCODE_ALT 0x400 #define SCANCODE_ALTGR 0x800 =20 +typedef struct kbd_layout_t kbd_layout_t; =20 -void *init_keyboard_layout(const name2keysym_t *table, const char *languag= e); -int keysym2scancode(void *kbd_layout, int keysym); -int keycode_is_keypad(void *kbd_layout, int keycode); -int keysym_is_numlock(void *kbd_layout, int keysym); +kbd_layout_t *init_keyboard_layout(const name2keysym_t *table, + const char *language); +int keysym2scancode(kbd_layout_t *k, int keysym); +int keycode_is_keypad(kbd_layout_t *k, int keycode); +int keysym_is_numlock(kbd_layout_t *k, int keysym); =20 #endif /* QEMU_KEYMAPS_H */ diff --git a/ui/keymaps.c b/ui/keymaps.c index f9762d1497..134958a197 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -28,6 +28,26 @@ #include "trace.h" #include "qemu/error-report.h" =20 +#define MAX_NORMAL_KEYCODE 512 +#define MAX_EXTRA_COUNT 256 + +struct key_range { + int start; + int end; + struct key_range *next; +}; + +struct kbd_layout_t { + uint16_t keysym2keycode[MAX_NORMAL_KEYCODE]; + struct { + int keysym; + uint16_t keycode; + } keysym2keycode_extra[MAX_EXTRA_COUNT]; + int extra_count; + struct key_range *keypad_range; + struct key_range *numlock_range; +}; + static int get_keysym(const name2keysym_t *table, const char *name) { @@ -186,15 +206,15 @@ static kbd_layout_t *parse_keyboard_layout(const name= 2keysym_t *table, } =20 =20 -void *init_keyboard_layout(const name2keysym_t *table, const char *languag= e) +kbd_layout_t *init_keyboard_layout(const name2keysym_t *table, + const char *language) { return parse_keyboard_layout(table, language, NULL); } =20 =20 -int keysym2scancode(void *kbd_layout, int keysym) +int keysym2scancode(kbd_layout_t *k, int keysym) { - kbd_layout_t *k =3D kbd_layout; if (keysym < MAX_NORMAL_KEYCODE) { if (k->keysym2keycode[keysym] =3D=3D 0) { trace_keymap_unmapped(keysym); @@ -217,9 +237,8 @@ int keysym2scancode(void *kbd_layout, int keysym) return 0; } =20 -int keycode_is_keypad(void *kbd_layout, int keycode) +int keycode_is_keypad(kbd_layout_t *k, int keycode) { - kbd_layout_t *k =3D kbd_layout; struct key_range *kr; =20 for (kr =3D k->keypad_range; kr; kr =3D kr->next) { @@ -230,9 +249,8 @@ int keycode_is_keypad(void *kbd_layout, int keycode) return 0; } =20 -int keysym_is_numlock(void *kbd_layout, int keysym) +int keysym_is_numlock(kbd_layout_t *k, int keysym) { - kbd_layout_t *k =3D kbd_layout; struct key_range *kr; =20 for (kr =3D k->numlock_range; kr; kr =3D kr->next) { --=20 2.9.3 From nobody Wed Oct 22 06:32:27 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151929527180785.22545158898993; Thu, 22 Feb 2018 02:27:51 -0800 (PST) Received: from localhost ([::1]:37182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo6R-0006iq-0R for importer@patchew.org; Thu, 22 Feb 2018 05:27:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo2G-0003Jl-FW for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoo2B-000205-E1 for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:32 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40142 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoo2B-0001yL-4e for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:27 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB7F98A3DD for ; Thu, 22 Feb 2018 10:23:24 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-147.ams2.redhat.com [10.36.116.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58E2C10A9704; Thu, 22 Feb 2018 10:23:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1594A17535; Thu, 22 Feb 2018 11:23:18 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 22 Feb 2018 11:23:14 +0100 Message-Id: <20180222102317.25776-7-kraxel@redhat.com> In-Reply-To: <20180222102317.25776-1-kraxel@redhat.com> References: <20180222102317.25776-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 22 Feb 2018 10:23:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 22 Feb 2018 10:23:24 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' 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: 66.187.233.73 Subject: [Qemu-devel] [PULL 6/9] keymap: use glib hash for kbd_layout_t 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" Drop home-grown lookup code, which is a strange mix of a lookup table and a list. Use standard glib hash instead. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrang=C3=A9 Message-id: 20180222070513.8740-3-kraxel@redhat.com --- ui/keymaps.c | 73 ++++++++++++++++++++++++-----------------------------= ---- ui/trace-events | 2 +- 2 files changed, 32 insertions(+), 43 deletions(-) diff --git a/ui/keymaps.c b/ui/keymaps.c index 134958a197..449c3dec22 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -28,22 +28,18 @@ #include "trace.h" #include "qemu/error-report.h" =20 -#define MAX_NORMAL_KEYCODE 512 -#define MAX_EXTRA_COUNT 256 - struct key_range { int start; int end; struct key_range *next; }; =20 +struct keysym2code { + uint16_t keycode; +}; + struct kbd_layout_t { - uint16_t keysym2keycode[MAX_NORMAL_KEYCODE]; - struct { - int keysym; - uint16_t keycode; - } keysym2keycode_extra[MAX_EXTRA_COUNT]; - int extra_count; + GHashTable *hash; struct key_range *keypad_range; struct key_range *numlock_range; }; @@ -91,23 +87,19 @@ static void add_to_key_range(struct key_range **krp, in= t code) { } } =20 -static void add_keysym(char *line, int keysym, int keycode, kbd_layout_t *= k) { - if (keysym < MAX_NORMAL_KEYCODE) { - trace_keymap_add("normal", keysym, keycode, line); - k->keysym2keycode[keysym] =3D keycode; - } else { - if (k->extra_count >=3D MAX_EXTRA_COUNT) { - warn_report("Could not assign keysym %s (0x%x)" - " because of memory constraints.", line, keysym); - } else { - trace_keymap_add("extra", keysym, keycode, line); - k->keysym2keycode_extra[k->extra_count]. - keysym =3D keysym; - k->keysym2keycode_extra[k->extra_count]. - keycode =3D keycode; - k->extra_count++; - } +static void add_keysym(char *line, int keysym, int keycode, kbd_layout_t *= k) +{ + struct keysym2code *keysym2code; + + keysym2code =3D g_hash_table_lookup(k->hash, GINT_TO_POINTER(keysym)); + if (keysym2code) { + return; } + + keysym2code =3D g_new0(struct keysym2code, 1); + keysym2code->keycode =3D keycode; + g_hash_table_replace(k->hash, GINT_TO_POINTER(keysym), keysym2code); + trace_keymap_add(keysym, keycode, line); } =20 static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table, @@ -131,6 +123,7 @@ static kbd_layout_t *parse_keyboard_layout(const name2k= eysym_t *table, =20 if (!k) { k =3D g_new0(kbd_layout_t, 1); + k->hash =3D g_hash_table_new(NULL, NULL); } =20 for(;;) { @@ -215,26 +208,22 @@ kbd_layout_t *init_keyboard_layout(const name2keysym_= t *table, =20 int keysym2scancode(kbd_layout_t *k, int keysym) { - if (keysym < MAX_NORMAL_KEYCODE) { - if (k->keysym2keycode[keysym] =3D=3D 0) { - trace_keymap_unmapped(keysym); - warn_report("no scancode found for keysym %d", keysym); - } - return k->keysym2keycode[keysym]; - } else { - int i; + struct keysym2code *keysym2code; + #ifdef XK_ISO_Left_Tab - if (keysym =3D=3D XK_ISO_Left_Tab) { - keysym =3D XK_Tab; - } + if (keysym =3D=3D XK_ISO_Left_Tab) { + keysym =3D XK_Tab; + } #endif - for (i =3D 0; i < k->extra_count; i++) { - if (k->keysym2keycode_extra[i].keysym =3D=3D keysym) { - return k->keysym2keycode_extra[i].keycode; - } - } + + keysym2code =3D g_hash_table_lookup(k->hash, GINT_TO_POINTER(keysym)); + if (!keysym2code) { + trace_keymap_unmapped(keysym); + warn_report("no scancode found for keysym %d", keysym); + return 0; } - return 0; + + return keysym2code->keycode; } =20 int keycode_is_keypad(kbd_layout_t *k, int keycode) diff --git a/ui/trace-events b/ui/trace-events index 34229e6747..861b68a305 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -78,7 +78,7 @@ qemu_spice_create_update(uint32_t left, uint32_t right, u= int32_t top, uint32_t b =20 # ui/keymaps.c 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_add(int sym, int code, const char *line) "sym=3D0x%04x code=3D0x%04= x (line: %s)" keymap_unmapped(int sym) "sym=3D0x%04x" =20 # ui/x_keymap.c --=20 2.9.3 From nobody Wed Oct 22 06:32:27 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519295357918377.7418330351395; Thu, 22 Feb 2018 02:29:17 -0800 (PST) Received: from localhost ([::1]:37194 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo7p-0007uq-6b for importer@patchew.org; Thu, 22 Feb 2018 05:29:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo2E-0003J5-Ka for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoo2B-0001zy-Du for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:30 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40850 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoo2B-0001yR-5J for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:27 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C84CC40201A1 for ; Thu, 22 Feb 2018 10:23:24 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-147.ams2.redhat.com [10.36.116.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77601AB589; Thu, 22 Feb 2018 10:23:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 200C817536; Thu, 22 Feb 2018 11:23:18 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 22 Feb 2018 11:23:15 +0100 Message-Id: <20180222102317.25776-8-kraxel@redhat.com> In-Reply-To: <20180222102317.25776-1-kraxel@redhat.com> References: <20180222102317.25776-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 22 Feb 2018 10:23:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 22 Feb 2018 10:23:24 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' 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: 66.187.233.73 Subject: [Qemu-devel] [PULL 7/9] keymap: numpad keysyms and keycodes are fixed 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" No need to figure them at runtime from the keymap. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrang=C3=A9 Message-id: 20180222070513.8740-4-kraxel@redhat.com --- ui/keymaps.c | 61 +++++++++-----------------------------------------------= ---- 1 file changed, 9 insertions(+), 52 deletions(-) diff --git a/ui/keymaps.c b/ui/keymaps.c index 449c3dec22..cbdd65c767 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -28,20 +28,12 @@ #include "trace.h" #include "qemu/error-report.h" =20 -struct key_range { - int start; - int end; - struct key_range *next; -}; - struct keysym2code { uint16_t keycode; }; =20 struct kbd_layout_t { GHashTable *hash; - struct key_range *keypad_range; - struct key_range *numlock_range; }; =20 static int get_keysym(const name2keysym_t *table, @@ -64,29 +56,6 @@ static int get_keysym(const name2keysym_t *table, } =20 =20 -static void add_to_key_range(struct key_range **krp, int code) { - struct key_range *kr; - for (kr =3D *krp; kr; kr =3D kr->next) { - if (code >=3D kr->start && code <=3D kr->end) { - break; - } - if (code =3D=3D kr->start - 1) { - kr->start--; - break; - } - if (code =3D=3D kr->end + 1) { - kr->end++; - break; - } - } - if (kr =3D=3D NULL) { - kr =3D g_malloc0(sizeof(*kr)); - kr->start =3D kr->end =3D code; - kr->next =3D *krp; - *krp =3D kr; - } -} - static void add_keysym(char *line, int keysym, int keycode, kbd_layout_t *= k) { struct keysym2code *keysym2code; @@ -160,13 +129,6 @@ static kbd_layout_t *parse_keyboard_layout(const name2= keysym_t *table, const char *rest =3D line + offset + 1; int keycode =3D strtol(rest, NULL, 0); =20 - if (strstr(rest, "numlock")) { - add_to_key_range(&k->keypad_range, keycode); - add_to_key_range(&k->numlock_range, keysym); - /* fprintf(stderr, "keypad keysym %04x keycode %d\= n", - keysym, keycode); */ - } - if (strstr(rest, "shift")) { keycode |=3D SCANCODE_SHIFT; } @@ -228,24 +190,19 @@ int keysym2scancode(kbd_layout_t *k, int keysym) =20 int keycode_is_keypad(kbd_layout_t *k, int keycode) { - struct key_range *kr; - - for (kr =3D k->keypad_range; kr; kr =3D kr->next) { - if (keycode >=3D kr->start && keycode <=3D kr->end) { - return 1; - } + if (keycode >=3D 0x47 && keycode <=3D 0x53) { + return true; } - return 0; + return false; } =20 int keysym_is_numlock(kbd_layout_t *k, int keysym) { - struct key_range *kr; - - for (kr =3D k->numlock_range; kr; kr =3D kr->next) { - if (keysym >=3D kr->start && keysym <=3D kr->end) { - return 1; - } + switch (keysym) { + case 0xffb0 ... 0xffb9: /* KP_0 .. KP_9 */ + case 0xffac: /* KP_Separator */ + case 0xffae: /* KP_Decimal */ + return true; } - return 0; + return false; } --=20 2.9.3 From nobody Wed Oct 22 06:32:27 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15192951427819.933686533547643; Thu, 22 Feb 2018 02:25:42 -0800 (PST) Received: from localhost ([::1]:37159 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo4D-0004aU-O4 for importer@patchew.org; Thu, 22 Feb 2018 05:25:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo2E-0003J8-ML for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoo2B-0001zp-EO for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:30 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44646 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoo2B-0001yK-66 for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:27 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B1B5E8182D2F for ; Thu, 22 Feb 2018 10:23:23 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-147.ams2.redhat.com [10.36.116.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78DDE2026E04; Thu, 22 Feb 2018 10:23:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 28CC217537; Thu, 22 Feb 2018 11:23:18 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 22 Feb 2018 11:23:16 +0100 Message-Id: <20180222102317.25776-9-kraxel@redhat.com> In-Reply-To: <20180222102317.25776-1-kraxel@redhat.com> References: <20180222102317.25776-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 22 Feb 2018 10:23:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 22 Feb 2018 10:23:23 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' 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: 66.187.233.73 Subject: [Qemu-devel] [PULL 8/9] keymap: record multiple keysym -> keycode mappings 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" Sometimes the same keysym can be created using different key combinations. Record them all in the reverse keymap, not only the first one. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrang=C3=A9 Message-id: 20180222070513.8740-5-kraxel@redhat.com --- ui/keymaps.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ui/keymaps.c b/ui/keymaps.c index cbdd65c767..1eba6d7057 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -29,7 +29,8 @@ #include "qemu/error-report.h" =20 struct keysym2code { - uint16_t keycode; + uint32_t count; + uint16_t keycodes[4]; }; =20 struct kbd_layout_t { @@ -62,11 +63,18 @@ static void add_keysym(char *line, int keysym, int keyc= ode, kbd_layout_t *k) =20 keysym2code =3D g_hash_table_lookup(k->hash, GINT_TO_POINTER(keysym)); if (keysym2code) { + if (keysym2code->count < ARRAY_SIZE(keysym2code->keycodes)) { + keysym2code->keycodes[keysym2code->count++] =3D keycode; + } else { + warn_report("more than %zd keycodes for keysym %d", + ARRAY_SIZE(keysym2code->keycodes), keysym); + } return; } =20 keysym2code =3D g_new0(struct keysym2code, 1); - keysym2code->keycode =3D keycode; + keysym2code->keycodes[0] =3D keycode; + keysym2code->count =3D 1; g_hash_table_replace(k->hash, GINT_TO_POINTER(keysym), keysym2code); trace_keymap_add(keysym, keycode, line); } @@ -185,7 +193,7 @@ int keysym2scancode(kbd_layout_t *k, int keysym) return 0; } =20 - return keysym2code->keycode; + return keysym2code->keycodes[0]; } =20 int keycode_is_keypad(kbd_layout_t *k, int keycode) --=20 2.9.3 From nobody Wed Oct 22 06:32:27 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519295456704747.5376071100429; Thu, 22 Feb 2018 02:30:56 -0800 (PST) Received: from localhost ([::1]:37205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo9M-0000ZO-Sy for importer@patchew.org; Thu, 22 Feb 2018 05:30:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoo2E-0003J3-K1 for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoo2B-0001zB-9X for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:30 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54762 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoo2B-0001yH-41 for qemu-devel@nongnu.org; Thu, 22 Feb 2018 05:23:27 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 087B140753A2 for ; Thu, 22 Feb 2018 10:23:24 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-147.ams2.redhat.com [10.36.116.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91039217B400; Thu, 22 Feb 2018 10:23:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3549217538; Thu, 22 Feb 2018 11:23:18 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 22 Feb 2018 11:23:17 +0100 Message-Id: <20180222102317.25776-10-kraxel@redhat.com> In-Reply-To: <20180222102317.25776-1-kraxel@redhat.com> References: <20180222102317.25776-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 22 Feb 2018 10:23:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 22 Feb 2018 10:23:24 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' 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: 66.187.233.73 Subject: [Qemu-devel] [PULL 9/9] keymap: consider modifier state when picking a mapping 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" Pass the modifier state to the keymap lookup function. In case multiple keysym -> keycode mappings exist look at the modifier state and prefer the mapping where the modifier state matches. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrang=C3=A9 Message-id: 20180222070513.8740-6-kraxel@redhat.com --- ui/keymaps.h | 3 ++- ui/curses.c | 3 ++- ui/keymaps.c | 33 ++++++++++++++++++++++++++++++++- ui/sdl.c | 6 +++++- ui/vnc.c | 9 +++++++-- 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/ui/keymaps.h b/ui/keymaps.h index 17ec03387a..0693588225 100644 --- a/ui/keymaps.h +++ b/ui/keymaps.h @@ -54,7 +54,8 @@ typedef struct kbd_layout_t kbd_layout_t; =20 kbd_layout_t *init_keyboard_layout(const name2keysym_t *table, const char *language); -int keysym2scancode(kbd_layout_t *k, int keysym); +int keysym2scancode(kbd_layout_t *k, int keysym, + bool shift, bool altgr, bool ctrl); int keycode_is_keypad(kbd_layout_t *k, int keycode); int keysym_is_numlock(kbd_layout_t *k, int keysym); =20 diff --git a/ui/curses.c b/ui/curses.c index 479b77bd03..597e47fd4a 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -271,7 +271,8 @@ static void curses_refresh(DisplayChangeListener *dcl) keysym =3D chr; } =20 - keycode =3D keysym2scancode(kbd_layout, keysym & KEYSYM_MASK); + keycode =3D keysym2scancode(kbd_layout, keysym & KEYSYM_MASK, + false, false, false); if (keycode =3D=3D 0) continue; =20 diff --git a/ui/keymaps.c b/ui/keymaps.c index 1eba6d7057..43fe604724 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -176,8 +176,12 @@ kbd_layout_t *init_keyboard_layout(const name2keysym_t= *table, } =20 =20 -int keysym2scancode(kbd_layout_t *k, int keysym) +int keysym2scancode(kbd_layout_t *k, int keysym, + bool shift, bool altgr, bool ctrl) { + static const uint32_t mask =3D + SCANCODE_SHIFT | SCANCODE_ALTGR | SCANCODE_CTRL; + uint32_t mods, i; struct keysym2code *keysym2code; =20 #ifdef XK_ISO_Left_Tab @@ -193,6 +197,33 @@ int keysym2scancode(kbd_layout_t *k, int keysym) return 0; } =20 + if (keysym2code->count =3D=3D 1) { + return keysym2code->keycodes[0]; + } + + /* + * We have multiple keysym -> keycode mappings. + * + * Check whenever we find one mapping where the modifier state of + * the mapping matches the current user interface modifier state. + * If so, prefer that one. + */ + mods =3D 0; + if (shift) { + mods |=3D SCANCODE_SHIFT; + } + if (altgr) { + mods |=3D SCANCODE_ALTGR; + } + if (ctrl) { + mods |=3D SCANCODE_CTRL; + } + + for (i =3D 0; i < keysym2code->count; i++) { + if ((keysym2code->keycodes[i] & mask) =3D=3D mods) { + return keysym2code->keycodes[i]; + } + } return keysym2code->keycodes[0]; } =20 diff --git a/ui/sdl.c b/ui/sdl.c index 963cdf77a7..c4ae7ab05d 100644 --- a/ui/sdl.c +++ b/ui/sdl.c @@ -201,6 +201,9 @@ static kbd_layout_t *kbd_layout =3D NULL; =20 static uint8_t sdl_keyevent_to_keycode_generic(const SDL_KeyboardEvent *ev) { + bool shift =3D modifiers_state[0x2a] || modifiers_state[0x36]; + bool altgr =3D modifiers_state[0xb8]; + bool ctrl =3D modifiers_state[0x1d] || modifiers_state[0x9d]; int keysym; /* workaround for X11+SDL bug with AltGR */ keysym =3D ev->keysym.sym; @@ -210,7 +213,8 @@ static uint8_t sdl_keyevent_to_keycode_generic(const SD= L_KeyboardEvent *ev) if (keysym =3D=3D 92 && ev->keysym.scancode =3D=3D 133) { keysym =3D 0xa5; } - return keysym2scancode(kbd_layout, keysym) & SCANCODE_KEYMASK; + return keysym2scancode(kbd_layout, keysym, + shift, altgr, ctrl) & SCANCODE_KEYMASK; } =20 =20 diff --git a/ui/vnc.c b/ui/vnc.c index a77b568b57..d19f86c7f4 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1734,7 +1734,8 @@ static void reset_keys(VncState *vs) =20 static void press_key(VncState *vs, int keysym) { - int keycode =3D keysym2scancode(vs->vd->kbd_layout, keysym) & SCANCODE= _KEYMASK; + int keycode =3D keysym2scancode(vs->vd->kbd_layout, keysym, + false, false, false) & SCANCODE_KEYMASK; qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, true); qemu_input_event_send_key_delay(vs->vd->key_delay_ms); qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, false); @@ -1993,6 +1994,9 @@ static const char *code2name(int keycode) =20 static void key_event(VncState *vs, int down, uint32_t sym) { + bool shift =3D vs->modifiers_state[0x2a] || vs->modifiers_state[0x36]; + bool altgr =3D vs->modifiers_state[0xb8]; + bool ctrl =3D vs->modifiers_state[0x1d] || vs->modifiers_state[0x9d]; int keycode; int lsym =3D sym; =20 @@ -2000,7 +2004,8 @@ static void key_event(VncState *vs, int down, uint32_= t sym) lsym =3D lsym - 'A' + 'a'; } =20 - keycode =3D keysym2scancode(vs->vd->kbd_layout, lsym & 0xFFFF) & SCANC= ODE_KEYMASK; + keycode =3D keysym2scancode(vs->vd->kbd_layout, lsym & 0xFFFF, + shift, altgr, ctrl) & SCANCODE_KEYMASK; trace_vnc_key_event_map(down, sym, keycode, code2name(keycode)); do_key_event(vs, down, keycode, sym); } --=20 2.9.3