From patchwork Sun May 10 18:42:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 283051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 846F1C54E8B for ; Sun, 10 May 2020 18:44:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 617972082E for ; Sun, 10 May 2020 18:44:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 617972082E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXqvx-0000Yg-Ia for qemu-devel@archiver.kernel.org; Sun, 10 May 2020 14:44:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXquu-0007gh-Jk for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:12 -0400 Received: from mailout08.t-online.de ([194.25.134.20]:45010) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqut-0005Kn-SL for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:12 -0400 Received: from fwd10.aul.t-online.de (fwd10.aul.t-online.de [172.20.26.152]) by mailout08.t-online.de (Postfix) with SMTP id 52081410DE12; Sun, 10 May 2020 20:43:10 +0200 (CEST) Received: from linpower.localnet (SarWkQZHghCqUVkN6wP8qHFtdnsP6l9FRK8cl2-NPruvS050obWFpTLP-7i5Hnhgnj@[46.86.59.135]) by fwd10.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jXqus-1vLm640; Sun, 10 May 2020 20:43:10 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 9A15A200627; Sun, 10 May 2020 20:43:04 +0200 (CEST) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann , Stefan Weil , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= Subject: [PATCH 03/10] ui/gkt: release all keys on grab-broken-event Date: Sun, 10 May 2020 20:42:57 +0200 Message-Id: <20200510184304.9267-3-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.1 In-Reply-To: <2393388c-86c3-4d7e-178e-2c7e6d14a8de@t-online.de> References: <2393388c-86c3-4d7e-178e-2c7e6d14a8de@t-online.de> MIME-Version: 1.0 X-ID: SarWkQZHghCqUVkN6wP8qHFtdnsP6l9FRK8cl2-NPruvS050obWFpTLP-7i5Hnhgnj X-TOI-MSGID: c579c7b6-edc9-4a60-90a5-8622e012e7c9 Received-SPF: none client-ip=194.25.134.20; envelope-from=volker.ruemelin@t-online.de; helo=mailout08.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/10 14:43:07 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: QEMU Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" There is no way to grab the Ctrl-Alt-Del key combination on Windows. This key combination will leave all three keys in a stuck condition. This patch uses the grab-broken-event to release the keys. Signed-off-by: Volker Rümelin --- ui/gtk.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ui/gtk.c b/ui/gtk.c index 68c63532b1..5de2a75691 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1132,6 +1132,20 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) return TRUE; } +static gboolean gd_grab_broken_event(GtkWidget *widget, + GdkEventGrabBroken *event, void *opaque) +{ +#ifdef CONFIG_WIN32 + if (event->keyboard) { + VirtualConsole *vc = opaque; + GtkDisplayState *s = vc->s; + + gtk_release_modifiers(s); + } +#endif + return TRUE; +} + static gboolean gd_event(GtkWidget *widget, GdkEvent *event, void *opaque) { if (event->type == GDK_MOTION_NOTIFY) { @@ -1910,6 +1924,8 @@ static void gd_connect_vc_gfx_signals(VirtualConsole *vc) G_CALLBACK(gd_focus_out_event), vc); g_signal_connect(vc->gfx.drawing_area, "configure-event", G_CALLBACK(gd_configure), vc); + g_signal_connect(vc->gfx.drawing_area, "grab-broken-event", + G_CALLBACK(gd_grab_broken_event), vc); } else { g_signal_connect(vc->gfx.drawing_area, "key-press-event", G_CALLBACK(gd_text_key_down), vc); From patchwork Sun May 10 18:43:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 283050 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04A3DC54E8B for ; Sun, 10 May 2020 18:46:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D44262098B for ; Sun, 10 May 2020 18:46:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D44262098B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXqxu-000428-Ui for qemu-devel@archiver.kernel.org; Sun, 10 May 2020 14:46:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqv5-0007yL-LN for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:23 -0400 Received: from mailout10.t-online.de ([194.25.134.21]:57546) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqv4-0005RT-K1 for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:23 -0400 Received: from fwd04.aul.t-online.de (fwd04.aul.t-online.de [172.20.26.149]) by mailout10.t-online.de (Postfix) with SMTP id 090F741965F5; Sun, 10 May 2020 20:43:21 +0200 (CEST) Received: from linpower.localnet (rfrsC4ZTwhO4Go+wFNndvRwBbTUI1uyEh7ff6Kb+FcrT2aOrB-k7zJiVgnDvZALQAR@[46.86.59.135]) by fwd04.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jXqv2-1yhw7U0; Sun, 10 May 2020 20:43:20 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id A2B3D20062F; Sun, 10 May 2020 20:43:04 +0200 (CEST) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann , Stefan Weil , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= Subject: [PATCH 07/10] ui/sdl2: start in full screen with grab enabled Date: Sun, 10 May 2020 20:43:01 +0200 Message-Id: <20200510184304.9267-7-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.1 In-Reply-To: <2393388c-86c3-4d7e-178e-2c7e6d14a8de@t-online.de> References: <2393388c-86c3-4d7e-178e-2c7e6d14a8de@t-online.de> MIME-Version: 1.0 X-ID: rfrsC4ZTwhO4Go+wFNndvRwBbTUI1uyEh7ff6Kb+FcrT2aOrB-k7zJiVgnDvZALQAR X-TOI-MSGID: b3634502-8402-4b03-97e3-884f063e2b54 Received-SPF: none client-ip=194.25.134.21; envelope-from=volker.ruemelin@t-online.de; helo=mailout10.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/10 14:43:21 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: QEMU Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" To do it's work the sdl_grab_start() function needs a pointer to a sdl2_console structure. Signed-off-by: Volker Rümelin --- ui/sdl2.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ui/sdl2.c b/ui/sdl2.c index ec1cb8131f..c88ac97a79 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -871,17 +871,16 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o) SDL_SetWindowIcon(sdl2_console[0].real_window, icon); } - gui_grab = 0; - if (gui_fullscreen) { - sdl_grab_start(0); - } - mouse_mode_notifier.notify = sdl_mouse_mode_change; qemu_add_mouse_mode_change_notifier(&mouse_mode_notifier); sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0); sdl_cursor_normal = SDL_GetCursor(); + if (gui_fullscreen) { + sdl_grab_start(&sdl2_console[0]); + } + atexit(sdl_cleanup); } From patchwork Sun May 10 18:43:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 283049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A141BC38A2A for ; Sun, 10 May 2020 18:50:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 74F0A2082E for ; Sun, 10 May 2020 18:50:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74F0A2082E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXr1p-0001NW-Nh for qemu-devel@archiver.kernel.org; Sun, 10 May 2020 14:50:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqv7-00081y-Im for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:25 -0400 Received: from mailout11.t-online.de ([194.25.134.85]:33024) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqv6-0005Rf-Is for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:25 -0400 Received: from fwd26.aul.t-online.de (fwd26.aul.t-online.de [172.20.26.131]) by mailout11.t-online.de (Postfix) with SMTP id DC6B04216F8A; Sun, 10 May 2020 20:43:22 +0200 (CEST) Received: from linpower.localnet (E69VcaZbQhpsoxeUPbOxU4e1EuBmP+jS+ihFAP5ViFXLOHk5paJH8bW764H9b-gZIv@[46.86.59.135]) by fwd26.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jXqv4-1qwRU00; Sun, 10 May 2020 20:43:22 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id A4BF4200631; Sun, 10 May 2020 20:43:04 +0200 (CEST) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann , Stefan Weil , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= Subject: [PATCH 08/10] ui/sdl2-input: use trace-events to debug key events Date: Sun, 10 May 2020 20:43:02 +0200 Message-Id: <20200510184304.9267-8-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.1 In-Reply-To: <2393388c-86c3-4d7e-178e-2c7e6d14a8de@t-online.de> References: <2393388c-86c3-4d7e-178e-2c7e6d14a8de@t-online.de> MIME-Version: 1.0 X-ID: E69VcaZbQhpsoxeUPbOxU4e1EuBmP+jS+ihFAP5ViFXLOHk5paJH8bW764H9b-gZIv X-TOI-MSGID: 13800317-9579-487a-b8f2-4e9cf194af63 Received-SPF: none client-ip=194.25.134.85; envelope-from=volker.ruemelin@t-online.de; helo=mailout11.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/10 14:43:22 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: QEMU Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Volker Rümelin --- ui/sdl2-input.c | 3 +++ ui/trace-events | 3 +++ 2 files changed, 6 insertions(+) diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c index 1f9fe831b3..f068382209 100644 --- a/ui/sdl2-input.c +++ b/ui/sdl2-input.c @@ -27,6 +27,7 @@ #include "ui/console.h" #include "ui/input.h" #include "ui/sdl2.h" +#include "trace.h" void sdl2_process_key(struct sdl2_console *scon, SDL_KeyboardEvent *ev) @@ -38,6 +39,8 @@ void sdl2_process_key(struct sdl2_console *scon, return; } qcode = qemu_input_map_usb_to_qcode[ev->keysym.scancode]; + trace_sdl2_process_key(ev->keysym.scancode, qcode, + ev->type == SDL_KEYDOWN ? "down" : "up"); qkbd_state_key_event(scon->kbd, qcode, ev->type == SDL_KEYDOWN); if (!qemu_console_is_graphic(con)) { diff --git a/ui/trace-events b/ui/trace-events index 0dcda393c1..5367fd3f16 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -75,6 +75,9 @@ input_event_abs(int conidx, const char *axis, int value) "con %d, axis %s, value input_event_sync(void) "" input_mouse_mode(int absolute) "absolute %d" +# sdl2-input.c +sdl2_process_key(int sdl_scancode, int qcode, const char *action) "translated SDL scancode %d to QKeyCode %d (%s)" + # spice-display.c qemu_spice_add_memslot(int qid, uint32_t slot_id, unsigned long virt_start, unsigned long virt_end, int async) "%d %u: host virt 0x%lx - 0x%lx async=%d" qemu_spice_del_memslot(int qid, uint32_t gid, uint32_t slot_id) "%d gid=%u sid=%u" From patchwork Sun May 10 18:43:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 283048 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B59FC38A2A for ; Sun, 10 May 2020 18:52:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 350BA208DB for ; Sun, 10 May 2020 18:52:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 350BA208DB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXr3t-0003vt-DI for qemu-devel@archiver.kernel.org; Sun, 10 May 2020 14:52:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqvF-0008IO-BR for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:33 -0400 Received: from mailout08.t-online.de ([194.25.134.20]:45964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqvE-0005Te-Dn for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:33 -0400 Received: from fwd03.aul.t-online.de (fwd03.aul.t-online.de [172.20.27.148]) by mailout08.t-online.de (Postfix) with SMTP id 4DE64411E3C2; Sun, 10 May 2020 20:43:31 +0200 (CEST) Received: from linpower.localnet (EBMjgQZTZh0GoxMjU3+39KAfuO0yz5ADucJ4mg5dxOvPu3CDT1t+nebHnJxFpfwwv2@[46.86.59.135]) by fwd03.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jXqv9-0Aca8G0; Sun, 10 May 2020 20:43:27 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id A9151200633; Sun, 10 May 2020 20:43:04 +0200 (CEST) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann , Stefan Weil , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= Subject: [PATCH 10/10] ui/gtk: use native keyboard scancodes on Windows Date: Sun, 10 May 2020 20:43:04 +0200 Message-Id: <20200510184304.9267-10-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.1 In-Reply-To: <2393388c-86c3-4d7e-178e-2c7e6d14a8de@t-online.de> References: <2393388c-86c3-4d7e-178e-2c7e6d14a8de@t-online.de> MIME-Version: 1.0 X-ID: EBMjgQZTZh0GoxMjU3+39KAfuO0yz5ADucJ4mg5dxOvPu3CDT1t+nebHnJxFpfwwv2 X-TOI-MSGID: 8ef9979f-de5f-4d84-aee7-bc274509155f Received-SPF: none client-ip=194.25.134.20; envelope-from=volker.ruemelin@t-online.de; helo=mailout08.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/10 14:43:07 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: QEMU Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Since GTK 3.22 the function gdk_event_get_scancode() is available. On Windows this function returns keyboard scancodes and some extended flags. These raw keyboard scancodes are much better suited for this use case than the half-cooked win32 virtual-key codes because scancodes report the key position on the keyboard and the positions are independent of national language settings. Signed-off-by: Volker Rümelin --- ui/gtk.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index a43fddc57f..242b378bf1 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1016,8 +1016,13 @@ static const guint16 *gd_get_keymap(size_t *maplen) #ifdef GDK_WINDOWING_WIN32 if (GDK_IS_WIN32_DISPLAY(dpy)) { trace_gd_keymap_windowing("win32"); +#if GTK_CHECK_VERSION(3, 22, 0) + *maplen = qemu_input_map_atset1_to_qcode_len; + return qemu_input_map_atset1_to_qcode; +#else *maplen = qemu_input_map_win32_to_qcode_len; return qemu_input_map_win32_to_qcode; +#endif } #endif @@ -1063,6 +1068,25 @@ static int gd_map_keycode(int scancode) return keycode_map[scancode]; } +static int gd_get_keycode(GdkEventKey *key) +{ +#if defined G_OS_WIN32 && GTK_CHECK_VERSION(3, 22, 0) + int scancode = gdk_event_get_scancode((GdkEvent *)key); + + /* translate Windows native scan codes to atset1 keycodes */ + switch (scancode & (KF_EXTENDED | 0xff)) { + case 0x145: /* NUMLOCK */ + return scancode & 0xff; + } + + return scancode & KF_EXTENDED ? + 0xe000 | (scancode & 0xff) : scancode & 0xff; + +#else + return key->hardware_keycode; +#endif +} + static gboolean gd_text_key_down(GtkWidget *widget, GdkEventKey *key, void *opaque) { @@ -1074,7 +1098,7 @@ static gboolean gd_text_key_down(GtkWidget *widget, } else if (key->length) { kbd_put_string_console(con, key->string, key->length); } else { - int qcode = gd_map_keycode(key->hardware_keycode); + int qcode = gd_map_keycode(gd_get_keycode(key)); kbd_put_qcode_console(con, qcode, false); } return TRUE; @@ -1083,7 +1107,7 @@ static gboolean gd_text_key_down(GtkWidget *widget, static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) { VirtualConsole *vc = opaque; - int qcode; + int keycode, qcode; #ifdef G_OS_WIN32 /* on windows, we ought to ignore the reserved key event? */ @@ -1111,9 +1135,10 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) return TRUE; } - qcode = gd_map_keycode(key->hardware_keycode); + keycode = gd_get_keycode(key); + qcode = gd_map_keycode(keycode); - trace_gd_key_event(vc->label, key->hardware_keycode, qcode, + trace_gd_key_event(vc->label, keycode, qcode, (key->type == GDK_KEY_PRESS) ? "down" : "up"); qkbd_state_key_event(vc->gfx.kbd, qcode,