From patchwork Tue Feb 5 10:57:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10797291 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EEADB13B4 for ; Tue, 5 Feb 2019 11:02:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DABAD2B3AB for ; Tue, 5 Feb 2019 11:02:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9D1E2B3CE; Tue, 5 Feb 2019 11:02:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 59A2B2B3AB for ; Tue, 5 Feb 2019 11:02:49 +0000 (UTC) Received: from localhost ([127.0.0.1]:58206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyV6-0002Ut-M9 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 06:02:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyQo-0007La-Ss for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqyQg-0006Bu-Ln for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44922) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqyQc-000671-Td for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:11 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6CE6A37E88; Tue, 5 Feb 2019 10:58:05 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84B7A100194A; Tue, 5 Feb 2019 10:57:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C4899A1E7; Tue, 5 Feb 2019 11:57:58 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:45 +0100 Message-Id: <20190205105758.4230-2-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 05 Feb 2019 10:58:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/14] Remove deprecated -no-frame option 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: libvir-list@redhat.com, Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Thomas Huth The -no-frame option has been deprecated with QEMU v2.12. It was only useful with SDL1.2 - now that we've removed support for SDL1.2, we can certainly remove the -no-frame option, too. Signed-off-by: Thomas Huth Message-id: 1549351769-19620-1-git-send-email-thuth@redhat.com Signed-off-by: Gerd Hoffmann --- include/sysemu/sysemu.h | 1 - vl.c | 23 +++-------------------- qemu-deprecated.texi | 6 ------ qemu-options.hx | 11 ----------- 4 files changed, 3 insertions(+), 38 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 85877b7e43..4b5a6b77f9 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -102,7 +102,6 @@ extern const char *keyboard_layout; extern int win2k_install_hack; extern int alt_grab; extern int ctrl_grab; -extern int no_frame; extern int smp_cpus; extern unsigned int max_cpus; extern int cursor_hide; diff --git a/vl.c b/vl.c index 9cf0fbe0b8..33d226fb48 100644 --- a/vl.c +++ b/vl.c @@ -160,7 +160,6 @@ static int rtc_host_datetime_offset = -1; /* valid & used only with QEMUClockType rtc_clock; int vga_interface_type = VGA_NONE; static DisplayOptions dpy; -int no_frame; static int num_serial_hds; static Chardev **serial_hds; Chardev *parallel_hds[MAX_PARALLEL_PORTS]; @@ -2113,18 +2112,7 @@ static void parse_display(const char *p) while (*opts) { const char *nextopt; - if (strstart(opts, ",frame=", &nextopt)) { - g_printerr("The frame= sdl option is deprecated, and will be\n" - "removed in a future release.\n"); - opts = nextopt; - if (strstart(opts, "on", &nextopt)) { - no_frame = 0; - } else if (strstart(opts, "off", &nextopt)) { - no_frame = 1; - } else { - goto invalid_sdl_args; - } - } else if (strstart(opts, ",alt_grab=", &nextopt)) { + if (strstart(opts, ",alt_grab=", &nextopt)) { opts = nextopt; if (strstart(opts, "on", &nextopt)) { alt_grab = 1; @@ -3596,11 +3584,6 @@ int main(int argc, char **argv, char **envp) dpy.has_full_screen = true; dpy.full_screen = true; break; - case QEMU_OPTION_no_frame: - g_printerr("The -no-frame switch is deprecated, and will be\n" - "removed in a future release.\n"); - no_frame = 1; - break; case QEMU_OPTION_alt_grab: alt_grab = 1; break; @@ -4279,8 +4262,8 @@ int main(int argc, char **argv, char **envp) dpy.type = DISPLAY_TYPE_NONE; } - if ((no_frame || alt_grab || ctrl_grab) && dpy.type != DISPLAY_TYPE_SDL) { - error_report("-no-frame, -alt-grab and -ctrl-grab are only valid " + if ((alt_grab || ctrl_grab) && dpy.type != DISPLAY_TYPE_SDL) { + error_report("-alt-grab and -ctrl-grab are only valid " "for SDL, ignoring option"); } if (dpy.has_window_close && diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index 9cc20b365c..0b508e738f 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -37,12 +37,6 @@ would automatically enable USB support on the machine type. If using the new syntax, USB support must be explicitly enabled via the ``-machine usb=on'' argument. -@subsection -no-frame (since 2.12.0) - -The @code{--no-frame} argument works with SDL 1.2 only. The other user -interfaces never implemented this in the first place. So this will be -removed together with SDL 1.2 support. - @subsection -virtioconsole (since 3.0.0) Option @option{-virtioconsole} has been replaced by diff --git a/qemu-options.hx b/qemu-options.hx index 521511ec13..0180467dee 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1294,17 +1294,6 @@ mode using a curses/ncurses interface. Nothing is displayed in graphical mode. ETEXI -DEF("no-frame", 0, QEMU_OPTION_no_frame, - "-no-frame open SDL window without a frame and window decorations\n", - QEMU_ARCH_ALL) -STEXI -@item -no-frame -@findex -no-frame -Do not use decorations for SDL windows and start them using the whole -available screen space. This makes the using QEMU in a dedicated desktop -workspace more convenient. -ETEXI - DEF("alt-grab", 0, QEMU_OPTION_alt_grab, "-alt-grab use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt)\n", QEMU_ARCH_ALL) From patchwork Tue Feb 5 10:57:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10797283 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00A5C14E1 for ; Tue, 5 Feb 2019 10:59:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3A752AB97 for ; Tue, 5 Feb 2019 10:59:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7EB62AB82; Tue, 5 Feb 2019 10:59:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 95B622AB82 for ; Tue, 5 Feb 2019 10:59:55 +0000 (UTC) Received: from localhost ([127.0.0.1]:58141 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqySI-0007Qd-PH for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 05:59:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyQs-0007P9-UZ for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqyQr-0006IW-4G for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34276) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqyQq-0006B2-RQ for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:25 -0500 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 CE4DFC058CB7; Tue, 5 Feb 2019 10:58:12 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BCAC5D6A6; Tue, 5 Feb 2019 10:57:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id CC8449D85; Tue, 5 Feb 2019 11:57:58 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:46 +0100 Message-Id: <20190205105758.4230-3-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-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.32]); Tue, 05 Feb 2019 10:58:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/14] ui: don't send any event if delta_y == 0 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: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann , Sergio Lopez , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sergio Lopez When the user raises their fingers from the touchpad, we may receive a GDK_SMOOTH_SCROLL event with delta_y == 0. Avoid generating a WHEEL_UP event in this situation. Signed-off-by: Sergio Lopez Message-id: 20190204122043.43007-1-slp@redhat.com Signed-off-by: Gerd Hoffmann --- ui/gtk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/gtk.c b/ui/gtk.c index 87c0e33d2a..5a584353bd 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1004,7 +1004,9 @@ static gboolean gd_scroll_event(GtkWidget *widget, GdkEventScroll *scroll, &delta_x, &delta_y)) { return TRUE; } - if (delta_y > 0) { + if (delta_y == 0) { + return TRUE; + } else if (delta_y > 0) { btn = INPUT_BUTTON_WHEEL_DOWN; } else { btn = INPUT_BUTTON_WHEEL_UP; From patchwork Tue Feb 5 10:57:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10797361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A85413B4 for ; Tue, 5 Feb 2019 11:08:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 485A22AC37 for ; Tue, 5 Feb 2019 11:08:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39D772B3E0; Tue, 5 Feb 2019 11:08:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3C0492AC37 for ; Tue, 5 Feb 2019 11:08:22 +0000 (UTC) Received: from localhost ([127.0.0.1]:58274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyaT-0005qW-B9 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 06:08:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyQq-0007N7-Ps for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqyQm-0006Fk-V4 for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35989) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqyQd-00068Q-Uf for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:12 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7EFFC057F8F; Tue, 5 Feb 2019 10:58:08 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86DA716906; Tue, 5 Feb 2019 10:57:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D47AA245; Tue, 5 Feb 2019 11:57:58 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:47 +0100 Message-Id: <20190205105758.4230-4-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-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.32]); Tue, 05 Feb 2019 10:58:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/14] ui: listen for GDK_SMOOTH_SCROLL events 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: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann , Sergio Lopez , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sergio Lopez On Wayland, without grabbing focus, two-finger scrolling generates GDK_SMOOTH_SCROLL events instead of GDK_SCROLL_*, so listen for them. Signed-off-by: Sergio Lopez Message-id: 20190204120823.41333-1-slp@redhat.com Signed-off-by: Gerd Hoffmann --- ui/gtk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/gtk.c b/ui/gtk.c index 5a584353bd..57af69b0c4 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -2045,6 +2045,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_SCROLL_MASK | + GDK_SMOOTH_SCROLL_MASK | GDK_KEY_PRESS_MASK); gtk_widget_set_can_focus(vc->gfx.drawing_area, TRUE); From patchwork Tue Feb 5 10:57:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10797311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E4BB313B4 for ; Tue, 5 Feb 2019 11:05:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D178D2B3DE for ; Tue, 5 Feb 2019 11:05:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C56D92AC37; Tue, 5 Feb 2019 11:05:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1A6B22AC37 for ; Tue, 5 Feb 2019 11:05:55 +0000 (UTC) Received: from localhost ([127.0.0.1]:58266 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyY6-0004xq-Bl for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 06:05:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyQo-0007LZ-So for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqyQg-0006Br-Lk for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34172) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqyQc-000672-Uo for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:11 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5DB3CC057F34; Tue, 5 Feb 2019 10:58:05 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F4CA1048125; Tue, 5 Feb 2019 10:57:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DCD9897BA; Tue, 5 Feb 2019 11:57:58 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:48 +0100 Message-Id: <20190205105758.4230-5-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 05 Feb 2019 10:58:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/14] ui/sdl_keysym: Remove obsolete SDL1.2 related code 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: libvir-list@redhat.com, Paolo Bonzini , Thomas Huth , Gerd Hoffmann , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Thomas Huth sdl_keysym.h has only been included by sdl.c which has recently been removed recently with this commit: 0015ca5cbabe0b31d31610ddfaafd90a9e5911a4 ("ui: remove support for SDL1.2 in favour of SDL2") So we can drop this header file now completely, too. Signed-off-by: Thomas Huth Reviewed-by: Daniel P. Berrangé Message-id: 1549282241-23535-1-git-send-email-thuth@redhat.com Signed-off-by: Gerd Hoffmann --- ui/sdl_keysym.h | 278 -------------------------------------------------------- 1 file changed, 278 deletions(-) delete mode 100644 ui/sdl_keysym.h diff --git a/ui/sdl_keysym.h b/ui/sdl_keysym.h deleted file mode 100644 index 599d9fc64d..0000000000 --- a/ui/sdl_keysym.h +++ /dev/null @@ -1,278 +0,0 @@ - -#include "keymaps.h" - -static const name2keysym_t name2keysym[]={ -/* ascii */ - { "space", 0x020}, - { "exclam", 0x021}, - { "quotedbl", 0x022}, - { "numbersign", 0x023}, - { "dollar", 0x024}, - { "percent", 0x025}, - { "ampersand", 0x026}, - { "apostrophe", 0x027}, - { "parenleft", 0x028}, - { "parenright", 0x029}, - { "asterisk", 0x02a}, - { "plus", 0x02b}, - { "comma", 0x02c}, - { "minus", 0x02d}, - { "period", 0x02e}, - { "slash", 0x02f}, - { "0", 0x030}, - { "1", 0x031}, - { "2", 0x032}, - { "3", 0x033}, - { "4", 0x034}, - { "5", 0x035}, - { "6", 0x036}, - { "7", 0x037}, - { "8", 0x038}, - { "9", 0x039}, - { "colon", 0x03a}, - { "semicolon", 0x03b}, - { "less", 0x03c}, - { "equal", 0x03d}, - { "greater", 0x03e}, - { "question", 0x03f}, - { "at", 0x040}, - { "A", 0x041}, - { "B", 0x042}, - { "C", 0x043}, - { "D", 0x044}, - { "E", 0x045}, - { "F", 0x046}, - { "G", 0x047}, - { "H", 0x048}, - { "I", 0x049}, - { "J", 0x04a}, - { "K", 0x04b}, - { "L", 0x04c}, - { "M", 0x04d}, - { "N", 0x04e}, - { "O", 0x04f}, - { "P", 0x050}, - { "Q", 0x051}, - { "R", 0x052}, - { "S", 0x053}, - { "T", 0x054}, - { "U", 0x055}, - { "V", 0x056}, - { "W", 0x057}, - { "X", 0x058}, - { "Y", 0x059}, - { "Z", 0x05a}, - { "bracketleft", 0x05b}, - { "backslash", 0x05c}, - { "bracketright", 0x05d}, - { "asciicircum", 0x05e}, - { "underscore", 0x05f}, - { "grave", 0x060}, - { "a", 0x061}, - { "b", 0x062}, - { "c", 0x063}, - { "d", 0x064}, - { "e", 0x065}, - { "f", 0x066}, - { "g", 0x067}, - { "h", 0x068}, - { "i", 0x069}, - { "j", 0x06a}, - { "k", 0x06b}, - { "l", 0x06c}, - { "m", 0x06d}, - { "n", 0x06e}, - { "o", 0x06f}, - { "p", 0x070}, - { "q", 0x071}, - { "r", 0x072}, - { "s", 0x073}, - { "t", 0x074}, - { "u", 0x075}, - { "v", 0x076}, - { "w", 0x077}, - { "x", 0x078}, - { "y", 0x079}, - { "z", 0x07a}, - { "braceleft", 0x07b}, - { "bar", 0x07c}, - { "braceright", 0x07d}, - { "asciitilde", 0x07e}, - -/* latin 1 extensions */ -{ "nobreakspace", 0x0a0}, -{ "exclamdown", 0x0a1}, -{ "cent", 0x0a2}, -{ "sterling", 0x0a3}, -{ "currency", 0x0a4}, -{ "yen", 0x0a5}, -{ "brokenbar", 0x0a6}, -{ "section", 0x0a7}, -{ "diaeresis", 0x0a8}, -{ "copyright", 0x0a9}, -{ "ordfeminine", 0x0aa}, -{ "guillemotleft", 0x0ab}, -{ "notsign", 0x0ac}, -{ "hyphen", 0x0ad}, -{ "registered", 0x0ae}, -{ "macron", 0x0af}, -{ "degree", 0x0b0}, -{ "plusminus", 0x0b1}, -{ "twosuperior", 0x0b2}, -{ "threesuperior", 0x0b3}, -{ "acute", 0x0b4}, -{ "mu", 0x0b5}, -{ "paragraph", 0x0b6}, -{ "periodcentered", 0x0b7}, -{ "cedilla", 0x0b8}, -{ "onesuperior", 0x0b9}, -{ "masculine", 0x0ba}, -{ "guillemotright", 0x0bb}, -{ "onequarter", 0x0bc}, -{ "onehalf", 0x0bd}, -{ "threequarters", 0x0be}, -{ "questiondown", 0x0bf}, -{ "Agrave", 0x0c0}, -{ "Aacute", 0x0c1}, -{ "Acircumflex", 0x0c2}, -{ "Atilde", 0x0c3}, -{ "Adiaeresis", 0x0c4}, -{ "Aring", 0x0c5}, -{ "AE", 0x0c6}, -{ "Ccedilla", 0x0c7}, -{ "Egrave", 0x0c8}, -{ "Eacute", 0x0c9}, -{ "Ecircumflex", 0x0ca}, -{ "Ediaeresis", 0x0cb}, -{ "Igrave", 0x0cc}, -{ "Iacute", 0x0cd}, -{ "Icircumflex", 0x0ce}, -{ "Idiaeresis", 0x0cf}, -{ "ETH", 0x0d0}, -{ "Eth", 0x0d0}, -{ "Ntilde", 0x0d1}, -{ "Ograve", 0x0d2}, -{ "Oacute", 0x0d3}, -{ "Ocircumflex", 0x0d4}, -{ "Otilde", 0x0d5}, -{ "Odiaeresis", 0x0d6}, -{ "multiply", 0x0d7}, -{ "Ooblique", 0x0d8}, -{ "Oslash", 0x0d8}, -{ "Ugrave", 0x0d9}, -{ "Uacute", 0x0da}, -{ "Ucircumflex", 0x0db}, -{ "Udiaeresis", 0x0dc}, -{ "Yacute", 0x0dd}, -{ "THORN", 0x0de}, -{ "Thorn", 0x0de}, -{ "ssharp", 0x0df}, -{ "agrave", 0x0e0}, -{ "aacute", 0x0e1}, -{ "acircumflex", 0x0e2}, -{ "atilde", 0x0e3}, -{ "adiaeresis", 0x0e4}, -{ "aring", 0x0e5}, -{ "ae", 0x0e6}, -{ "ccedilla", 0x0e7}, -{ "egrave", 0x0e8}, -{ "eacute", 0x0e9}, -{ "ecircumflex", 0x0ea}, -{ "ediaeresis", 0x0eb}, -{ "igrave", 0x0ec}, -{ "iacute", 0x0ed}, -{ "icircumflex", 0x0ee}, -{ "idiaeresis", 0x0ef}, -{ "eth", 0x0f0}, -{ "ntilde", 0x0f1}, -{ "ograve", 0x0f2}, -{ "oacute", 0x0f3}, -{ "ocircumflex", 0x0f4}, -{ "otilde", 0x0f5}, -{ "odiaeresis", 0x0f6}, -{ "division", 0x0f7}, -{ "oslash", 0x0f8}, -{ "ooblique", 0x0f8}, -{ "ugrave", 0x0f9}, -{ "uacute", 0x0fa}, -{ "ucircumflex", 0x0fb}, -{ "udiaeresis", 0x0fc}, -{ "yacute", 0x0fd}, -{ "thorn", 0x0fe}, -{ "ydiaeresis", 0x0ff}, -#if SDL_MAJOR_VERSION == 1 -{"EuroSign", SDLK_EURO}, - - /* modifiers */ -{"Control_L", SDLK_LCTRL}, -{"Control_R", SDLK_RCTRL}, -{"Alt_L", SDLK_LALT}, -{"Alt_R", SDLK_RALT}, -{"Caps_Lock", SDLK_CAPSLOCK}, -{"Meta_L", SDLK_LMETA}, -{"Meta_R", SDLK_RMETA}, -{"Shift_L", SDLK_LSHIFT}, -{"Shift_R", SDLK_RSHIFT}, -{"Super_L", SDLK_LSUPER}, -{"Super_R", SDLK_RSUPER}, - - /* special keys */ -{"BackSpace", SDLK_BACKSPACE}, -{"Tab", SDLK_TAB}, -{"Return", SDLK_RETURN}, -{"Right", SDLK_RIGHT}, -{"Left", SDLK_LEFT}, -{"Up", SDLK_UP}, -{"Down", SDLK_DOWN}, -{"Page_Down", SDLK_PAGEDOWN}, -{"Page_Up", SDLK_PAGEUP}, -{"Insert", SDLK_INSERT}, -{"Delete", SDLK_DELETE}, -{"Home", SDLK_HOME}, -{"End", SDLK_END}, -{"Scroll_Lock", SDLK_SCROLLOCK}, -{"F1", SDLK_F1}, -{"F2", SDLK_F2}, -{"F3", SDLK_F3}, -{"F4", SDLK_F4}, -{"F5", SDLK_F5}, -{"F6", SDLK_F6}, -{"F7", SDLK_F7}, -{"F8", SDLK_F8}, -{"F9", SDLK_F9}, -{"F10", SDLK_F10}, -{"F11", SDLK_F11}, -{"F12", SDLK_F12}, -{"F13", SDLK_F13}, -{"F14", SDLK_F14}, -{"F15", SDLK_F15}, -{"Sys_Req", SDLK_SYSREQ}, -{"KP_0", SDLK_KP0}, -{"KP_1", SDLK_KP1}, -{"KP_2", SDLK_KP2}, -{"KP_3", SDLK_KP3}, -{"KP_4", SDLK_KP4}, -{"KP_5", SDLK_KP5}, -{"KP_6", SDLK_KP6}, -{"KP_7", SDLK_KP7}, -{"KP_8", SDLK_KP8}, -{"KP_9", SDLK_KP9}, -{"KP_Add", SDLK_KP_PLUS}, -{"KP_Decimal", SDLK_KP_PERIOD}, -{"KP_Divide", SDLK_KP_DIVIDE}, -{"KP_Enter", SDLK_KP_ENTER}, -{"KP_Equal", SDLK_KP_EQUALS}, -{"KP_Multiply", SDLK_KP_MULTIPLY}, -{"KP_Subtract", SDLK_KP_MINUS}, -{"help", SDLK_HELP}, -{"Menu", SDLK_MENU}, -{"Power", SDLK_POWER}, -{"Print", SDLK_PRINT}, -{"Mode_switch", SDLK_MODE}, -{"Multi_Key", SDLK_COMPOSE}, -{"Num_Lock", SDLK_NUMLOCK}, -{"Pause", SDLK_PAUSE}, -{"Escape", SDLK_ESCAPE}, -#endif -{NULL, 0}, -}; From patchwork Tue Feb 5 10:57:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10797313 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7B8676C2 for ; Tue, 5 Feb 2019 11:06:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69BDF2AC37 for ; Tue, 5 Feb 2019 11:06:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BDA12B3E0; Tue, 5 Feb 2019 11:06:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E71852AC37 for ; Tue, 5 Feb 2019 11:06:04 +0000 (UTC) Received: from localhost ([127.0.0.1]:58220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyYG-0003qY-6p for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 06:06:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyQs-0007P8-UW for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqyQq-0006I4-Sh for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58834) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqyQo-00067X-ST for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:24 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92C3387620; Tue, 5 Feb 2019 10:58:06 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05CE71048116; Tue, 5 Feb 2019 10:58:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E4C9197BC; Tue, 5 Feb 2019 11:57:58 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:49 +0100 Message-Id: <20190205105758.4230-6-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 05 Feb 2019 10:58:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/14] ui/cocoa.m: Fix macOS 10.14 deprecation warnings 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: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann , Brendan Shanks , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Brendan Shanks macOS 10.14 deprecated NSOnState/NSOffState in favour of NSControlStateValueOn/NSControlStateValueOff. Use the new constants, and #define them to the old ones when compiling against a pre-10.13 SDK. Also [NSGraphicsContext graphicsPort] is now deprecated, use [NSGraphicsContext CGContext] when available. Signed-off-by: Brendan Shanks Message-id: 20190201071225.20576-1-brendan@bslabs.net Signed-off-by: Gerd Hoffmann --- ui/cocoa.m | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index ddc058e76e..e2567d6946 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -54,6 +54,9 @@ #ifndef MAC_OS_X_VERSION_10_12 #define MAC_OS_X_VERSION_10_12 101200 #endif +#ifndef MAC_OS_X_VERSION_10_13 +#define MAC_OS_X_VERSION_10_13 101300 +#endif /* macOS 10.12 deprecated many constants, #define the new names for older SDKs */ #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 @@ -90,6 +93,14 @@ #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9 #define NSModalResponseOK NSFileHandlingPanelOKButton #endif +/* 10.14 deprecates NSOnState and NSOffState in favor of + * NSControlStateValueOn/Off, which were introduced in 10.13. + * Define for older versions + */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13 +#define NSControlStateValueOn NSOnState +#define NSControlStateValueOff NSOffState +#endif //#define DEBUG @@ -377,7 +388,12 @@ QemuCocoaView *cocoaView; COCOA_DEBUG("QemuCocoaView: drawRect\n"); // get CoreGraphic context +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10 CGContextRef viewContextRef = [[NSGraphicsContext currentContext] graphicsPort]; +#else + CGContextRef viewContextRef = [[NSGraphicsContext currentContext] CGContext]; +#endif + CGContextSetInterpolationQuality (viewContextRef, kCGInterpolationNone); CGContextSetShouldAntialias (viewContextRef, NO); @@ -1147,9 +1163,9 @@ QemuCocoaView *cocoaView; { stretch_video = !stretch_video; if (stretch_video == true) { - [sender setState: NSOnState]; + [sender setState: NSControlStateValueOn]; } else { - [sender setState: NSOffState]; + [sender setState: NSControlStateValueOff]; } } @@ -1390,15 +1406,15 @@ QemuCocoaView *cocoaView; { /* Unselect the currently selected item */ for (NSMenuItem *item in [menu itemArray]) { - if (item.state == NSOnState) { - [item setState: NSOffState]; + if (item.state == NSControlStateValueOn) { + [item setState: NSControlStateValueOff]; break; } } } // check the menu item - [sender setState: NSOnState]; + [sender setState: NSControlStateValueOn]; // get the throttle percentage throttle_pct = [sender tag]; @@ -1502,7 +1518,7 @@ int main (int argc, const char * argv[]) { initWithTitle: [NSString stringWithFormat: @"%d%%", percentage] action:@selector(adjustSpeed:) keyEquivalent:@""] autorelease]; if (percentage == 100) { - [menuItem setState: NSOnState]; + [menuItem setState: NSControlStateValueOn]; } /* Calculate the throttle percentage */ From patchwork Tue Feb 5 10:57:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10797287 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB75713B4 for ; Tue, 5 Feb 2019 11:00:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8F092B307 for ; Tue, 5 Feb 2019 11:00:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA7B22B388; Tue, 5 Feb 2019 11:00:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4FB962B307 for ; Tue, 5 Feb 2019 11:00:21 +0000 (UTC) Received: from localhost ([127.0.0.1]:58183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqySi-0000hw-Ho for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 06:00:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyQq-0007N5-Pf for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqyQm-0006Fl-Ux for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39015) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqyQd-00067V-4T for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:12 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F205C05B03C; Tue, 5 Feb 2019 10:58:06 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAF48183D6; Tue, 5 Feb 2019 10:58:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id F1E6697BE; Tue, 5 Feb 2019 11:57:58 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:50 +0100 Message-Id: <20190205105758.4230-7-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-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.31]); Tue, 05 Feb 2019 10:58:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/14] ui/egl-helpers: Augment parameter list of egl_texture_blend() to convey scales of viewport 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: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann , Chen Zhang , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Chen Zhang This would help gtk-egl display showing scaled DMABuf cursor images when gtk window was zoomed. A default scale of (1.0, 1.0) was presumed for call sites where no scaling is needed. Signed-off-by: Chen Zhang Message-id: 23B229B3-3095-4DFB-8369-866784808D30@me.com Signed-off-by: Gerd Hoffmann --- include/ui/egl-helpers.h | 2 +- ui/egl-headless.c | 3 ++- ui/egl-helpers.c | 9 +++++---- ui/gtk-egl.c | 3 ++- ui/spice-display.c | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index 3fc656a7ba..b976cb8728 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -27,7 +27,7 @@ void egl_fb_read(void *dst, egl_fb *src); void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip); void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip, - int x, int y); + int x, int y, double scale_x, double scale_y); #ifdef CONFIG_OPENGL_DMABUF diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 519e7bad32..e67b47aeff 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -142,7 +142,8 @@ static void egl_scanout_flush(DisplayChangeListener *dcl, egl_texture_blit(edpy->gls, &edpy->blit_fb, &edpy->guest_fb, !edpy->y_0_top); egl_texture_blend(edpy->gls, &edpy->blit_fb, &edpy->cursor_fb, - !edpy->y_0_top, edpy->pos_x, edpy->pos_y); + !edpy->y_0_top, edpy->pos_x, edpy->pos_y, + 1.0, 1.0); } else { /* no cursor -> use simple framebuffer blit */ egl_fb_blit(&edpy->blit_fb, &edpy->guest_fb, edpy->y_0_top); diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 5e115b3fb4..e90eef8c9c 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -120,14 +120,15 @@ void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip) } void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip, - int x, int y) + int x, int y, double scale_x, double scale_y) { glBindFramebuffer(GL_FRAMEBUFFER_EXT, dst->framebuffer); + int w = scale_x * src->width; + int h = scale_y * src->height; if (flip) { - glViewport(x, y, src->width, src->height); + glViewport(x, y, w, h); } else { - glViewport(x, dst->height - src->height - y, - src->width, src->height); + glViewport(x, dst->height - h - y, w, h); } glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, src->texture); diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index afd17148c0..42801b688b 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -278,7 +278,8 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl, vc->gfx.y0_top); egl_texture_blend(vc->gfx.gls, &vc->gfx.win_fb, &vc->gfx.cursor_fb, vc->gfx.y0_top, - vc->gfx.cursor_x, vc->gfx.cursor_y); + vc->gfx.cursor_x, vc->gfx.cursor_y, + vc->gfx.scale_x, vc->gfx.scale_y); } else { egl_fb_blit(&vc->gfx.win_fb, &vc->gfx.guest_fb, !vc->gfx.y0_top); } diff --git a/ui/spice-display.c b/ui/spice-display.c index 52f8cb5ae1..aea6f6ebce 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -1090,7 +1090,7 @@ static void qemu_spice_gl_update(DisplayChangeListener *dcl, egl_texture_blit(ssd->gls, &ssd->blit_fb, &ssd->guest_fb, !y_0_top); egl_texture_blend(ssd->gls, &ssd->blit_fb, &ssd->cursor_fb, - !y_0_top, x, y); + !y_0_top, x, y, 1.0, 1.0); glFlush(); } From patchwork Tue Feb 5 10:57:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10797295 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A259013B4 for ; Tue, 5 Feb 2019 11:03:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E3252B3AB for ; Tue, 5 Feb 2019 11:03:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FE112B3CE; Tue, 5 Feb 2019 11:03:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CEF292B3AB for ; Tue, 5 Feb 2019 11:03:07 +0000 (UTC) Received: from localhost ([127.0.0.1]:58200 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyVP-0001YT-3p for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 06:03:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyQz-0007Vz-KE for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqyQw-0006Mh-6S for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37678) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqyQt-0006Ba-9H for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:28 -0500 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 1016AC01DE03; Tue, 5 Feb 2019 10:58:14 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14E936A530; Tue, 5 Feb 2019 10:58:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 08A54960F; Tue, 5 Feb 2019 11:57:59 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:51 +0100 Message-Id: <20190205105758.4230-8-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-1-kraxel@redhat.com> MIME-Version: 1.0 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.31]); Tue, 05 Feb 2019 10:58:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/14] kbd-state: add keyboard state tracker 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: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Now that most user interfaces are using QKeyCodes it is easier to have common keyboard code useable by all user interfaces. This patch adds helper code to track the state of all keyboard keys, using a bitmap indexed by QKeyCode. Modifier state is tracked too, as separate bitmap. That makes checking modifier state easier. Likewise we can easily apply special handling for capslock & numlock (toggles on keypress) and ctrl + shift (we have two keys for that). Signed-off-by: Gerd Hoffmann Message-id: 20190122092814.14919-2-kraxel@redhat.com [ kraxel: added license boilerplate header ] Reviewed-by: Daniel P. Berrangé --- include/ui/kbd-state.h | 101 ++++++++++++++++++++++++++++++++++++++ ui/kbd-state.c | 130 +++++++++++++++++++++++++++++++++++++++++++++++++ ui/Makefile.objs | 2 +- 3 files changed, 232 insertions(+), 1 deletion(-) create mode 100644 include/ui/kbd-state.h create mode 100644 ui/kbd-state.c diff --git a/include/ui/kbd-state.h b/include/ui/kbd-state.h new file mode 100644 index 0000000000..d87833553a --- /dev/null +++ b/include/ui/kbd-state.h @@ -0,0 +1,101 @@ +/* + * This work is licensed under the terms of the GNU GPL, version 2 or + * (at your option) any later version. See the COPYING file in the + * top-level directory. + */ +#ifndef QEMU_UI_KBD_STATE_H +#define QEMU_UI_KBD_STATE_H 1 + +#include "qapi/qapi-types-ui.h" + +typedef enum QKbdModifier QKbdModifier; + +enum QKbdModifier { + QKBD_MOD_NONE = 0, + + QKBD_MOD_SHIFT, + QKBD_MOD_CTRL, + QKBD_MOD_ALT, + QKBD_MOD_ALTGR, + + QKBD_MOD_NUMLOCK, + QKBD_MOD_CAPSLOCK, + + QKBD_MOD__MAX +}; + +typedef struct QKbdState QKbdState; + +/** + * qkbd_state_init: init keyboard state tracker. + * + * Allocates and initializes keyboard state struct. + * + * @con: QemuConsole for this state tracker. Gets passed down to + * qemu_input_*() functions when sending key events to the guest. + */ +QKbdState *qkbd_state_init(QemuConsole *con); + +/** + * qkbd_state_free: free keyboard tracker state. + * + * @kbd: state tracker state. + */ +void qkbd_state_free(QKbdState *kbd); + +/** + * qkbd_state_key_event: process key event. + * + * Update keyboard state, send event to the guest. + * + * This function takes care to not send suspious events (keyup event + * for a key not pressed for example). + * + * @kbd: state tracker state. + * @qcode: the key pressed or released. + * @down: true for key down events, false otherwise. + */ +void qkbd_state_key_event(QKbdState *kbd, QKeyCode qcode, bool down); + +/** + * qkbd_state_set_delay: set key press delay. + * + * When set the specified delay will be added after each key event, + * using qemu_input_event_send_key_delay(). + * + * @kbd: state tracker state. + * @delay_ms: the delay in miliseconds. + */ +void qkbd_state_set_delay(QKbdState *kbd, int delay_ms); + +/** + * qkbd_state_key_get: get key state. + * + * Returns true when the key is down. + * + * @kbd: state tracker state. + * @qcode: the key to query. + */ +bool qkbd_state_key_get(QKbdState *kbd, QKeyCode qcode); + +/** + * qkbd_state_modifier_get: get modifier state. + * + * Returns true when the modifier is active. + * + * @kbd: state tracker state. + * @mod: the modifier to query. + */ +bool qkbd_state_modifier_get(QKbdState *kbd, QKbdModifier mod); + +/** + * qkbd_state_lift_all_keys: lift all pressed keys. + * + * This sends key up events to the guest for all keys which are in + * down state. + * + * @kbd: state tracker state. + */ +void qkbd_state_lift_all_keys(QKbdState *kbd); + +#endif /* QEMU_UI_KBD_STATE_H */ diff --git a/ui/kbd-state.c b/ui/kbd-state.c new file mode 100644 index 0000000000..ac14add70e --- /dev/null +++ b/ui/kbd-state.c @@ -0,0 +1,130 @@ +/* + * This work is licensed under the terms of the GNU GPL, version 2 or + * (at your option) any later version. See the COPYING file in the + * top-level directory. + */ +#include "qemu/osdep.h" +#include "qemu/bitmap.h" +#include "qemu/queue.h" +#include "ui/console.h" +#include "ui/input.h" +#include "ui/kbd-state.h" + +struct QKbdState { + QemuConsole *con; + int key_delay_ms; + DECLARE_BITMAP(keys, Q_KEY_CODE__MAX); + DECLARE_BITMAP(mods, QKBD_MOD__MAX); +}; + +static void qkbd_state_modifier_update(QKbdState *kbd, + QKeyCode qcode1, QKeyCode qcode2, + QKbdModifier mod) +{ + if (test_bit(qcode1, kbd->keys) || test_bit(qcode2, kbd->keys)) { + set_bit(mod, kbd->mods); + } else { + clear_bit(mod, kbd->mods); + } +} + +bool qkbd_state_modifier_get(QKbdState *kbd, QKbdModifier mod) +{ + return test_bit(mod, kbd->mods); +} + +bool qkbd_state_key_get(QKbdState *kbd, QKeyCode qcode) +{ + return test_bit(qcode, kbd->keys); +} + +void qkbd_state_key_event(QKbdState *kbd, QKeyCode qcode, bool down) +{ + bool state = test_bit(qcode, kbd->keys); + + if (state == down) { + /* + * Filter out events which don't change the keyboard state. + * + * Most notably this allows to simply send along all key-up + * events, and this function will filter out everything where + * the corresponding key-down event wasn't send to the guest, + * for example due to being a host hotkey. + */ + return; + } + + /* update key and modifier state */ + change_bit(qcode, kbd->keys); + switch (qcode) { + case Q_KEY_CODE_SHIFT: + case Q_KEY_CODE_SHIFT_R: + qkbd_state_modifier_update(kbd, Q_KEY_CODE_SHIFT, Q_KEY_CODE_SHIFT_R, + QKBD_MOD_SHIFT); + break; + case Q_KEY_CODE_CTRL: + case Q_KEY_CODE_CTRL_R: + qkbd_state_modifier_update(kbd, Q_KEY_CODE_CTRL, Q_KEY_CODE_CTRL_R, + QKBD_MOD_CTRL); + break; + case Q_KEY_CODE_ALT: + qkbd_state_modifier_update(kbd, Q_KEY_CODE_ALT, Q_KEY_CODE_ALT, + QKBD_MOD_ALT); + break; + case Q_KEY_CODE_ALT_R: + qkbd_state_modifier_update(kbd, Q_KEY_CODE_ALT_R, Q_KEY_CODE_ALT_R, + QKBD_MOD_ALTGR); + break; + case Q_KEY_CODE_CAPS_LOCK: + if (down) { + change_bit(QKBD_MOD_CAPSLOCK, kbd->mods); + } + break; + case Q_KEY_CODE_NUM_LOCK: + if (down) { + change_bit(QKBD_MOD_NUMLOCK, kbd->mods); + } + break; + default: + /* keep gcc happy */ + break; + } + + /* send to guest */ + if (qemu_console_is_graphic(kbd->con)) { + qemu_input_event_send_key_qcode(kbd->con, qcode, down); + if (kbd->key_delay_ms) { + qemu_input_event_send_key_delay(kbd->key_delay_ms); + } + } +} + +void qkbd_state_lift_all_keys(QKbdState *kbd) +{ + int qcode; + + for (qcode = 0; qcode < Q_KEY_CODE__MAX; qcode++) { + if (test_bit(qcode, kbd->keys)) { + qkbd_state_key_event(kbd, qcode, false); + } + } +} + +void qkbd_state_set_delay(QKbdState *kbd, int delay_ms) +{ + kbd->key_delay_ms = delay_ms; +} + +void qkbd_state_free(QKbdState *kbd) +{ + g_free(kbd); +} + +QKbdState *qkbd_state_init(QemuConsole *con) +{ + QKbdState *kbd = g_new0(QKbdState, 1); + + kbd->con = con; + + return kbd; +} diff --git a/ui/Makefile.objs b/ui/Makefile.objs index 9b6f0c6b67..7f8b3da791 100644 --- a/ui/Makefile.objs +++ b/ui/Makefile.objs @@ -8,7 +8,7 @@ vnc-obj-y += vnc-ws.o vnc-obj-y += vnc-jobs.o common-obj-y += keymaps.o console.o cursor.o qemu-pixman.o -common-obj-y += input.o input-keymap.o input-legacy.o +common-obj-y += input.o input-keymap.o input-legacy.o kbd-state.o common-obj-$(CONFIG_LINUX) += input-linux.o common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o common-obj-$(CONFIG_COCOA) += cocoa.o From patchwork Tue Feb 5 10:57:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10797367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1BC6C6C2 for ; Tue, 5 Feb 2019 11:10:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08C262AC68 for ; Tue, 5 Feb 2019 11:10:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F15862AC77; Tue, 5 Feb 2019 11:10:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9A65D2AC68 for ; Tue, 5 Feb 2019 11:10:29 +0000 (UTC) Received: from localhost ([127.0.0.1]:58292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqycW-0007jo-Uk for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 06:10:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyQv-0007Ri-AP for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqyQt-0006L8-BQ for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36308) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqyQs-00067N-Ro for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:27 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6E0FD81F0D; Tue, 5 Feb 2019 10:58:06 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1683D5FCA0; Tue, 5 Feb 2019 10:58:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 11D6093E8; Tue, 5 Feb 2019 11:57:59 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:52 +0100 Message-Id: <20190205105758.4230-9-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-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.27]); Tue, 05 Feb 2019 10:58:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/14] sdl2: remove sdl2_reset_keys() function 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: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP No users left, dead code. Signed-off-by: Gerd Hoffmann Message-id: 20190122092814.14919-3-kraxel@redhat.com --- include/ui/sdl2.h | 1 - ui/sdl2-input.c | 16 ---------------- 2 files changed, 17 deletions(-) diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h index f6db642b65..71f5cfc6e3 100644 --- a/include/ui/sdl2.h +++ b/include/ui/sdl2.h @@ -44,7 +44,6 @@ void sdl2_window_destroy(struct sdl2_console *scon); void sdl2_window_resize(struct sdl2_console *scon); void sdl2_poll_events(struct sdl2_console *scon); -void sdl2_reset_keys(struct sdl2_console *scon); void sdl2_process_key(struct sdl2_console *scon, SDL_KeyboardEvent *ev); diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c index 1378b63dd9..208266c6a5 100644 --- a/ui/sdl2-input.c +++ b/ui/sdl2-input.c @@ -32,22 +32,6 @@ static uint8_t modifiers_state[SDL_NUM_SCANCODES]; -void sdl2_reset_keys(struct sdl2_console *scon) -{ - QemuConsole *con = scon ? scon->dcl.con : NULL; - int i; - - for (i = 0 ; - i < SDL_NUM_SCANCODES && i < qemu_input_map_usb_to_qcode_len ; - i++) { - if (modifiers_state[i]) { - int qcode = qemu_input_map_usb_to_qcode[i]; - qemu_input_event_send_key_qcode(con, qcode, false); - modifiers_state[i] = 0; - } - } -} - void sdl2_process_key(struct sdl2_console *scon, SDL_KeyboardEvent *ev) { From patchwork Tue Feb 5 10:57:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10797315 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 88D6613B4 for ; Tue, 5 Feb 2019 11:06:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76EC22AC37 for ; Tue, 5 Feb 2019 11:06:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B4012B403; Tue, 5 Feb 2019 11:06:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 02E082AC37 for ; Tue, 5 Feb 2019 11:06:30 +0000 (UTC) Received: from localhost ([127.0.0.1]:58241 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyYf-0004Mg-AY for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 06:06:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyQw-0007Sr-HQ for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqyQv-0006Lv-08 for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54710) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqyQt-00067Z-8t for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:28 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B81E181DF3; Tue, 5 Feb 2019 10:58:06 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20E901048125; Tue, 5 Feb 2019 10:58:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1D2D38FA0; Tue, 5 Feb 2019 11:57:59 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:53 +0100 Message-Id: <20190205105758.4230-10-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 05 Feb 2019 10:58:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/14] kbd-state: use state tracker for sdl2 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: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use the new keyboard state tracked for sdl2. We can drop the modifier state tracking from sdl2. Also keyup code is simpler, the state tracker will take care to not send suspious keyup events to the guest. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrangé Message-id: 20190122092814.14919-4-kraxel@redhat.com --- include/ui/sdl2.h | 2 ++ ui/sdl2-input.c | 27 ++------------------------- ui/sdl2.c | 12 +++--------- 3 files changed, 7 insertions(+), 34 deletions(-) diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h index 71f5cfc6e3..0875b8d56b 100644 --- a/include/ui/sdl2.h +++ b/include/ui/sdl2.h @@ -10,6 +10,7 @@ # include #endif +#include "ui/kbd-state.h" #ifdef CONFIG_OPENGL # include "ui/egl-helpers.h" #endif @@ -30,6 +31,7 @@ struct sdl2_console { int idle_counter; int ignore_hotkeys; SDL_GLContext winctx; + QKbdState *kbd; #ifdef CONFIG_OPENGL QemuGLShader *gls; egl_fb guest_fb; diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c index 208266c6a5..22e3336aab 100644 --- a/ui/sdl2-input.c +++ b/ui/sdl2-input.c @@ -30,8 +30,6 @@ #include "ui/sdl2.h" #include "sysemu/sysemu.h" -static uint8_t modifiers_state[SDL_NUM_SCANCODES]; - void sdl2_process_key(struct sdl2_console *scon, SDL_KeyboardEvent *ev) { @@ -43,31 +41,10 @@ void sdl2_process_key(struct sdl2_console *scon, } qcode = qemu_input_map_usb_to_qcode[ev->keysym.scancode]; - - /* modifier state tracking */ - switch (ev->keysym.scancode) { - case SDL_SCANCODE_LCTRL: - case SDL_SCANCODE_LSHIFT: - case SDL_SCANCODE_LALT: - case SDL_SCANCODE_LGUI: - case SDL_SCANCODE_RCTRL: - case SDL_SCANCODE_RSHIFT: - case SDL_SCANCODE_RALT: - case SDL_SCANCODE_RGUI: - if (ev->type == SDL_KEYUP) { - modifiers_state[ev->keysym.scancode] = 0; - } else { - modifiers_state[ev->keysym.scancode] = 1; - } - break; - default: - /* nothing */ - break; - } + qkbd_state_key_event(scon->kbd, qcode, ev->type == SDL_KEYDOWN); if (!qemu_console_is_graphic(con)) { - bool ctrl = (modifiers_state[SDL_SCANCODE_LCTRL] || - modifiers_state[SDL_SCANCODE_RCTRL]); + bool ctrl = qkbd_state_modifier_get(scon->kbd, QKBD_MOD_CTRL); if (ev->type == SDL_KEYDOWN) { switch (ev->keysym.scancode) { case SDL_SCANCODE_RETURN: diff --git a/ui/sdl2.c b/ui/sdl2.c index cde7feba91..1277cf28fb 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -38,7 +38,6 @@ static int gui_grab; /* if true, all keyboard/mouse events are grabbed */ static int gui_saved_grab; static int gui_fullscreen; -static int gui_keysym; static int gui_grab_code = KMOD_LALT | KMOD_LCTRL; static SDL_Cursor *sdl_cursor_normal; static SDL_Cursor *sdl_cursor_hidden; @@ -330,6 +329,7 @@ static void handle_keydown(SDL_Event *ev) int win; struct sdl2_console *scon = get_scon_from_window(ev->key.windowID); int gui_key_modifier_pressed = get_mod_state(); + int gui_keysym = 0; if (!scon->ignore_hotkeys && gui_key_modifier_pressed && !ev->key.repeat) { switch (ev->key.keysym.scancode) { @@ -410,16 +410,9 @@ static void handle_keydown(SDL_Event *ev) static void handle_keyup(SDL_Event *ev) { struct sdl2_console *scon = get_scon_from_window(ev->key.windowID); - int gui_key_modifier_pressed = get_mod_state(); scon->ignore_hotkeys = false; - - if (!gui_key_modifier_pressed) { - gui_keysym = 0; - } - if (!gui_keysym) { - sdl2_process_key(scon, &ev->key); - } + sdl2_process_key(scon, &ev->key); } static void handle_textinput(SDL_Event *ev) @@ -823,6 +816,7 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o) sdl2_console[i].dcl.ops = &dcl_2d_ops; #endif sdl2_console[i].dcl.con = con; + sdl2_console[i].kbd = qkbd_state_init(con); register_displaychangelistener(&sdl2_console[i].dcl); #if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_X11) From patchwork Tue Feb 5 10:57:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10797365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE1A06C2 for ; Tue, 5 Feb 2019 11:08:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA2D62A823 for ; Tue, 5 Feb 2019 11:08:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B94E22A87D; Tue, 5 Feb 2019 11:08:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 663AD2A823 for ; Tue, 5 Feb 2019 11:08:54 +0000 (UTC) Received: from localhost ([127.0.0.1]:58288 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyaz-00077L-M4 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 06:08:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyQz-0007Vy-KF for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqyQt-0006L2-B0 for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20563) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqyQs-0006BK-QP for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:26 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6586EC05D3E6; Tue, 5 Feb 2019 10:58:13 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D4FE17CEE; Tue, 5 Feb 2019 10:58:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 254357849; Tue, 5 Feb 2019 11:57:59 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:54 +0100 Message-Id: <20190205105758.4230-11-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 05 Feb 2019 10:58:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/14] sdl2: use only QKeyCode in sdl2_process_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: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Also: sdl2_process_key is never called with scon == NULL. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrangé Message-id: 20190122092814.14919-5-kraxel@redhat.com --- ui/sdl2-input.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c index 22e3336aab..664364a5e5 100644 --- a/ui/sdl2-input.c +++ b/ui/sdl2-input.c @@ -34,20 +34,19 @@ void sdl2_process_key(struct sdl2_console *scon, SDL_KeyboardEvent *ev) { int qcode; - QemuConsole *con = scon ? scon->dcl.con : NULL; + QemuConsole *con = scon->dcl.con; if (ev->keysym.scancode >= qemu_input_map_usb_to_qcode_len) { return; } - qcode = qemu_input_map_usb_to_qcode[ev->keysym.scancode]; qkbd_state_key_event(scon->kbd, qcode, ev->type == SDL_KEYDOWN); if (!qemu_console_is_graphic(con)) { bool ctrl = qkbd_state_modifier_get(scon->kbd, QKBD_MOD_CTRL); if (ev->type == SDL_KEYDOWN) { - switch (ev->keysym.scancode) { - case SDL_SCANCODE_RETURN: + switch (qcode) { + case Q_KEY_CODE_RET: kbd_put_keysym_console(con, '\n'); break; default: From patchwork Tue Feb 5 10:57:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10797285 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 577BC17FB for ; Tue, 5 Feb 2019 10:59:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 461502AB82 for ; Tue, 5 Feb 2019 10:59:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 374F42AB97; Tue, 5 Feb 2019 10:59:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C6DF72AB9B for ; Tue, 5 Feb 2019 10:59:55 +0000 (UTC) Received: from localhost ([127.0.0.1]:58139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqySJ-0007Pr-2j for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 05:59:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyQq-0007N9-RV for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqyQo-0006Gg-Ny for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42486) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqyQe-00067n-Ou for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:16 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5371359444; Tue, 5 Feb 2019 10:58:07 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDA67183DE; Tue, 5 Feb 2019 10:58:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2E8D87850; Tue, 5 Feb 2019 11:57:59 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:55 +0100 Message-Id: <20190205105758.4230-12-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 05 Feb 2019 10:58:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/14] kbd-state: use state tracker for gtk 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: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use the new keyboard state tracked for gtk. Allows to drop the gtk-specific modifier state tracking code. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrangé Message-id: 20190122092814.14919-6-kraxel@redhat.com --- include/ui/gtk.h | 2 ++ ui/gtk.c | 38 ++++++-------------------------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index 99edd3c085..d9eedad976 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -22,6 +22,7 @@ #include #endif +#include "ui/kbd-state.h" #if defined(CONFIG_OPENGL) #include "ui/egl-helpers.h" #include "ui/egl-context.h" @@ -32,6 +33,7 @@ typedef struct GtkDisplayState GtkDisplayState; typedef struct VirtualGfxConsole { GtkWidget *drawing_area; DisplayChangeListener dcl; + QKbdState *kbd; DisplaySurface *ds; pixman_image_t *convert; cairo_surface_t *surface; diff --git a/ui/gtk.c b/ui/gtk.c index 57af69b0c4..949b143e4e 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -122,17 +122,6 @@ #define HOTKEY_MODIFIERS (GDK_CONTROL_MASK | GDK_MOD1_MASK) -static const int modifier_keycode[] = { - Q_KEY_CODE_SHIFT, - Q_KEY_CODE_SHIFT_R, - Q_KEY_CODE_CTRL, - Q_KEY_CODE_CTRL_R, - Q_KEY_CODE_ALT, - Q_KEY_CODE_ALT_R, - Q_KEY_CODE_META_L, - Q_KEY_CODE_META_R, -}; - static const guint16 *keycode_map; static size_t keycode_maplen; @@ -187,7 +176,6 @@ struct GtkDisplayState { bool external_pause_update; - bool modifier_pressed[ARRAY_SIZE(modifier_keycode)]; bool ignore_keys; DisplayOptions *opts; @@ -426,20 +414,12 @@ static void gd_update_full_redraw(VirtualConsole *vc) static void gtk_release_modifiers(GtkDisplayState *s) { VirtualConsole *vc = gd_vc_find_current(s); - int i, qcode; if (vc->type != GD_VC_GFX || !qemu_console_is_graphic(vc->gfx.dcl.con)) { return; } - for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) { - qcode = modifier_keycode[i]; - if (!s->modifier_pressed[i]) { - continue; - } - qemu_input_event_send_key_qcode(vc->gfx.dcl.con, qcode, false); - s->modifier_pressed[i] = false; - } + qkbd_state_lift_all_keys(vc->gfx.kbd); } static void gd_widget_reparent(GtkWidget *from, GtkWidget *to, @@ -1115,7 +1095,6 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) VirtualConsole *vc = opaque; GtkDisplayState *s = vc->s; int qcode; - int i; if (s->ignore_keys) { s->ignore_keys = (key->type == GDK_KEY_PRESS); @@ -1136,8 +1115,8 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) || key->hardware_keycode == VK_PAUSE #endif ) { - qemu_input_event_send_key_qcode(vc->gfx.dcl.con, Q_KEY_CODE_PAUSE, - key->type == GDK_KEY_PRESS); + qkbd_state_key_event(vc->gfx.kbd, Q_KEY_CODE_PAUSE, + key->type == GDK_KEY_PRESS); return TRUE; } @@ -1146,14 +1125,8 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) trace_gd_key_event(vc->label, key->hardware_keycode, qcode, (key->type == GDK_KEY_PRESS) ? "down" : "up"); - for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) { - if (qcode == modifier_keycode[i]) { - s->modifier_pressed[i] = (key->type == GDK_KEY_PRESS); - } - } - - qemu_input_event_send_key_qcode(vc->gfx.dcl.con, qcode, - key->type == GDK_KEY_PRESS); + qkbd_state_key_event(vc->gfx.kbd, qcode, + key->type == GDK_KEY_PRESS); return TRUE; } @@ -2055,6 +2028,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc, gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), vc->tab_item, gtk_label_new(vc->label)); + vc->gfx.kbd = qkbd_state_init(con); vc->gfx.dcl.con = con; register_displaychangelistener(&vc->gfx.dcl); From patchwork Tue Feb 5 10:57:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10797297 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1ED914E1 for ; Tue, 5 Feb 2019 11:03:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADD492B3AB for ; Tue, 5 Feb 2019 11:03:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0F092B3CE; Tue, 5 Feb 2019 11:03:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 892BE2B3AB for ; Tue, 5 Feb 2019 11:03:36 +0000 (UTC) Received: from localhost ([127.0.0.1]:58212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyVr-00033Q-Px for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 06:03:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyQs-0007P4-Tr for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqyQr-0006IN-2U for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60426) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqyQq-0006BI-NT for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:24 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6C1303DBD2; Tue, 5 Feb 2019 10:58:13 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A93760BEE; Tue, 5 Feb 2019 10:58:07 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 38AB17851; Tue, 5 Feb 2019 11:57:59 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:56 +0100 Message-Id: <20190205105758.4230-13-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-1-kraxel@redhat.com> MIME-Version: 1.0 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.30]); Tue, 05 Feb 2019 10:58:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 12/14] kbd-state: use state tracker for vnc 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: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use the new keyboard state tracked for vnc. Allows to drop the vnc-specific modifier state tracking code. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrangé Message-id: 20190122092814.14919-7-kraxel@redhat.com --- ui/vnc.h | 5 ++- ui/vnc.c | 120 ++++++++++++++++++--------------------------------------------- 2 files changed, 35 insertions(+), 90 deletions(-) diff --git a/ui/vnc.h b/ui/vnc.h index a86e0610e8..81daa7a0eb 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -44,6 +44,7 @@ #include "keymaps.h" #include "vnc-palette.h" #include "vnc-enc-zrle.h" +#include "ui/kbd-state.h" // #define _VNC_DEBUG 1 @@ -155,7 +156,7 @@ struct VncDisplay int lock_key_sync; QEMUPutLEDEntry *led; int ledstate; - int key_delay_ms; + QKbdState *kbd; QemuMutex mutex; QEMUCursor *cursor; @@ -326,8 +327,6 @@ struct VncState VncReadEvent *read_handler; size_t read_handler_expect; - /* input */ - uint8_t modifiers_state[256]; bool abort; QemuMutex output_mutex; diff --git a/ui/vnc.c b/ui/vnc.c index 6002d09407..8e52b999b8 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -59,7 +59,6 @@ static QTAILQ_HEAD(, VncDisplay) vnc_displays = QTAILQ_HEAD_INITIALIZER(vnc_displays); static int vnc_cursor_define(VncState *vs); -static void vnc_release_modifiers(VncState *vs); static void vnc_update_throttle_offset(VncState *vs); static void vnc_set_share_mode(VncState *vs, VncShareMode mode) @@ -1267,7 +1266,7 @@ void vnc_disconnect_finish(VncState *vs) vnc_sasl_client_cleanup(vs); #endif /* CONFIG_VNC_SASL */ audio_del(vs); - vnc_release_modifiers(vs); + qkbd_state_lift_all_keys(vs->vd->kbd); if (vs->mouse_mode_notifier.notify != NULL) { qemu_remove_mouse_mode_change_notifier(&vs->mouse_mode_notifier); @@ -1756,26 +1755,10 @@ static void pointer_event(VncState *vs, int button_mask, int x, int y) qemu_input_event_sync(); } -static void reset_keys(VncState *vs) +static void press_key(VncState *vs, QKeyCode qcode) { - int i; - for(i = 0; i < 256; i++) { - if (vs->modifiers_state[i]) { - qemu_input_event_send_key_number(vs->vd->dcl.con, i, false); - qemu_input_event_send_key_delay(vs->vd->key_delay_ms); - vs->modifiers_state[i] = 0; - } - } -} - -static void press_key(VncState *vs, int keysym) -{ - int keycode = 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); - qemu_input_event_send_key_delay(vs->vd->key_delay_ms); + qkbd_state_key_event(vs->vd->kbd, qcode, true); + qkbd_state_key_event(vs->vd->kbd, qcode, false); } static void vnc_led_state_change(VncState *vs) @@ -1816,32 +1799,20 @@ static void kbd_leds(void *opaque, int ledstate) static void do_key_event(VncState *vs, int down, int keycode, int sym) { + QKeyCode qcode = qemu_input_key_number_to_qcode(keycode); + /* QEMU console switch */ - switch(keycode) { - case 0x2a: /* Left Shift */ - case 0x36: /* Right Shift */ - case 0x1d: /* Left CTRL */ - case 0x9d: /* Right CTRL */ - case 0x38: /* Left ALT */ - case 0xb8: /* Right ALT */ - if (down) - vs->modifiers_state[keycode] = 1; - else - vs->modifiers_state[keycode] = 0; - break; - case 0x02 ... 0x0a: /* '1' to '9' keys */ - if (vs->vd->dcl.con == NULL && - down && vs->modifiers_state[0x1d] && vs->modifiers_state[0x38]) { + switch (qcode) { + case Q_KEY_CODE_1 ... Q_KEY_CODE_9: /* '1' to '9' keys */ + if (vs->vd->dcl.con == NULL && down && + qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_CTRL) && + qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_ALT)) { /* Reset the modifiers sent to the current console */ - reset_keys(vs); - console_select(keycode - 0x02); + qkbd_state_lift_all_keys(vs->vd->kbd); + console_select(qcode - Q_KEY_CODE_1); return; } - break; - case 0x3a: /* CapsLock */ - case 0x45: /* NumLock */ - if (down) - vs->modifiers_state[keycode] ^= 1; + default: break; } @@ -1856,16 +1827,14 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) toggles numlock away from the VNC window. */ if (keysym_is_numlock(vs->vd->kbd_layout, sym & 0xFFFF)) { - if (!vs->modifiers_state[0x45]) { + if (!qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_NUMLOCK)) { trace_vnc_key_sync_numlock(true); - vs->modifiers_state[0x45] = 1; - press_key(vs, 0xff7f); + press_key(vs, Q_KEY_CODE_NUM_LOCK); } } else { - if (vs->modifiers_state[0x45]) { + if (qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_NUMLOCK)) { trace_vnc_key_sync_numlock(false); - vs->modifiers_state[0x45] = 0; - press_key(vs, 0xff7f); + press_key(vs, Q_KEY_CODE_NUM_LOCK); } } } @@ -1878,30 +1847,25 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) toggles capslock away from the VNC window. */ int uppercase = !!(sym >= 'A' && sym <= 'Z'); - int shift = !!(vs->modifiers_state[0x2a] | vs->modifiers_state[0x36]); - int capslock = !!(vs->modifiers_state[0x3a]); + bool shift = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_SHIFT); + bool capslock = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_CAPSLOCK); if (capslock) { if (uppercase == shift) { trace_vnc_key_sync_capslock(false); - vs->modifiers_state[0x3a] = 0; - press_key(vs, 0xffe5); + press_key(vs, Q_KEY_CODE_CAPS_LOCK); } } else { if (uppercase != shift) { trace_vnc_key_sync_capslock(true); - vs->modifiers_state[0x3a] = 1; - press_key(vs, 0xffe5); + press_key(vs, Q_KEY_CODE_CAPS_LOCK); } } } - if (qemu_console_is_graphic(NULL)) { - qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, down); - qemu_input_event_send_key_delay(vs->vd->key_delay_ms); - } else { - bool numlock = vs->modifiers_state[0x45]; - bool control = (vs->modifiers_state[0x1d] || - vs->modifiers_state[0x9d]); + qkbd_state_key_event(vs->vd->kbd, qcode, down); + if (!qemu_console_is_graphic(NULL)) { + bool numlock = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_NUMLOCK); + bool control = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_CTRL); /* QEMU console emulation */ if (down) { switch (keycode) { @@ -2002,27 +1966,6 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) } } -static void vnc_release_modifiers(VncState *vs) -{ - static const int keycodes[] = { - /* shift, control, alt keys, both left & right */ - 0x2a, 0x36, 0x1d, 0x9d, 0x38, 0xb8, - }; - int i, keycode; - - if (!qemu_console_is_graphic(NULL)) { - return; - } - for (i = 0; i < ARRAY_SIZE(keycodes); i++) { - keycode = keycodes[i]; - if (!vs->modifiers_state[keycode]) { - continue; - } - qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, false); - qemu_input_event_send_key_delay(vs->vd->key_delay_ms); - } -} - static const char *code2name(int keycode) { return QKeyCode_str(qemu_input_key_number_to_qcode(keycode)); @@ -2030,9 +1973,9 @@ static const char *code2name(int keycode) static void key_event(VncState *vs, int down, uint32_t sym) { - bool shift = vs->modifiers_state[0x2a] || vs->modifiers_state[0x36]; - bool altgr = vs->modifiers_state[0xb8]; - bool ctrl = vs->modifiers_state[0x1d] || vs->modifiers_state[0x9d]; + bool shift = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_SHIFT); + bool altgr = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_ALTGR); + bool ctrl = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_CTRL); int keycode; int lsym = sym; @@ -3259,6 +3202,7 @@ void vnc_display_init(const char *id, Error **errp) vd->dcl.ops = &dcl_ops; register_displaychangelistener(&vd->dcl); + vd->kbd = qkbd_state_init(vd->dcl.con); } @@ -3995,7 +3939,6 @@ void vnc_display_open(const char *id, Error **errp) vd->led = qemu_add_led_event_handler(kbd_leds, vd); } vd->ledstate = 0; - vd->key_delay_ms = key_delay_ms; device_id = qemu_opt_get(opts, "display"); if (device_id) { @@ -4012,10 +3955,13 @@ void vnc_display_open(const char *id, Error **errp) } if (con != vd->dcl.con) { + qkbd_state_free(vd->kbd); unregister_displaychangelistener(&vd->dcl); vd->dcl.con = con; register_displaychangelistener(&vd->dcl); + vd->kbd = qkbd_state_init(vd->dcl.con); } + qkbd_state_set_delay(vd->kbd, key_delay_ms); if (saddr == NULL) { goto cleanup; From patchwork Tue Feb 5 10:57:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10797281 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE2601669 for ; Tue, 5 Feb 2019 10:59:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA78D2AB7A for ; Tue, 5 Feb 2019 10:59:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EB442AB82; Tue, 5 Feb 2019 10:59:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 37F6E2AB7A for ; Tue, 5 Feb 2019 10:59:41 +0000 (UTC) Received: from localhost ([127.0.0.1]:58137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyS4-0007Ka-Df for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 05:59:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyQl-0007Ie-2H for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqyQd-00069z-5J for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36326) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqyQb-00067p-2a for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:10 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62D25811D5; Tue, 5 Feb 2019 10:58:07 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id D432867155; Tue, 5 Feb 2019 10:58:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 447097852; Tue, 5 Feb 2019 11:57:59 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:57 +0100 Message-Id: <20190205105758.4230-14-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 05 Feb 2019 10:58:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 13/14] keymap: pass full keyboard state to keysym2scancode 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: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Pass the keyboard state tracker handle down to keysym2scancode(), so the code can fully inspect the keyboard state as needed. No functional change. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrangé Message-id: 20190122092814.14919-8-kraxel@redhat.com --- ui/keymaps.h | 3 ++- ui/curses.c | 2 +- ui/keymaps.c | 8 ++++---- ui/vnc.c | 5 +---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ui/keymaps.h b/ui/keymaps.h index 4e9c87fb8f..d8652b8a5a 100644 --- a/ui/keymaps.h +++ b/ui/keymaps.h @@ -26,6 +26,7 @@ #define QEMU_KEYMAPS_H #include "qemu-common.h" +#include "ui/kbd-state.h" typedef struct { const char* name; @@ -55,7 +56,7 @@ typedef struct kbd_layout_t kbd_layout_t; kbd_layout_t *init_keyboard_layout(const name2keysym_t *table, const char *language, Error **errp); int keysym2scancode(kbd_layout_t *k, int keysym, - bool shift, bool altgr, bool ctrl); + QKbdState *kbd); int keycode_is_keypad(kbd_layout_t *k, int keycode); int keysym_is_numlock(kbd_layout_t *k, int keysym); diff --git a/ui/curses.c b/ui/curses.c index f4e7a12f74..54687589d4 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -273,7 +273,7 @@ static void curses_refresh(DisplayChangeListener *dcl) } keycode = keysym2scancode(kbd_layout, keysym & KEYSYM_MASK, - false, false, false); + NULL); if (keycode == 0) continue; diff --git a/ui/keymaps.c b/ui/keymaps.c index 6e44f738ed..c8b2135340 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -188,7 +188,7 @@ kbd_layout_t *init_keyboard_layout(const name2keysym_t *table, int keysym2scancode(kbd_layout_t *k, int keysym, - bool shift, bool altgr, bool ctrl) + QKbdState *kbd) { static const uint32_t mask = SCANCODE_SHIFT | SCANCODE_ALTGR | SCANCODE_CTRL; @@ -220,13 +220,13 @@ int keysym2scancode(kbd_layout_t *k, int keysym, * If so, prefer that one. */ mods = 0; - if (shift) { + if (kbd && qkbd_state_modifier_get(kbd, QKBD_MOD_SHIFT)) { mods |= SCANCODE_SHIFT; } - if (altgr) { + if (kbd && qkbd_state_modifier_get(kbd, QKBD_MOD_ALTGR)) { mods |= SCANCODE_ALTGR; } - if (ctrl) { + if (kbd && qkbd_state_modifier_get(kbd, QKBD_MOD_CTRL)) { mods |= SCANCODE_CTRL; } diff --git a/ui/vnc.c b/ui/vnc.c index 8e52b999b8..f66ed53094 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1973,9 +1973,6 @@ static const char *code2name(int keycode) static void key_event(VncState *vs, int down, uint32_t sym) { - bool shift = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_SHIFT); - bool altgr = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_ALTGR); - bool ctrl = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_CTRL); int keycode; int lsym = sym; @@ -1984,7 +1981,7 @@ static void key_event(VncState *vs, int down, uint32_t sym) } keycode = keysym2scancode(vs->vd->kbd_layout, lsym & 0xFFFF, - shift, altgr, ctrl) & SCANCODE_KEYMASK; + vs->vd->kbd) & SCANCODE_KEYMASK; trace_vnc_key_event_map(down, sym, keycode, code2name(keycode)); do_key_event(vs, down, keycode, sym); } From patchwork Tue Feb 5 10:57:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10797363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7B5B13B4 for ; Tue, 5 Feb 2019 11:08:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9674C2AC37 for ; Tue, 5 Feb 2019 11:08:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 894422B3E0; Tue, 5 Feb 2019 11:08:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 066EB2AC37 for ; Tue, 5 Feb 2019 11:08:29 +0000 (UTC) Received: from localhost ([127.0.0.1]:58278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyaa-0005wt-7t for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Feb 2019 06:08:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqyQz-0007Vx-K7 for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqyQw-0006Mq-6d for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58868) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqyQt-000685-9v for qemu-devel@nongnu.org; Tue, 05 Feb 2019 05:58:28 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D2AF985A07; Tue, 5 Feb 2019 10:58:07 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45C721055009; Tue, 5 Feb 2019 10:58:07 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 511A07853; Tue, 5 Feb 2019 11:57:59 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:58 +0100 Message-Id: <20190205105758.4230-15-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 05 Feb 2019 10:58:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 14/14] keymap: fix keyup 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: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP It is possible that the modifier state on keyup is different from the modifier state on keydown. In that case the keycode lookup can end up with different keys in case multiple keysym -> keycode mappings exist, because it picks the mapping depending on modifier state. To fix that change the lookup logic for keyup events. Instead of looking at the modifier state check the key state and prefer a keycodes where the key is in "down" state right now. Fixes: abb4f2c965 keymap: consider modifier state when picking a mapping Buglink: https://bugs.launchpad.net/bugs/1738283 Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1658676 Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrangé Message-id: 20190122092814.14919-9-kraxel@redhat.com --- ui/keymaps.h | 2 +- ui/curses.c | 2 +- ui/keymaps.c | 55 ++++++++++++++++++++++++++++++++++--------------------- ui/vnc.c | 2 +- 4 files changed, 37 insertions(+), 24 deletions(-) diff --git a/ui/keymaps.h b/ui/keymaps.h index d8652b8a5a..b6d48aac40 100644 --- a/ui/keymaps.h +++ b/ui/keymaps.h @@ -56,7 +56,7 @@ typedef struct kbd_layout_t kbd_layout_t; kbd_layout_t *init_keyboard_layout(const name2keysym_t *table, const char *language, Error **errp); int keysym2scancode(kbd_layout_t *k, int keysym, - QKbdState *kbd); + QKbdState *kbd, bool down); int keycode_is_keypad(kbd_layout_t *k, int keycode); int keysym_is_numlock(kbd_layout_t *k, int keysym); diff --git a/ui/curses.c b/ui/curses.c index 54687589d4..6e0091c3b2 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -273,7 +273,7 @@ static void curses_refresh(DisplayChangeListener *dcl) } keycode = keysym2scancode(kbd_layout, keysym & KEYSYM_MASK, - NULL); + NULL, false); if (keycode == 0) continue; diff --git a/ui/keymaps.c b/ui/keymaps.c index c8b2135340..544b55c27b 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -28,6 +28,7 @@ #include "trace.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "ui/input.h" struct keysym2code { uint32_t count; @@ -188,7 +189,7 @@ kbd_layout_t *init_keyboard_layout(const name2keysym_t *table, int keysym2scancode(kbd_layout_t *k, int keysym, - QKbdState *kbd) + QKbdState *kbd, bool down) { static const uint32_t mask = SCANCODE_SHIFT | SCANCODE_ALTGR | SCANCODE_CTRL; @@ -212,27 +213,39 @@ int keysym2scancode(kbd_layout_t *k, int keysym, 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 = 0; - if (kbd && qkbd_state_modifier_get(kbd, QKBD_MOD_SHIFT)) { - mods |= SCANCODE_SHIFT; - } - if (kbd && qkbd_state_modifier_get(kbd, QKBD_MOD_ALTGR)) { - mods |= SCANCODE_ALTGR; - } - if (kbd && qkbd_state_modifier_get(kbd, QKBD_MOD_CTRL)) { - mods |= SCANCODE_CTRL; - } + /* We have multiple keysym -> keycode mappings. */ + if (down) { + /* + * On keydown: 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 = 0; + if (kbd && qkbd_state_modifier_get(kbd, QKBD_MOD_SHIFT)) { + mods |= SCANCODE_SHIFT; + } + if (kbd && qkbd_state_modifier_get(kbd, QKBD_MOD_ALTGR)) { + mods |= SCANCODE_ALTGR; + } + if (kbd && qkbd_state_modifier_get(kbd, QKBD_MOD_CTRL)) { + mods |= SCANCODE_CTRL; + } - for (i = 0; i < keysym2code->count; i++) { - if ((keysym2code->keycodes[i] & mask) == mods) { - return keysym2code->keycodes[i]; + for (i = 0; i < keysym2code->count; i++) { + if ((keysym2code->keycodes[i] & mask) == mods) { + return keysym2code->keycodes[i]; + } + } + } else { + /* + * On keyup: Try find a key which is actually down. + */ + for (i = 0; i < keysym2code->count; i++) { + QKeyCode qcode = qemu_input_key_number_to_qcode + (keysym2code->keycodes[i]); + if (kbd && qkbd_state_key_get(kbd, qcode)) { + return keysym2code->keycodes[i]; + } } } return keysym2code->keycodes[0]; diff --git a/ui/vnc.c b/ui/vnc.c index f66ed53094..0fef646fc4 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1981,7 +1981,7 @@ static void key_event(VncState *vs, int down, uint32_t sym) } keycode = keysym2scancode(vs->vd->kbd_layout, lsym & 0xFFFF, - vs->vd->kbd) & SCANCODE_KEYMASK; + vs->vd->kbd, down) & SCANCODE_KEYMASK; trace_vnc_key_event_map(down, sym, keycode, code2name(keycode)); do_key_event(vs, down, keycode, sym); }