From patchwork Wed Oct 11 08:35:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 824289 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yBnTQ59yfz9t3H for ; Wed, 11 Oct 2017 19:39:21 +1100 (AEDT) Received: from localhost ([::1]:39157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CXu-0006Ki-Vi for incoming@patchwork.ozlabs.org; Wed, 11 Oct 2017 04:39:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CUu-0003vp-3K for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2CUr-0007jr-S1 for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36020) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e2CUr-0007iY-JT for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:09 -0400 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 9F0DF81DE2 for ; Wed, 11 Oct 2017 08:36:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9F0DF81DE2 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74A6718952; Wed, 11 Oct 2017 08:36:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id AC3DA16A887; Wed, 11 Oct 2017 10:36:04 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 11 Oct 2017 10:35:55 +0200 Message-Id: <20171011083604.11820-2-kraxel@redhat.com> In-Reply-To: <20171011083604.11820-1-kraxel@redhat.com> References: <20171011083604.11820-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.25]); Wed, 11 Oct 2017 08:36:08 +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 01/10] build: automatically handle GIT submodule checkout for dtc 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Daniel P. Berrange" Currently if DTC is required by configure and not available in the host OS install, we exit with an error message telling the user to checkout a git submodule or install the library. This introduces automatic handling of the git submodule checkout process and enables it for dtc. This only runs if building from GIT, so users of release tarballs still need the system library install. The current state of the git checkout is stashed in .git-submodule-status, and a helper program is used to determine if this state matches the desired submodule state. A dependency against 'Makefile' ensures that the submodule state is refreshed at the start of the build process Signed-off-by: Daniel P. Berrange Message-id: 20170929101201.21039-2-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- configure | 46 ++++++++++++++++++++++++++-------------------- Makefile | 25 ++++++++++++++++++++++++- .gitignore | 1 + MAINTAINERS | 6 ++++++ scripts/git-submodule.sh | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+), 21 deletions(-) create mode 100755 scripts/git-submodule.sh diff --git a/configure b/configure index 6587e8014b..38f1710c80 100755 --- a/configure +++ b/configure @@ -264,6 +264,7 @@ cc_i386=i386-pc-linux-gnu-gcc libs_qga="" debug_info="yes" stack_protector="" +git_submodules="" # Don't accept a target_list environment variable. unset target_list @@ -3584,27 +3585,30 @@ EOF if compile_prog "" "$fdt_libs" ; then # system DTC is good - use it fdt=yes - elif test -d ${source_path}/dtc/libfdt ; then - # have submodule DTC - use it - fdt=yes - dtc_internal="yes" - mkdir -p dtc - if [ "$pwd_is_source_path" != "y" ] ; then - symlink "$source_path/dtc/Makefile" "dtc/Makefile" - symlink "$source_path/dtc/scripts" "dtc/scripts" - fi - fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt" - fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs" - elif test "$fdt" = "yes" ; then - # have neither and want - prompt for system/submodule install - error_exit "DTC (libfdt) version >= 1.4.2 not present. Your options:" \ - " (1) Preferred: Install the DTC (libfdt) devel package" \ - " (2) Fetch the DTC submodule, using:" \ - " git submodule update --init dtc" else - # don't have and don't want - fdt_libs= - fdt=no + # have GIT checkout, so activate dtc submodule + if test -e "${source_path}/.git" ; then + git_submodules="${git_submodules} dtc" + fi + if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then + fdt=yes + dtc_internal="yes" + mkdir -p dtc + if [ "$pwd_is_source_path" != "y" ] ; then + symlink "$source_path/dtc/Makefile" "dtc/Makefile" + symlink "$source_path/dtc/scripts" "dtc/scripts" + fi + fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt" + fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs" + elif test "$fdt" = "yes" ; then + # Not a git build & no libfdt found, prompt for system install + error_exit "DTC (libfdt) version >= 1.4.2 not present." \ + "Please install the DTC (libfdt) devel package" + else + # don't have and don't want + fdt_libs= + fdt=no + fi fi fi @@ -5295,6 +5299,7 @@ echo "local state directory queried at runtime" echo "Windows SDK $win_sdk" fi echo "Source path $source_path" +echo "GIT submodules $git_submodules" echo "C compiler $cc" echo "Host C compiler $host_cc" echo "C++ compiler $cxx" @@ -5483,6 +5488,7 @@ echo "extra_cxxflags=$EXTRA_CXXFLAGS" >> $config_host_mak echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak echo "qemu_localedir=$qemu_localedir" >> $config_host_mak echo "libs_softmmu=$libs_softmmu" >> $config_host_mak +echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak echo "ARCH=$ARCH" >> $config_host_mak diff --git a/Makefile b/Makefile index cee6e28659..cec0f44374 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,29 @@ ifneq ($(wildcard config-host.mak),) all: include config-host.mak +git-submodule-update: + +.PHONY: git-submodule-update + +ifeq (0,$(MAKELEVEL)) + git_module_status := $(shell \ + cd '$(SRC_PATH)' && \ + ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \ + echo $$?; \ + ) + +ifeq (1,$(git_module_status)) +git-submodule-update: + $(call quiet-command, \ + (cd $(SRC_PATH) && ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \ + "GIT","$(GIT_SUBMODULES)") +endif +endif + +.git-submodule-status: git-submodule-update + +Makefile: .git-submodule-status + # Check that we're not trying to do an out-of-tree build from # a tree that's been used for an in-tree build. ifneq ($(realpath $(SRC_PATH)),$(realpath .)) @@ -330,7 +353,7 @@ DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_src DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS) DTC_CPPFLAGS=-I$(BUILD_DIR)/dtc -I$(SRC_PATH)/dtc -I$(SRC_PATH)/dtc/libfdt -subdir-dtc:dtc/libfdt dtc/tests +subdir-dtc: .git-submodule-status dtc/libfdt dtc/tests $(call quiet-command,$(MAKE) $(DTC_MAKE_ARGS) CPPFLAGS="$(DTC_CPPFLAGS)" CFLAGS="$(DTC_CFLAGS)" LDFLAGS="$(LDFLAGS)" ARFLAGS="$(ARFLAGS)" CC="$(CC)" AR="$(AR)" LD="$(LD)" $(SUBDIR_MAKEFLAGS) libfdt/libfdt.a,) dtc/%: diff --git a/.gitignore b/.gitignore index 3a7e01dc6a..b5e115d96b 100644 --- a/.gitignore +++ b/.gitignore @@ -113,6 +113,7 @@ /docs/version.texi *.tps .stgit-* +.git-submodule-status cscope.* tags TAGS diff --git a/MAINTAINERS b/MAINTAINERS index 772ac209e1..bb585bbd8f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1949,3 +1949,9 @@ M: Daniel P. Berrange S: Odd Fixes F: docs/devel/build-system.txt +Build System +------------ +GIT submodules +M: Daniel P. Berrange +S: Odd Fixes +F: scripts/git-submodule.sh diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh new file mode 100755 index 0000000000..9f73f0e6e3 --- /dev/null +++ b/scripts/git-submodule.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# This code is licensed under the GPL version 2 or later. See +# the COPYING file in the top-level directory. + +set -e + +substat=".git-submodule-status" + +command=$1 +shift +modules="$@" + +if test -z "$modules" +then + test -e $substat || touch $substat + exit 0 +fi + +if ! test -e ".git" +then + echo "$0: unexpectedly called with submodules but no git checkout exists" + exit 1 +fi + +case "$command" in +status) + test -f "$substat" || exit 1 + trap "rm -f ${substat}.tmp" EXIT + git submodule status $modules > "${substat}.tmp" + diff "${substat}" "${substat}.tmp" >/dev/null + exit $? + ;; +update) + git submodule update --init $modules 1>/dev/null 2>&1 + git submodule status $modules > "${substat}" + ;; +esac From patchwork Wed Oct 11 08:35:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 824294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yBnWy70hDz9t3H for ; Wed, 11 Oct 2017 19:41:34 +1100 (AEDT) Received: from localhost ([::1]:39198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2Ca5-0008H2-2w for incoming@patchwork.ozlabs.org; Wed, 11 Oct 2017 04:41:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CUw-0003xz-V9 for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2CUq-0007iQ-Tg for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34220) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e2CUq-0007hV-LN for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:08 -0400 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 AE60446210 for ; Wed, 11 Oct 2017 08:36:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AE60446210 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7103A53CC7; Wed, 11 Oct 2017 08:36:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B380116A88F; Wed, 11 Oct 2017 10:36:04 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 11 Oct 2017 10:35:56 +0200 Message-Id: <20171011083604.11820-3-kraxel@redhat.com> In-Reply-To: <20171011083604.11820-1-kraxel@redhat.com> References: <20171011083604.11820-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.29]); Wed, 11 Oct 2017 08:36:07 +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 02/10] docker: don't rely on submodules existing in the main checkout 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Daniel P. Berrange" When building the tarball to pass into the docker/vm test image, the code relies on the git submodules being checked out in the main checkout. ie if the developer has not run 'git submodule update --init dtc' many of the docker tests will fail due to the libfdt package not being present in the test images. Patchew manually checks out the dtc submodule in the main git checkout, but this is a bad idea. When running tests we want to have a predictable set of submodules included in the source that's tested. The build environment is completely independent of the developers host OS, so the submodules the developer has checked out should not be considered relevant for the tests. This changes the archive-source.sh script so that it clones the current git checkout into a temporary directory, checks out a fixed set of submodules, builds the tarball and finally removes the temporary git clone. Signed-off-by: Daniel P. Berrange Message-id: 20170929101201.21039-3-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- scripts/archive-source.sh | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh index c4e7d98f4d..4029de7b20 100755 --- a/scripts/archive-source.sh +++ b/scripts/archive-source.sh @@ -18,15 +18,37 @@ if test $# -lt 1; then error "Usage: $0 " fi -tar_file="$1" -list_file="$1.list" -submodules=$(git submodule foreach --recursive --quiet 'echo $name') +tar_file=`realpath "$1"` +list_file="${tar_file}.list" +vroot_dir="${tar_file}.vroot" -if test $? -ne 0; then - error "git submodule command failed" +# We want a predictable list of submodules for builds, that is +# independent of what the developer currently has initialized +# in their checkout, because the build environment is completely +# different to the host OS. +submodules="dtc" + +trap "status=$?; rm -rf \"$list_file\" \"$vroot_dir\"; exit \$status" 0 1 2 3 15 + +if git diff-index --quiet HEAD -- &>/dev/null +then + HEAD=HEAD +else + HEAD=`git stash create` fi +git clone --shared . "$vroot_dir" +test $? -ne 0 && error "failed to clone into '$vroot_dir'" -trap "status=$?; rm -f \"$list_file\"; exit \$status" 0 1 2 3 15 +cd "$vroot_dir" +test $? -ne 0 && error "failed to change into '$vroot_dir'" + +git checkout $HEAD +test $? -ne 0 && error "failed to checkout $HEAD revision" + +for sm in $submodules; do + git submodule update --init $sm + test $? -ne 0 && error "failed to init submodule $sm" +done if test -n "$submodules"; then { From patchwork Wed Oct 11 08:35:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 824285 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yBnQg2RcCz9t3Z for ; Wed, 11 Oct 2017 19:36:59 +1100 (AEDT) Received: from localhost ([::1]:39149 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CVd-0003yV-DF for incoming@patchwork.ozlabs.org; Wed, 11 Oct 2017 04:36:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CUu-0003vn-2d for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2CUr-0007ix-79 for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54750) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e2CUq-0007hf-Ug for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:09 -0400 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 ED65AC04AC7E for ; Wed, 11 Oct 2017 08:36:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ED65AC04AC7E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F89D17984; Wed, 11 Oct 2017 08:36:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id BF21A16A89E; Wed, 11 Oct 2017 10:36:04 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 11 Oct 2017 10:35:57 +0200 Message-Id: <20171011083604.11820-4-kraxel@redhat.com> In-Reply-To: <20171011083604.11820-1-kraxel@redhat.com> References: <20171011083604.11820-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.31]); Wed, 11 Oct 2017 08:36:08 +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 03/10] ui: add keycodemapdb repository as a GIT submodule 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Daniel P. Berrange" The https://gitlab.com/keycodemap/keycodemapdb/ repo contains a data file mapping between all the different scancode/keycode/keysym sets that are known, and a tool to auto-generate lookup tables for different combinations. It is used by GTK-VNC, SPICE-GTK and libvirt for mapping keys. Using it in QEMU will let us replace many hand written lookup tables with auto-generated tables from a master data source, reducing bugs. Adding new QKeyCodes will now only require the master table to be updated, all ~20 other tables will be automatically updated to follow. Signed-off-by: Daniel P. Berrange Message-id: 20170929101201.21039-4-berrange@redhat.com [ kraxel: fix build ] Signed-off-by: Gerd Hoffmann --- configure | 8 +++++++- Makefile | 24 +++++++++++++++++++++++- .gitignore | 1 + .gitmodules | 3 +++ scripts/archive-source.sh | 2 +- ui/keycodemapdb | 1 + 6 files changed, 36 insertions(+), 3 deletions(-) create mode 160000 ui/keycodemapdb diff --git a/configure b/configure index 38f1710c80..06f18ea9af 100755 --- a/configure +++ b/configure @@ -264,7 +264,13 @@ cc_i386=i386-pc-linux-gnu-gcc libs_qga="" debug_info="yes" stack_protector="" -git_submodules="" + +if test -e "$source_path/.git" +then + git_submodules="ui/keycodemapdb" +else + git_submodules="" +fi # Don't accept a target_list environment variable. unset target_list diff --git a/Makefile b/Makefile index cec0f44374..53c66f765b 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ git-submodule-update: endif endif -.git-submodule-status: git-submodule-update +.git-submodule-status: git-submodule-update config-host.mak Makefile: .git-submodule-status @@ -214,6 +214,28 @@ trace-dtrace-root.h: trace-dtrace-root.dtrace trace-dtrace-root.o: trace-dtrace-root.dtrace +KEYCODEMAP_GEN = $(SRC_PATH)/ui/keycodemapdb/tools/keymap-gen +KEYCODEMAP_CSV = $(SRC_PATH)/ui/keycodemapdb/data/keymaps.csv + +KEYCODEMAP_FILES = \ + $(NULL) + +GENERATED_FILES += $(KEYCODEMAP_FILES) + +ui/input-keymap-%.c: $(KEYCODEMAP_GEN) $(KEYCODEMAP_CSV) $(SRC_PATH)/ui/Makefile.objs + $(call quiet-command,\ + src=$$(echo $@ | sed -E -e "s,^ui/input-keymap-(.+)-to-(.+)\.c$$,\1,") && \ + dst=$$(echo $@ | sed -E -e "s,^ui/input-keymap-(.+)-to-(.+)\.c$$,\2,") && \ + test -e $(KEYCODEMAP_GEN) && \ + $(PYTHON) $(KEYCODEMAP_GEN) \ + --lang glib2 \ + --varname qemu_input_map_$${src}_to_$${dst} \ + code-map $(KEYCODEMAP_CSV) $${src} $${dst} \ + > $@ || rm -f $@, "GEN", "$@") + +$(KEYCODEMAP_GEN): .git-submodule-status +$(KEYCODEMAP_CSV): .git-submodule-status + # Don't try to regenerate Makefile or configure # We don't generate any of them Makefile: ; diff --git a/.gitignore b/.gitignore index b5e115d96b..620eec6b47 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ /trace/generated-tcg-tracers.h /ui/shader/texture-blit-frag.h /ui/shader/texture-blit-vert.h +/ui/input-keymap-*.c *-timestamp /*-softmmu /*-darwin-user diff --git a/.gitmodules b/.gitmodules index 84c54cdc49..f3bbc01f82 100644 --- a/.gitmodules +++ b/.gitmodules @@ -34,3 +34,6 @@ [submodule "roms/QemuMacDrivers"] path = roms/QemuMacDrivers url = git://git.qemu.org/QemuMacDrivers.git +[submodule "ui/keycodemapdb"] + path = ui/keycodemapdb + url = https://gitlab.com/keycodemap/keycodemapdb.git diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh index 4029de7b20..4e63774f9a 100755 --- a/scripts/archive-source.sh +++ b/scripts/archive-source.sh @@ -26,7 +26,7 @@ vroot_dir="${tar_file}.vroot" # independent of what the developer currently has initialized # in their checkout, because the build environment is completely # different to the host OS. -submodules="dtc" +submodules="dtc ui/keycodemapdb" trap "status=$?; rm -rf \"$list_file\" \"$vroot_dir\"; exit \$status" 0 1 2 3 15 diff --git a/ui/keycodemapdb b/ui/keycodemapdb new file mode 160000 index 0000000000..56ce5650d2 --- /dev/null +++ b/ui/keycodemapdb @@ -0,0 +1 @@ +Subproject commit 56ce5650d2c6ea216b4580df44b9a6dd3bc92c3b From patchwork Wed Oct 11 08:35:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 824293 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yBnWq6Jhlz9t3H for ; Wed, 11 Oct 2017 19:41:27 +1100 (AEDT) Received: from localhost ([::1]:39197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CZy-0008A8-1j for incoming@patchwork.ozlabs.org; Wed, 11 Oct 2017 04:41:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CUu-0003vo-32 for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2CUr-0007jQ-LD for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48222) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e2CUr-0007iH-Bl for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:09 -0400 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 72F5AC0587ED for ; Wed, 11 Oct 2017 08:36:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 72F5AC0587ED Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79CFD19639; Wed, 11 Oct 2017 08:36:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C85F14FD40; Wed, 11 Oct 2017 10:36:04 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 11 Oct 2017 10:35:58 +0200 Message-Id: <20171011083604.11820-5-kraxel@redhat.com> In-Reply-To: <20171011083604.11820-1-kraxel@redhat.com> References: <20171011083604.11820-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.32]); Wed, 11 Oct 2017 08:36:08 +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 04/10] ui: convert common input code 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Daniel P. Berrange" Replace the number_to_qcode, qcode_to_number and linux_to_qcode tables with automatically generated tables. Missing entries in linux_to_qcode now fixed: KEY_LINEFEED -> Q_KEY_CODE_LF KEY_KPEQUAL -> Q_KEY_CODE_KP_EQUALS KEY_COMPOSE -> Q_KEY_CODE_COMPOSE KEY_AGAIN -> Q_KEY_CODE_AGAIN KEY_PROPS -> Q_KEY_CODE_PROPS KEY_UNDO -> Q_KEY_CODE_UNDO KEY_FRONT -> Q_KEY_CODE_FRONT KEY_COPY -> Q_KEY_CODE_COPY KEY_OPEN -> Q_KEY_CODE_OPEN KEY_PASTE -> Q_KEY_CODE_PASTE KEY_CUT -> Q_KEY_CODE_CUT KEY_HELP -> Q_KEY_CODE_HELP KEY_MEDIA -> Q_KEY_CODE_MEDIASELECT In addition, some fixes: - KEY_PLAYPAUSE now maps to Q_KEY_CODE_AUDIOPLAY, instead of KEY_PLAYCD. KEY_PLAYPAUSE is defined across almost all scancodes sets, while KEY_PLAYCD only appears in AT set1, so the former is a more useful mapping. Missing entries in qcode_to_number now fixed: Q_KEY_CODE_AGAIN -> 0x85 Q_KEY_CODE_PROPS -> 0x86 Q_KEY_CODE_UNDO -> 0x87 Q_KEY_CODE_FRONT -> 0x8c Q_KEY_CODE_COPY -> 0xf8 Q_KEY_CODE_OPEN -> 0x64 Q_KEY_CODE_PASTE -> 0x65 Q_KEY_CODE_CUT -> 0xbc Q_KEY_CODE_LF -> 0x5b Q_KEY_CODE_HELP -> 0xf5 Q_KEY_CODE_COMPOSE -> 0xdd Q_KEY_CODE_KP_EQUALS -> 0x59 Q_KEY_CODE_MEDIASELECT -> 0xed In addition, some fixes: - Q_KEY_CODE_MENU was incorrectly mapped to the compose scancode (0xdd) and is now mapped to 0x9e - Q_KEY_CODE_FIND was mapped to 0xe065 (Search) instead of to 0xe041 (Find) - Q_KEY_CODE_HIRAGANA was mapped to 0x70 (Katakanahiragana) instead of of 0x77 (Hirigana) - Q_KEY_CODE_PRINT was mapped to 0xb7 which is not a defined scan code in AT set 1, it is now mapped to 0x54 (sysrq) Signed-off-by: Daniel P. Berrange Message-id: 20170929101201.21039-5-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- Makefile | 3 + include/ui/input.h | 11 +- ui/input-keymap.c | 336 ++++------------------------------------------------- 3 files changed, 33 insertions(+), 317 deletions(-) diff --git a/Makefile b/Makefile index 53c66f765b..f76b87472c 100644 --- a/Makefile +++ b/Makefile @@ -218,6 +218,9 @@ KEYCODEMAP_GEN = $(SRC_PATH)/ui/keycodemapdb/tools/keymap-gen KEYCODEMAP_CSV = $(SRC_PATH)/ui/keycodemapdb/data/keymaps.csv KEYCODEMAP_FILES = \ + ui/input-keymap-linux-to-qcode.c \ + ui/input-keymap-qcode-to-qnum.c \ + ui/input-keymap-qnum-to-qcode.c \ $(NULL) GENERATED_FILES += $(KEYCODEMAP_FILES) diff --git a/include/ui/input.h b/include/ui/input.h index c488585def..479cc46cfc 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -43,7 +43,7 @@ void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down); void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down); void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down); void qemu_input_event_send_key_delay(uint32_t delay_ms); -int qemu_input_key_number_to_qcode(uint8_t nr); +int qemu_input_key_number_to_qcode(unsigned int nr); int qemu_input_key_value_to_number(const KeyValue *value); int qemu_input_key_value_to_qcode(const KeyValue *value); int qemu_input_key_value_to_scancode(const KeyValue *value, bool down, @@ -69,4 +69,13 @@ 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); +extern const guint qemu_input_map_linux_to_qcode_len; +extern const guint16 qemu_input_map_linux_to_qcode[]; + +extern const guint qemu_input_map_qcode_to_qnum_len; +extern const guint16 qemu_input_map_qcode_to_qnum[]; + +extern const guint qemu_input_map_qnum_to_qcode_len; +extern const guint16 qemu_input_map_qnum_to_qcode[]; + #endif /* INPUT_H */ diff --git a/ui/input-keymap.c b/ui/input-keymap.c index cf979c2ce9..3a19a169f5 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -5,333 +5,37 @@ #include "standard-headers/linux/input.h" -static int linux_to_qcode[KEY_CNT] = { - [KEY_ESC] = Q_KEY_CODE_ESC, - [KEY_1] = Q_KEY_CODE_1, - [KEY_2] = Q_KEY_CODE_2, - [KEY_3] = Q_KEY_CODE_3, - [KEY_4] = Q_KEY_CODE_4, - [KEY_5] = Q_KEY_CODE_5, - [KEY_6] = Q_KEY_CODE_6, - [KEY_7] = Q_KEY_CODE_7, - [KEY_8] = Q_KEY_CODE_8, - [KEY_9] = Q_KEY_CODE_9, - [KEY_0] = Q_KEY_CODE_0, - [KEY_MINUS] = Q_KEY_CODE_MINUS, - [KEY_EQUAL] = Q_KEY_CODE_EQUAL, - [KEY_BACKSPACE] = Q_KEY_CODE_BACKSPACE, - [KEY_TAB] = Q_KEY_CODE_TAB, - [KEY_Q] = Q_KEY_CODE_Q, - [KEY_W] = Q_KEY_CODE_W, - [KEY_E] = Q_KEY_CODE_E, - [KEY_R] = Q_KEY_CODE_R, - [KEY_T] = Q_KEY_CODE_T, - [KEY_Y] = Q_KEY_CODE_Y, - [KEY_U] = Q_KEY_CODE_U, - [KEY_I] = Q_KEY_CODE_I, - [KEY_O] = Q_KEY_CODE_O, - [KEY_P] = Q_KEY_CODE_P, - [KEY_LEFTBRACE] = Q_KEY_CODE_BRACKET_LEFT, - [KEY_RIGHTBRACE] = Q_KEY_CODE_BRACKET_RIGHT, - [KEY_ENTER] = Q_KEY_CODE_RET, - [KEY_LEFTCTRL] = Q_KEY_CODE_CTRL, - [KEY_A] = Q_KEY_CODE_A, - [KEY_S] = Q_KEY_CODE_S, - [KEY_D] = Q_KEY_CODE_D, - [KEY_F] = Q_KEY_CODE_F, - [KEY_G] = Q_KEY_CODE_G, - [KEY_H] = Q_KEY_CODE_H, - [KEY_J] = Q_KEY_CODE_J, - [KEY_K] = Q_KEY_CODE_K, - [KEY_L] = Q_KEY_CODE_L, - [KEY_SEMICOLON] = Q_KEY_CODE_SEMICOLON, - [KEY_APOSTROPHE] = Q_KEY_CODE_APOSTROPHE, - [KEY_GRAVE] = Q_KEY_CODE_GRAVE_ACCENT, - [KEY_LEFTSHIFT] = Q_KEY_CODE_SHIFT, - [KEY_BACKSLASH] = Q_KEY_CODE_BACKSLASH, - [KEY_102ND] = Q_KEY_CODE_LESS, - [KEY_Z] = Q_KEY_CODE_Z, - [KEY_X] = Q_KEY_CODE_X, - [KEY_C] = Q_KEY_CODE_C, - [KEY_V] = Q_KEY_CODE_V, - [KEY_B] = Q_KEY_CODE_B, - [KEY_N] = Q_KEY_CODE_N, - [KEY_M] = Q_KEY_CODE_M, - [KEY_COMMA] = Q_KEY_CODE_COMMA, - [KEY_DOT] = Q_KEY_CODE_DOT, - [KEY_SLASH] = Q_KEY_CODE_SLASH, - [KEY_RIGHTSHIFT] = Q_KEY_CODE_SHIFT_R, - [KEY_LEFTALT] = Q_KEY_CODE_ALT, - [KEY_SPACE] = Q_KEY_CODE_SPC, - [KEY_CAPSLOCK] = Q_KEY_CODE_CAPS_LOCK, - [KEY_F1] = Q_KEY_CODE_F1, - [KEY_F2] = Q_KEY_CODE_F2, - [KEY_F3] = Q_KEY_CODE_F3, - [KEY_F4] = Q_KEY_CODE_F4, - [KEY_F5] = Q_KEY_CODE_F5, - [KEY_F6] = Q_KEY_CODE_F6, - [KEY_F7] = Q_KEY_CODE_F7, - [KEY_F8] = Q_KEY_CODE_F8, - [KEY_F9] = Q_KEY_CODE_F9, - [KEY_F10] = Q_KEY_CODE_F10, - [KEY_NUMLOCK] = Q_KEY_CODE_NUM_LOCK, - [KEY_SCROLLLOCK] = Q_KEY_CODE_SCROLL_LOCK, - [KEY_KP0] = Q_KEY_CODE_KP_0, - [KEY_KP1] = Q_KEY_CODE_KP_1, - [KEY_KP2] = Q_KEY_CODE_KP_2, - [KEY_KP3] = Q_KEY_CODE_KP_3, - [KEY_KP4] = Q_KEY_CODE_KP_4, - [KEY_KP5] = Q_KEY_CODE_KP_5, - [KEY_KP6] = Q_KEY_CODE_KP_6, - [KEY_KP7] = Q_KEY_CODE_KP_7, - [KEY_KP8] = Q_KEY_CODE_KP_8, - [KEY_KP9] = Q_KEY_CODE_KP_9, - [KEY_KPMINUS] = Q_KEY_CODE_KP_SUBTRACT, - [KEY_KPPLUS] = Q_KEY_CODE_KP_ADD, - [KEY_KPDOT] = Q_KEY_CODE_KP_DECIMAL, - [KEY_KPENTER] = Q_KEY_CODE_KP_ENTER, - [KEY_KPSLASH] = Q_KEY_CODE_KP_DIVIDE, - [KEY_KPASTERISK] = Q_KEY_CODE_KP_MULTIPLY, - [KEY_F11] = Q_KEY_CODE_F11, - [KEY_F12] = Q_KEY_CODE_F12, - [KEY_RO] = Q_KEY_CODE_RO, - [KEY_HIRAGANA] = Q_KEY_CODE_HIRAGANA, - [KEY_HENKAN] = Q_KEY_CODE_HENKAN, - [KEY_RIGHTCTRL] = Q_KEY_CODE_CTRL_R, - [KEY_SYSRQ] = Q_KEY_CODE_SYSRQ, - [KEY_RIGHTALT] = Q_KEY_CODE_ALT_R, - [KEY_HOME] = Q_KEY_CODE_HOME, - [KEY_UP] = Q_KEY_CODE_UP, - [KEY_PAGEUP] = Q_KEY_CODE_PGUP, - [KEY_LEFT] = Q_KEY_CODE_LEFT, - [KEY_RIGHT] = Q_KEY_CODE_RIGHT, - [KEY_END] = Q_KEY_CODE_END, - [KEY_DOWN] = Q_KEY_CODE_DOWN, - [KEY_PAGEDOWN] = Q_KEY_CODE_PGDN, - [KEY_INSERT] = Q_KEY_CODE_INSERT, - [KEY_DELETE] = Q_KEY_CODE_DELETE, - [KEY_POWER] = Q_KEY_CODE_POWER, - [KEY_KPCOMMA] = Q_KEY_CODE_KP_COMMA, - [KEY_YEN] = Q_KEY_CODE_YEN, - [KEY_LEFTMETA] = Q_KEY_CODE_META_L, - [KEY_RIGHTMETA] = Q_KEY_CODE_META_R, - [KEY_MENU] = Q_KEY_CODE_MENU, - [KEY_PAUSE] = Q_KEY_CODE_PAUSE, - - [KEY_SLEEP] = Q_KEY_CODE_SLEEP, - [KEY_WAKEUP] = Q_KEY_CODE_WAKE, - [KEY_CALC] = Q_KEY_CODE_CALCULATOR, - [KEY_MAIL] = Q_KEY_CODE_MAIL, - [KEY_COMPUTER] = Q_KEY_CODE_COMPUTER, - - [KEY_STOP] = Q_KEY_CODE_STOP, - [KEY_BOOKMARKS] = Q_KEY_CODE_AC_BOOKMARKS, - [KEY_BACK] = Q_KEY_CODE_AC_BACK, - [KEY_FORWARD] = Q_KEY_CODE_AC_FORWARD, - [KEY_HOMEPAGE] = Q_KEY_CODE_AC_HOME, - [KEY_REFRESH] = Q_KEY_CODE_AC_REFRESH, - [KEY_FIND] = Q_KEY_CODE_FIND, - - [KEY_NEXTSONG] = Q_KEY_CODE_AUDIONEXT, - [KEY_PREVIOUSSONG] = Q_KEY_CODE_AUDIOPREV, - [KEY_STOPCD] = Q_KEY_CODE_AUDIOSTOP, - [KEY_PLAYCD] = Q_KEY_CODE_AUDIOPLAY, - [KEY_MUTE] = Q_KEY_CODE_AUDIOMUTE, - [KEY_VOLUMEDOWN] = Q_KEY_CODE_VOLUMEDOWN, - [KEY_VOLUMEUP] = Q_KEY_CODE_VOLUMEUP, -}; - -static const int qcode_to_number[] = { - [Q_KEY_CODE_SHIFT] = 0x2a, - [Q_KEY_CODE_SHIFT_R] = 0x36, - - [Q_KEY_CODE_ALT] = 0x38, - [Q_KEY_CODE_ALT_R] = 0xb8, - [Q_KEY_CODE_CTRL] = 0x1d, - [Q_KEY_CODE_CTRL_R] = 0x9d, - - [Q_KEY_CODE_META_L] = 0xdb, - [Q_KEY_CODE_META_R] = 0xdc, - [Q_KEY_CODE_MENU] = 0xdd, - - [Q_KEY_CODE_ESC] = 0x01, - - [Q_KEY_CODE_1] = 0x02, - [Q_KEY_CODE_2] = 0x03, - [Q_KEY_CODE_3] = 0x04, - [Q_KEY_CODE_4] = 0x05, - [Q_KEY_CODE_5] = 0x06, - [Q_KEY_CODE_6] = 0x07, - [Q_KEY_CODE_7] = 0x08, - [Q_KEY_CODE_8] = 0x09, - [Q_KEY_CODE_9] = 0x0a, - [Q_KEY_CODE_0] = 0x0b, - [Q_KEY_CODE_MINUS] = 0x0c, - [Q_KEY_CODE_EQUAL] = 0x0d, - [Q_KEY_CODE_BACKSPACE] = 0x0e, - - [Q_KEY_CODE_TAB] = 0x0f, - [Q_KEY_CODE_Q] = 0x10, - [Q_KEY_CODE_W] = 0x11, - [Q_KEY_CODE_E] = 0x12, - [Q_KEY_CODE_R] = 0x13, - [Q_KEY_CODE_T] = 0x14, - [Q_KEY_CODE_Y] = 0x15, - [Q_KEY_CODE_U] = 0x16, - [Q_KEY_CODE_I] = 0x17, - [Q_KEY_CODE_O] = 0x18, - [Q_KEY_CODE_P] = 0x19, - [Q_KEY_CODE_BRACKET_LEFT] = 0x1a, - [Q_KEY_CODE_BRACKET_RIGHT] = 0x1b, - [Q_KEY_CODE_RET] = 0x1c, - - [Q_KEY_CODE_A] = 0x1e, - [Q_KEY_CODE_S] = 0x1f, - [Q_KEY_CODE_D] = 0x20, - [Q_KEY_CODE_F] = 0x21, - [Q_KEY_CODE_G] = 0x22, - [Q_KEY_CODE_H] = 0x23, - [Q_KEY_CODE_J] = 0x24, - [Q_KEY_CODE_K] = 0x25, - [Q_KEY_CODE_L] = 0x26, - [Q_KEY_CODE_SEMICOLON] = 0x27, - [Q_KEY_CODE_APOSTROPHE] = 0x28, - [Q_KEY_CODE_GRAVE_ACCENT] = 0x29, - - [Q_KEY_CODE_BACKSLASH] = 0x2b, - [Q_KEY_CODE_Z] = 0x2c, - [Q_KEY_CODE_X] = 0x2d, - [Q_KEY_CODE_C] = 0x2e, - [Q_KEY_CODE_V] = 0x2f, - [Q_KEY_CODE_B] = 0x30, - [Q_KEY_CODE_N] = 0x31, - [Q_KEY_CODE_M] = 0x32, - [Q_KEY_CODE_COMMA] = 0x33, - [Q_KEY_CODE_DOT] = 0x34, - [Q_KEY_CODE_SLASH] = 0x35, - - [Q_KEY_CODE_ASTERISK] = 0x37, - - [Q_KEY_CODE_SPC] = 0x39, - [Q_KEY_CODE_CAPS_LOCK] = 0x3a, - [Q_KEY_CODE_F1] = 0x3b, - [Q_KEY_CODE_F2] = 0x3c, - [Q_KEY_CODE_F3] = 0x3d, - [Q_KEY_CODE_F4] = 0x3e, - [Q_KEY_CODE_F5] = 0x3f, - [Q_KEY_CODE_F6] = 0x40, - [Q_KEY_CODE_F7] = 0x41, - [Q_KEY_CODE_F8] = 0x42, - [Q_KEY_CODE_F9] = 0x43, - [Q_KEY_CODE_F10] = 0x44, - [Q_KEY_CODE_NUM_LOCK] = 0x45, - [Q_KEY_CODE_SCROLL_LOCK] = 0x46, - - [Q_KEY_CODE_KP_DIVIDE] = 0xb5, - [Q_KEY_CODE_KP_MULTIPLY] = 0x37, - [Q_KEY_CODE_KP_SUBTRACT] = 0x4a, - [Q_KEY_CODE_KP_ADD] = 0x4e, - [Q_KEY_CODE_KP_ENTER] = 0x9c, - [Q_KEY_CODE_KP_DECIMAL] = 0x53, - [Q_KEY_CODE_SYSRQ] = 0x54, - [Q_KEY_CODE_PAUSE] = 0xc6, - - [Q_KEY_CODE_KP_0] = 0x52, - [Q_KEY_CODE_KP_1] = 0x4f, - [Q_KEY_CODE_KP_2] = 0x50, - [Q_KEY_CODE_KP_3] = 0x51, - [Q_KEY_CODE_KP_4] = 0x4b, - [Q_KEY_CODE_KP_5] = 0x4c, - [Q_KEY_CODE_KP_6] = 0x4d, - [Q_KEY_CODE_KP_7] = 0x47, - [Q_KEY_CODE_KP_8] = 0x48, - [Q_KEY_CODE_KP_9] = 0x49, - - [Q_KEY_CODE_LESS] = 0x56, - - [Q_KEY_CODE_F11] = 0x57, - [Q_KEY_CODE_F12] = 0x58, - - [Q_KEY_CODE_PRINT] = 0xb7, - - [Q_KEY_CODE_HOME] = 0xc7, - [Q_KEY_CODE_PGUP] = 0xc9, - [Q_KEY_CODE_PGDN] = 0xd1, - [Q_KEY_CODE_END] = 0xcf, - - [Q_KEY_CODE_LEFT] = 0xcb, - [Q_KEY_CODE_UP] = 0xc8, - [Q_KEY_CODE_DOWN] = 0xd0, - [Q_KEY_CODE_RIGHT] = 0xcd, - - [Q_KEY_CODE_INSERT] = 0xd2, - [Q_KEY_CODE_DELETE] = 0xd3, - - [Q_KEY_CODE_RO] = 0x73, - [Q_KEY_CODE_HIRAGANA] = 0x70, - [Q_KEY_CODE_HENKAN] = 0x79, - [Q_KEY_CODE_POWER] = 0xde, - [Q_KEY_CODE_YEN] = 0x7d, - [Q_KEY_CODE_KP_COMMA] = 0x7e, - - [Q_KEY_CODE_SLEEP] = 0xdf, - [Q_KEY_CODE_WAKE] = 0xe3, - [Q_KEY_CODE_CALCULATOR] = 0xa1, - [Q_KEY_CODE_MAIL] = 0xec, - [Q_KEY_CODE_COMPUTER] = 0xeb, - - [Q_KEY_CODE_STOP] = 0xe8, - [Q_KEY_CODE_AC_BOOKMARKS] = 0xe6, - [Q_KEY_CODE_AC_BACK] = 0xea, - [Q_KEY_CODE_AC_FORWARD] = 0xe9, - [Q_KEY_CODE_AC_HOME] = 0xb2, - [Q_KEY_CODE_AC_REFRESH] = 0xe7, - [Q_KEY_CODE_FIND] = 0xe5, - - [Q_KEY_CODE_AUDIONEXT] = 0x99, - [Q_KEY_CODE_AUDIOPREV] = 0x90, - [Q_KEY_CODE_AUDIOSTOP] = 0xa4, - [Q_KEY_CODE_AUDIOPLAY] = 0xa2, - [Q_KEY_CODE_AUDIOMUTE] = 0xa0, - [Q_KEY_CODE_VOLUMEDOWN] = 0xae, - [Q_KEY_CODE_VOLUMEUP] = 0xb0, - - [Q_KEY_CODE__MAX] = 0, -}; - -static int number_to_qcode[0x100]; +#include "ui/input-keymap-linux-to-qcode.c" +#include "ui/input-keymap-qcode-to-qnum.c" +#include "ui/input-keymap-qnum-to-qcode.c" int qemu_input_linux_to_qcode(unsigned int lnx) { - assert(lnx < KEY_CNT); - return linux_to_qcode[lnx]; + if (lnx >= qemu_input_map_linux_to_qcode_len) { + return 0; + } + return qemu_input_map_linux_to_qcode[lnx]; } int qemu_input_key_value_to_number(const KeyValue *value) { if (value->type == KEY_VALUE_KIND_QCODE) { - return qcode_to_number[value->u.qcode.data]; - } else { - assert(value->type == KEY_VALUE_KIND_NUMBER); - return value->u.number.data; - } -} - -int qemu_input_key_number_to_qcode(uint8_t nr) -{ - static int first = true; - - if (first) { - int qcode, number; - first = false; - for (qcode = 0; qcode < Q_KEY_CODE__MAX; qcode++) { - number = qcode_to_number[qcode]; - assert(number < ARRAY_SIZE(number_to_qcode)); - number_to_qcode[number] = qcode; + if (value->u.qcode.data >= qemu_input_map_qcode_to_qnum_len) { + return 0; } + return qemu_input_map_qcode_to_qnum[value->u.qcode.data]; + } else { + assert(value->type == KEY_VALUE_KIND_NUMBER); + return value->u.number.data; } +} - return number_to_qcode[nr]; +int qemu_input_key_number_to_qcode(unsigned int nr) +{ + if (nr >= qemu_input_map_qnum_to_qcode_len) { + return 0; + } + return qemu_input_map_qnum_to_qcode[nr]; } int qemu_input_key_value_to_qcode(const KeyValue *value) From patchwork Wed Oct 11 08:35:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 824282 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yBnQc1Kfnz9t3Z for ; Wed, 11 Oct 2017 19:36:56 +1100 (AEDT) Received: from localhost ([::1]:39147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CVa-0003xP-6M for incoming@patchwork.ozlabs.org; Wed, 11 Oct 2017 04:36:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CUu-0003vr-4R for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2CUs-0007kF-5s for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49798) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e2CUr-0007jB-UO for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:10 -0400 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 062B0356F6 for ; Wed, 11 Oct 2017 08:36:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 062B0356F6 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3D2519639; Wed, 11 Oct 2017 08:36:08 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id CF5674FD41; Wed, 11 Oct 2017 10:36:04 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 11 Oct 2017 10:35:59 +0200 Message-Id: <20171011083604.11820-6-kraxel@redhat.com> In-Reply-To: <20171011083604.11820-1-kraxel@redhat.com> References: <20171011083604.11820-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.30]); Wed, 11 Oct 2017 08:36:09 +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 05/10] ui: convert key events to QKeyCodes immediately 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Daniel P. Berrange" Always use QKeyCode in the InputKeyEvent struct, by converting key numbers to QKeyCode at the time the event is created. This allows the code processing / consuming key events to assume QKeyCode is used. The only place we accept a key number in the InputKeyEvent struct is with QMP commands sent by the user. Signed-off-by: Daniel P. Berrange Message-id: 20170929101201.21039-6-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- ui/input.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ui/input.c b/ui/input.c index 3422d4a8ef..4b241aa823 100644 --- a/ui/input.c +++ b/ui/input.c @@ -157,9 +157,16 @@ void qmp_input_send_event(bool has_device, const char *device, } for (e = events; e != NULL; e = e->next) { - InputEvent *event = e->value; + InputEvent *evt = e->value; - qemu_input_event_send(con, event); + if (evt->type == INPUT_EVENT_KIND_KEY && + evt->u.key.data->key->type == KEY_VALUE_KIND_NUMBER) { + KeyValue *key = evt->u.key.data->key; + QKeyCode code = qemu_input_key_number_to_qcode(key->u.qcode.data); + qemu_input_event_send_key_qcode(con, code, evt->u.key.data->down); + } else { + qemu_input_event_send(con, evt); + } } qemu_input_event_sync(); @@ -341,6 +348,11 @@ void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt) void qemu_input_event_send(QemuConsole *src, InputEvent *evt) { + /* Expect all parts of QEMU to send events with QCodes exclusively. + * Key numbers are only supported as end-user input via QMP */ + assert(!(evt->type == INPUT_EVENT_KIND_KEY && + evt->u.key.data->key->type == KEY_VALUE_KIND_NUMBER)); + if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { return; } @@ -400,10 +412,8 @@ void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down) void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down) { - KeyValue *key = g_new0(KeyValue, 1); - key->type = KEY_VALUE_KIND_NUMBER; - key->u.number.data = num; - qemu_input_event_send_key(src, key, down); + QKeyCode code = qemu_input_key_number_to_qcode(num); + qemu_input_event_send_key_qcode(src, code, down); } void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down) From patchwork Wed Oct 11 08:36:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 824291 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yBnTd4Y9mz9t3H for ; Wed, 11 Oct 2017 19:39:33 +1100 (AEDT) Received: from localhost ([::1]:39182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CY7-0006Wr-NS for incoming@patchwork.ozlabs.org; Wed, 11 Oct 2017 04:39:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CUv-0003wo-Gs for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2CUu-0007oE-8J for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54872) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e2CUu-0007mo-07 for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:12 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 159B0C04AC41 for ; Wed, 11 Oct 2017 08:36:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 159B0C04AC41 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4C9562929; Wed, 11 Oct 2017 08:36:08 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D739B4FD42; Wed, 11 Oct 2017 10:36:04 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 11 Oct 2017 10:36:00 +0200 Message-Id: <20171011083604.11820-7-kraxel@redhat.com> In-Reply-To: <20171011083604.11820-1-kraxel@redhat.com> References: <20171011083604.11820-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 11 Oct 2017 08:36:11 +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 06/10] ui: don't export qemu_input_event_new_key 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Daniel P. Berrange" All public code should use qemu_input_event_send_key* functions instead of creating an event directly. Signed-off-by: Daniel P. Berrange Message-id: 20170929101201.21039-7-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- include/ui/input.h | 1 - ui/input.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/ui/input.h b/include/ui/input.h index 479cc46cfc..f8cee43f65 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -38,7 +38,6 @@ void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt); void qemu_input_event_sync(void); void qemu_input_event_sync_impl(void); -InputEvent *qemu_input_event_new_key(KeyValue *key, bool down); void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down); void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down); void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down); diff --git a/ui/input.c b/ui/input.c index 4b241aa823..290b47354a 100644 --- a/ui/input.c +++ b/ui/input.c @@ -386,7 +386,7 @@ void qemu_input_event_sync(void) replay_input_sync_event(); } -InputEvent *qemu_input_event_new_key(KeyValue *key, bool down) +static InputEvent *qemu_input_event_new_key(KeyValue *key, bool down) { InputEvent *evt = g_new0(InputEvent, 1); evt->u.key.data = g_new0(InputKeyEvent, 1); From patchwork Wed Oct 11 08:36:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 824292 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yBnWp4W9jz9t3H for ; Wed, 11 Oct 2017 19:41:26 +1100 (AEDT) Received: from localhost ([::1]:39196 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CZw-00089m-Of for incoming@patchwork.ozlabs.org; Wed, 11 Oct 2017 04:41:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CV1-00043D-BL for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2CUu-0007pG-Tk for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34376) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e2CUu-0007nj-LS for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:12 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6E59A797 for ; Wed, 11 Oct 2017 08:36:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A6E59A797 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id A86EF5C66F; Wed, 11 Oct 2017 08:36:08 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E046A4FD43; Wed, 11 Oct 2017 10:36:04 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 11 Oct 2017 10:36:01 +0200 Message-Id: <20171011083604.11820-8-kraxel@redhat.com> In-Reply-To: <20171011083604.11820-1-kraxel@redhat.com> References: <20171011083604.11820-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 11 Oct 2017 08:36:11 +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 07/10] tools: add qemu-keymap 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" qemu-keymap generates qemu reverse keymaps from xkb keymaps, which can be used with the qemu "-k" command line switch. Signed-off-by: Gerd Hoffmann Message-id: 20171005153330.19210-2-kraxel@redhat.com --- configure | 23 ++++++ Makefile | 5 ++ qemu-keymap.c | 258 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 286 insertions(+) create mode 100644 qemu-keymap.c diff --git a/configure b/configure index 06f18ea9af..be53b6b104 100755 --- a/configure +++ b/configure @@ -304,6 +304,7 @@ vde="" vnc_sasl="" vnc_jpeg="" vnc_png="" +xkbcommon="" xen="" xen_ctrl_version="" xen_pv_domain_build="no" @@ -2908,6 +2909,21 @@ EOF fi ########################################## +# xkbcommon probe +if test "$xkbcommon" != "no" ; then + if $pkg_config xkbcommon --exists; then + xkbcommon_cflags=$($pkg_config xkbcommon --cflags) + xkbcommon_libs=$($pkg_config xkbcommon --libs) + xkbcommon=yes + else + if test "$xkbcommon" = "yes" ; then + feature_not_found "xkbcommon" "Install libxkbcommon-devel" + fi + xkbcommon=no + fi +fi + +########################################## # fnmatch() probe, used for ACL routines fnmatch="no" cat > $TMPC << EOF @@ -5107,6 +5123,9 @@ if test "$softmmu" = yes ; then mpath=no fi fi +if test "$xkbcommon" = "yes"; then + tools="qemu-keymap\$(EXESUF) $tools" +fi # Probe for guest agent support/options @@ -5606,6 +5625,10 @@ fi if test "$vnc_png" = "yes" ; then echo "CONFIG_VNC_PNG=y" >> $config_host_mak fi +if test "$xkbcommon" = "yes" ; then + echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak + echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak +fi if test "$fnmatch" = "yes" ; then echo "CONFIG_FNMATCH=y" >> $config_host_mak fi diff --git a/Makefile b/Makefile index f76b87472c..70235c0442 100644 --- a/Makefile +++ b/Makefile @@ -418,6 +418,8 @@ qemu-io$(EXESUF): qemu-io.o $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS) +qemu-keymap$(EXESUF): qemu-keymap.o ui/input-keymap.o $(COMMON_LDADDS) + fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS) fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap @@ -432,6 +434,9 @@ qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool qemu-ga$(EXESUF): LIBS = $(LIBS_QGA) qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated +qemu-keymap$(EXESUF): LIBS += $(XKBCOMMON_LIBS) +qemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS) + gen-out-type = $(subst .,-,$(suffix $@)) qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py diff --git a/qemu-keymap.c b/qemu-keymap.c new file mode 100644 index 0000000000..49e9167b86 --- /dev/null +++ b/qemu-keymap.c @@ -0,0 +1,258 @@ +/* + * QEMU keymap utility + * + * Copyright Red Hat, Inc. 2017 + * + * Authors: + * Gerd Hoffmann + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qapi-types.h" +#include "qemu/notify.h" +#include "ui/input.h" + +#include + +struct xkb_rule_names names = { + .rules = NULL, + .model = "pc105", + .layout = "us", + .variant = NULL, + .options = NULL, +}; + +static xkb_mod_mask_t shift; +static xkb_mod_mask_t ctrl; +static xkb_mod_mask_t altgr; +static xkb_mod_mask_t numlock; + +static FILE *outfile; + +/* ------------------------------------------------------------------------ */ + +static uint32_t qcode_to_number(uint32_t qcode) +{ + KeyValue keyvalue; + uint32_t number; + + keyvalue.type = KEY_VALUE_KIND_QCODE; + keyvalue.u.qcode.data = qcode; + number = qemu_input_key_value_to_number(&keyvalue); + assert(number != 0); + return number; +} + +static void print_sym(xkb_keysym_t sym, uint32_t qcode, const char *mod) +{ + char name[64]; + + if (sym == XKB_KEY_NoSymbol) { + return; + } + xkb_keysym_get_name(sym, name, sizeof(name)); + + /* TODO: make ui/keymap.c parser accept QKeyCode names */ + fprintf(outfile, "%s 0x%02x%s\n", name, qcode_to_number(qcode), mod); +} + +static void walk_map(struct xkb_keymap *map, xkb_keycode_t code, void *data) +{ + struct xkb_state *state = data; + xkb_keysym_t kbase, knumlock, kshift, kaltgr, kaltgrshift; + uint32_t evdev, qcode; + char name[64]; + + fprintf(outfile, "\n"); + + /* + * map xkb keycode -> QKeyCode + * + * xkb keycode is linux evdev shifted by 8 + */ + evdev = code - 8; + qcode = qemu_input_linux_to_qcode(evdev); + if (qcode == Q_KEY_CODE_UNMAPPED) { + xkb_state_update_mask(state, 0, 0, 0, 0, 0, 0); + kbase = xkb_state_key_get_one_sym(state, code); + xkb_keysym_get_name(kbase, name, sizeof(name)); + fprintf(outfile, "# evdev %d (0x%x): no evdev -> QKeyCode mapping" + " (xkb keysym %s)\n", evdev, evdev, name); + return; + } + fprintf(outfile, "# evdev %d (0x%x), QKeyCode \"%s\", number 0x%x\n", + evdev, evdev, + QKeyCode_lookup.array[qcode], + qcode_to_number(qcode)); + + /* + * check which modifier states generate which keysyms + */ + xkb_state_update_mask(state, 0, 0, 0, 0, 0, 0); + kbase = xkb_state_key_get_one_sym(state, code); + print_sym(kbase, qcode, ""); + + xkb_state_update_mask(state, 0, 0, numlock, 0, 0, 0); + knumlock = xkb_state_key_get_one_sym(state, code); + if (kbase != knumlock) { + print_sym(knumlock, qcode, " numlock"); + } + + xkb_state_update_mask(state, shift, 0, 0, 0, 0, 0); + kshift = xkb_state_key_get_one_sym(state, code); + if (kbase != kshift && knumlock != kshift) { + print_sym(kshift, qcode, " shift"); + } + + xkb_state_update_mask(state, altgr, 0, 0, 0, 0, 0); + kaltgr = xkb_state_key_get_one_sym(state, code); + if (kbase != kaltgr) { + print_sym(kaltgr, qcode, " altgr"); + } + + xkb_state_update_mask(state, altgr | shift, 0, 0, 0, 0, 0); + kaltgrshift = xkb_state_key_get_one_sym(state, code); + if (kshift != kaltgrshift && kaltgr != kaltgrshift) { + print_sym(kaltgrshift, qcode, " shift altgr"); + } + return; +} + +static void usage(FILE *out) +{ + fprintf(out, + "\n" + "This tool generates qemu reverse keymaps from xkb keymaps,\n" + "which can be used with the qemu \"-k\" command line switch.\n" + "\n" + "usage: qemu-keymap \n" + "options:\n" + " -h print this text\n" + " -f set output file (default: stdout)\n" + " -m set kbd model (default: %s)\n" + " -l set kbd layout (default: %s)\n" + " -v set kbd variant (default: %s)\n" + " -o set kbd options (default: %s)\n" + "\n", + names.model, names.layout, + names.variant ?: "-", + names.options ?: "-"); +} + +int main(int argc, char *argv[]) +{ + struct xkb_context *ctx; + struct xkb_keymap *map; + struct xkb_state *state; + xkb_mod_index_t mod, mods; + int rc; + + for (;;) { + rc = getopt(argc, argv, "hm:l:v:o:f:"); + if (rc == -1) { + break; + } + switch (rc) { + case 'm': + names.model = optarg; + break; + case 'l': + names.layout = optarg; + break; + case 'v': + names.variant = optarg; + break; + case 'o': + names.options = optarg; + break; + case 'f': + outfile = fopen(optarg, "w"); + if (outfile == NULL) { + fprintf(stderr, "open %s: %s\n", optarg, strerror(errno)); + exit(1); + } + break; + case 'h': + usage(stdout); + exit(0); + default: + usage(stderr); + exit(1); + } + } + + if (outfile == NULL) { + outfile = stdout; + } + + fprintf(outfile, + "#\n" + "# generated by qemu-keymap\n" + "# model : %s\n" + "# layout : %s\n" + "# variant : %s\n" + "# options : %s\n" + "\n", + names.model, names.layout, + names.variant ?: "-", + names.options ?: "-"); + + ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + map = xkb_keymap_new_from_names(ctx, &names, XKB_KEYMAP_COMPILE_NO_FLAGS); + if (!map) { + /* libxkbcommon prints error */ + exit(1); + } + + fprintf(outfile, "# name: \"%s\"\n\n", + xkb_keymap_layout_get_name(map, 0)); + fprintf(outfile, "# modifiers\n"); + mods = xkb_keymap_num_mods(map); + for (mod = 0; mod < mods; mod++) { + fprintf(outfile, "# %2d: %s\n", + mod, xkb_keymap_mod_get_name(map, mod)); + } + + mod = xkb_keymap_mod_get_index(map, "Shift"); + shift = (1 << mod); + mod = xkb_keymap_mod_get_index(map, "Control"); + ctrl = (1 << mod); + mod = xkb_keymap_mod_get_index(map, "AltGr"); + altgr = (1 << mod); + mod = xkb_keymap_mod_get_index(map, "NumLock"); + numlock = (1 << mod); + + state = xkb_state_new(map); + xkb_keymap_key_for_each(map, walk_map, state); + + /* add quirks */ + fprintf(outfile, + "\n" + "#\n" + "# quirks section start\n" + "#\n" + "# Sometimes multiple keysyms map to the same keycodes.\n" + "# The keycode -> keysym lookup finds only one of the\n" + "# keysyms. So append them here.\n" + "#\n" + "\n"); + print_sym(XKB_KEY_Print, Q_KEY_CODE_SYSRQ, ""); + print_sym(XKB_KEY_Sys_Req, Q_KEY_CODE_SYSRQ, ""); + print_sym(XKB_KEY_Execute, Q_KEY_CODE_SYSRQ, ""); + + print_sym(XKB_KEY_KP_Decimal, Q_KEY_CODE_KP_DECIMAL, " numlock"); + print_sym(XKB_KEY_KP_Separator, Q_KEY_CODE_KP_DECIMAL, " numlock"); + + print_sym(XKB_KEY_Alt_R, Q_KEY_CODE_ALT_R, ""); + print_sym(XKB_KEY_ISO_Level3_Shift, Q_KEY_CODE_ALT_R, ""); + print_sym(XKB_KEY_Mode_switch, Q_KEY_CODE_ALT_R, ""); + + fprintf(outfile, + "\n" + "# quirks section end\n"); + + exit(0); +} From patchwork Wed Oct 11 08:36:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 824284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yBnQd6fRcz9t4b for ; Wed, 11 Oct 2017 19:36:57 +1100 (AEDT) Received: from localhost ([::1]:39148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CVc-0003yD-19 for incoming@patchwork.ozlabs.org; Wed, 11 Oct 2017 04:36:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58470) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CUu-0003vt-5d for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2CUs-0007kP-8j for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e2CUs-0007jK-3r for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:10 -0400 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 2C2611299 for ; Wed, 11 Oct 2017 08:36:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2C2611299 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB61F17984; Wed, 11 Oct 2017 08:36:08 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E75D74FD44; Wed, 11 Oct 2017 10:36:04 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 11 Oct 2017 10:36:02 +0200 Message-Id: <20171011083604.11820-9-kraxel@redhat.com> In-Reply-To: <20171011083604.11820-1-kraxel@redhat.com> References: <20171011083604.11820-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.29]); Wed, 11 Oct 2017 08:36:09 +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 08/10] Add pc-bios/keymaps/Makefile 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Update files where I think I've figured the correct xkb maps. TODO: nl-be sl sv Signed-off-by: Gerd Hoffmann Message-id: 20171005153330.19210-3-kraxel@redhat.com --- pc-bios/keymaps/Makefile | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 pc-bios/keymaps/Makefile diff --git a/pc-bios/keymaps/Makefile b/pc-bios/keymaps/Makefile new file mode 100644 index 0000000000..f0e44fd110 --- /dev/null +++ b/pc-bios/keymaps/Makefile @@ -0,0 +1,56 @@ + +KEYMAP := $(shell which qemu-keymap 2>/dev/null) + +MAPS := ar bepo cz da de de-ch en-us en-gb es et fi fo \ + fr fr-be fr-ca fr-ch \ + hr hu is it ja lt lv mk nl no pl pt pt-br ru th tr + +ar : MAP_FLAGS := -l ar +bepo : MAP_FLAGS := -l fr -v dvorak +cz : MAP_FLAGS := -l cz +da : MAP_FLAGS := -l dk +de : MAP_FLAGS := -l de +de-ch : MAP_FLAGS := -l ch +en-us : MAP_FLAGS := -l us +en-gb : MAP_FLAGS := -l gb +es : MAP_FLAGS := -l es +et : MAP_FLAGS := -l et +fi : MAP_FLAGS := -l fi +fo : MAP_FLAGS := -l fo +fr : MAP_FLAGS := -l fr +fr-be : MAP_FLAGS := -l be +fr-ca : MAP_FLAGS := -l ca -v fr +fr-ch : MAP_FLAGS := -l ch -v fr +hr : MAP_FLAGS := -l hr +hu : MAP_FLAGS := -l hu +is : MAP_FLAGS := -l is +it : MAP_FLAGS := -l it +ja : MAP_FLAGS := -l jp -m jp106 +lt : MAP_FLAGS := -l lt +lv : MAP_FLAGS := -l lv +mk : MAP_FLAGS := -l mk +nl : MAP_FLAGS := -l nl +no : MAP_FLAGS := -l no +pl : MAP_FLAGS := -l pl +pt : MAP_FLAGS := -l pt +pt-br : MAP_FLAGS := -l br +ru : MAP_FLAGS := -l ru +th : MAP_FLAGS := -l th +tr : MAP_FLAGS := -l tr + +ifeq ($(KEYMAP),) + +all: + @echo "nothing to do (qemu-keymap not found)" + +else + +all: $(MAPS) + +clean: + rm -f $(MAPS) + +$(MAPS): $(KEYMAP) Makefile + $(KEYMAP) -f $@ $(MAP_FLAGS) + +endif From patchwork Wed Oct 11 08:36:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 824288 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yBnQw2XB7z9t3H for ; Wed, 11 Oct 2017 19:37:12 +1100 (AEDT) Received: from localhost ([::1]:39151 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CVq-0004Bj-9C for incoming@patchwork.ozlabs.org; Wed, 11 Oct 2017 04:37:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2CUv-0003wh-EE for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2CUu-0007oi-Iz for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54884) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e2CUu-0007nL-Ay for qemu-devel@nongnu.org; Wed, 11 Oct 2017 04:36:12 -0400 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 69E6BC04AC6A; Wed, 11 Oct 2017 08:36:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 69E6BC04AC6A Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B3A96BC0F; Wed, 11 Oct 2017 08:36:09 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 35A664FD46; Wed, 11 Oct 2017 10:36:05 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 11 Oct 2017 10:36:04 +0200 Message-Id: <20171011083604.11820-11-kraxel@redhat.com> In-Reply-To: <20171011083604.11820-1-kraxel@redhat.com> References: <20171011083604.11820-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]); Wed, 11 Oct 2017 08:36:11 +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 10/10] ui/gtk: Fix deprecation of vte_terminal_copy_clipboard 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: Anthony PERARD , Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Anthony PERARD vte_terminal_copy_clipboard() is deprecated in VTE 0.50. Signed-off-by: Anthony PERARD Reviewed-by: Daniel P. Berrange Signed-off-by: Gerd Hoffmann --- ui/gtk.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/gtk.c b/ui/gtk.c index 5bd87c265a..342e96fbe9 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1702,7 +1702,12 @@ static void gd_menu_copy(GtkMenuItem *item, void *opaque) GtkDisplayState *s = opaque; VirtualConsole *vc = gd_vc_find_current(s); +#if VTE_CHECK_VERSION(0, 50, 0) + vte_terminal_copy_clipboard_format(VTE_TERMINAL(vc->vte.terminal), + VTE_FORMAT_TEXT); +#else vte_terminal_copy_clipboard(VTE_TERMINAL(vc->vte.terminal)); +#endif } static void gd_vc_adjustment_changed(GtkAdjustment *adjustment, void *opaque)