From patchwork Sun May 10 18:42:55 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: 1287275 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=t-online.de 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 ozlabs.org (Postfix) with ESMTPS id 49KtJ46sq5z9sPF for ; Mon, 11 May 2020 04:43:48 +1000 (AEST) Received: from localhost ([::1]:34916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXqvS-0007jr-Ka for incoming@patchwork.ozlabs.org; Sun, 10 May 2020 14:43:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXquv-0007hR-9Q for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:13 -0400 Received: from mailout08.t-online.de ([194.25.134.20]:44842) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqut-0005Kj-B3 for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:13 -0400 Received: from fwd13.aul.t-online.de (fwd13.aul.t-online.de [172.20.27.62]) by mailout08.t-online.de (Postfix) with SMTP id 6D7E3410DE0D; Sun, 10 May 2020 20:43:07 +0200 (CEST) Received: from linpower.localnet (bLYMKoZU8hKhDKb8PFWW0jzr1G64I1AXiXwwqX-uajYjh2-B4mwX-J5cBQZ-ljEwhJ@[46.86.59.135]) by fwd13.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jXqun-0gUsd60; Sun, 10 May 2020 20:43:05 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 96DAE200624; 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 01/10] ui/win32-kbd-hook: handle AltGr in a hook procedure Date: Sun, 10 May 2020 20:42:55 +0200 Message-Id: <20200510184304.9267-1-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: bLYMKoZU8hKhDKb8PFWW0jzr1G64I1AXiXwwqX-uajYjh2-B4mwX-J5cBQZ-ljEwhJ X-TOI-MSGID: 17a9a933-805a-419d-9d43-3b9b32aec4d4 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, URIBL_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Import win32 keyboard hooking code from project spice-gtk. This patch removes the extra left control key up/down input events inserted by Windows for the right alt key up/down input events with international keyboard layouts. Additionally there's some code to grab the keyboard. The next patches will use this code. Only Windows needs this. Signed-off-by: Volker Rümelin --- ui/Makefile.objs | 1 + ui/win32-kbd-hook.c | 100 ++++++++++++++++++++++++++++++++++++++++++++ ui/win32-kbd-hook.h | 14 +++++++ 3 files changed, 115 insertions(+) create mode 100644 ui/win32-kbd-hook.c create mode 100644 ui/win32-kbd-hook.h diff --git a/ui/Makefile.objs b/ui/Makefile.objs index e6da6ff047..f74d72a612 100644 --- a/ui/Makefile.objs +++ b/ui/Makefile.objs @@ -15,6 +15,7 @@ common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o common-obj-$(CONFIG_COCOA) += cocoa.o common-obj-$(CONFIG_VNC) += $(vnc-obj-y) common-obj-$(call lnot,$(CONFIG_VNC)) += vnc-stubs.o +common-obj-$(CONFIG_WIN32) += win32-kbd-hook.o # ui-sdl module common-obj-$(CONFIG_SDL) += sdl.mo diff --git a/ui/win32-kbd-hook.c b/ui/win32-kbd-hook.c new file mode 100644 index 0000000000..d558912ef2 --- /dev/null +++ b/ui/win32-kbd-hook.c @@ -0,0 +1,100 @@ +/* + * 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 "sysemu/sysemu.h" +#include "win32-kbd-hook.h" + +static Notifier win32_unhook_notifier; +static HHOOK win32_keyboard_hook; +static HWND win32_window; +static DWORD win32_grab; + +static LRESULT CALLBACK keyboard_hook_cb(int code, WPARAM wparam, LPARAM lparam) +{ + if (win32_window && code == HC_ACTION && win32_window == GetFocus()) { + KBDLLHOOKSTRUCT *hooked = (KBDLLHOOKSTRUCT *)lparam; + + if (wparam != WM_KEYUP) { + DWORD dwmsg = (hooked->flags << 24) | + ((hooked->scanCode & 0xff) << 16) | 1; + + switch (hooked->vkCode) { + case VK_CAPITAL: + /* fall through */ + case VK_SCROLL: + /* fall through */ + case VK_NUMLOCK: + /* fall through */ + case VK_LSHIFT: + /* fall through */ + case VK_RSHIFT: + /* fall through */ + case VK_RCONTROL: + /* fall through */ + case VK_LMENU: + /* fall through */ + case VK_RMENU: + break; + + case VK_LCONTROL: + /* + * When pressing AltGr, an extra VK_LCONTROL with a special + * scancode with bit 9 set is sent. Let's ignore the extra + * VK_LCONTROL, as that will make AltGr misbehave. + */ + if (hooked->scanCode & 0x200) { + return 1; + } + break; + + default: + if (win32_grab) { + SendMessage(win32_window, wparam, hooked->vkCode, dwmsg); + return 1; + } + break; + } + + } else { + switch (hooked->vkCode) { + case VK_LCONTROL: + if (hooked->scanCode & 0x200) { + return 1; + } + break; + } + } + } + + return CallNextHookEx(NULL, code, wparam, lparam); +} + +static void keyboard_hook_unhook(Notifier *n, void *data) +{ + UnhookWindowsHookEx(win32_keyboard_hook); + win32_keyboard_hook = NULL; +} + +void win32_kbd_set_window(HWND hwnd) +{ + if (hwnd && !win32_keyboard_hook) { + /* note: the installing thread must have a message loop */ + win32_keyboard_hook = SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_hook_cb, + GetModuleHandle(NULL), 0); + if (win32_keyboard_hook) { + win32_unhook_notifier.notify = keyboard_hook_unhook; + qemu_add_exit_notifier(&win32_unhook_notifier); + } + } + + win32_window = hwnd; +} + +void win32_kbd_set_grab(bool grab) +{ + win32_grab = grab; +} diff --git a/ui/win32-kbd-hook.h b/ui/win32-kbd-hook.h new file mode 100644 index 0000000000..1e0e866610 --- /dev/null +++ b/ui/win32-kbd-hook.h @@ -0,0 +1,14 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef UI_WIN32_KBD_HOOK_H +#define UI_WIN32_KBD_HOOK_H + +void win32_kbd_set_window(HWND hwnd); +void win32_kbd_set_grab(bool grab); + +#endif From patchwork Sun May 10 18:42:56 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: 1287280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=t-online.de 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 ozlabs.org (Postfix) with ESMTPS id 49KtL24Wr0z9sPF for ; Mon, 11 May 2020 04:45:30 +1000 (AEST) Received: from localhost ([::1]:41606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXqx6-00021R-B1 for incoming@patchwork.ozlabs.org; Sun, 10 May 2020 14:45:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXquv-0007hu-N2 for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:13 -0400 Received: from mailout06.t-online.de ([194.25.134.19]:58580) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXquu-0005LJ-N5 for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:13 -0400 Received: from fwd18.aul.t-online.de (fwd18.aul.t-online.de [172.20.26.244]) by mailout06.t-online.de (Postfix) with SMTP id 11FF6412B000; Sun, 10 May 2020 20:43:11 +0200 (CEST) Received: from linpower.localnet (ZGsaI4ZArh2p4tcVeWMbsQWTZHinmOYO+4ZDxCh6zMxsEtCdqr0p6i9KXLRyygXZUW@[46.86.59.135]) by fwd18.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jXqup-1lEoaW0; Sun, 10 May 2020 20:43:07 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 99239200626; 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 02/10] ui/gtk: fix handling of AltGr key on Windows Date: Sun, 10 May 2020 20:42:56 +0200 Message-Id: <20200510184304.9267-2-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: ZGsaI4ZArh2p4tcVeWMbsQWTZHinmOYO+4ZDxCh6zMxsEtCdqr0p6i9KXLRyygXZUW X-TOI-MSGID: 94e6f681-a0f3-4fd4-a4c4-53acd4f9acd8 Received-SPF: none client-ip=194.25.134.19; envelope-from=volker.ruemelin@t-online.de; helo=mailout06.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/10 14:43:11 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Wire up the keyboard hooking code on Windows to fix the AltGr key and improve keyboard grabbing. Signed-off-by: Volker Rümelin --- ui/gtk.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/ui/gtk.c b/ui/gtk.c index 83f2f5d49b..68c63532b1 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -38,6 +38,10 @@ #include "ui/console.h" #include "ui/gtk.h" +#ifdef CONFIG_WIN32 +#include +#include "win32-kbd-hook.h" +#endif #include #include @@ -1451,6 +1455,9 @@ static void gd_grab_keyboard(VirtualConsole *vc, const char *reason) } } +#ifdef CONFIG_WIN32 + win32_kbd_set_grab(true); +#endif #if GTK_CHECK_VERSION(3, 20, 0) gd_grab_update(vc, true, vc->s->ptr_owner == vc); #else @@ -1472,6 +1479,9 @@ static void gd_ungrab_keyboard(GtkDisplayState *s) } s->kbd_owner = NULL; +#ifdef CONFIG_WIN32 + win32_kbd_set_grab(false); +#endif #if GTK_CHECK_VERSION(3, 20, 0) gd_grab_update(vc, false, vc->s->ptr_owner == vc); #else @@ -1614,12 +1624,28 @@ static gboolean gd_leave_event(GtkWidget *widget, GdkEventCrossing *crossing, return TRUE; } +static gboolean gd_focus_in_event(GtkWidget *widget, + GdkEventFocus *event, gpointer opaque) +{ +#ifdef CONFIG_WIN32 + VirtualConsole *vc = opaque; + GtkDisplayState *s = vc->s; + + win32_kbd_set_window(gdk_win32_window_get_impl_hwnd( + gtk_widget_get_window(vc->window ? vc->window : s->window))); +#endif + return TRUE; +} + static gboolean gd_focus_out_event(GtkWidget *widget, - GdkEventCrossing *crossing, gpointer opaque) + GdkEventFocus *event, gpointer opaque) { VirtualConsole *vc = opaque; GtkDisplayState *s = vc->s; +#ifdef CONFIG_WIN32 + win32_kbd_set_window(NULL); +#endif gtk_release_modifiers(s); return TRUE; } @@ -1878,6 +1904,8 @@ static void gd_connect_vc_gfx_signals(VirtualConsole *vc) G_CALLBACK(gd_enter_event), vc); g_signal_connect(vc->gfx.drawing_area, "leave-notify-event", G_CALLBACK(gd_leave_event), vc); + g_signal_connect(vc->gfx.drawing_area, "focus-in-event", + G_CALLBACK(gd_focus_in_event), vc); g_signal_connect(vc->gfx.drawing_area, "focus-out-event", G_CALLBACK(gd_focus_out_event), vc); g_signal_connect(vc->gfx.drawing_area, "configure-event", 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: 1287276 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=t-online.de 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 ozlabs.org (Postfix) with ESMTPS id 49KtJ90tL2z9sPF for ; Mon, 11 May 2020 04:43:53 +1000 (AEST) Received: from localhost ([::1]:35040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXqvW-0007n7-TB for incoming@patchwork.ozlabs.org; Sun, 10 May 2020 14:43:50 -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+incoming=patchwork.ozlabs.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:42:58 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: 1287283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=t-online.de 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 ozlabs.org (Postfix) with ESMTPS id 49KtP860jZz9sPF for ; Mon, 11 May 2020 04:48:12 +1000 (AEST) Received: from localhost ([::1]:50306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXqzi-0006eE-Dw for incoming@patchwork.ozlabs.org; Sun, 10 May 2020 14:48:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqv3-0007uu-Iz for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:21 -0400 Received: from mailout06.t-online.de ([194.25.134.19]:58962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqv2-0005R2-PS for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:21 -0400 Received: from fwd13.aul.t-online.de (fwd13.aul.t-online.de [172.20.27.62]) by mailout06.t-online.de (Postfix) with SMTP id 16F9B412B005; Sun, 10 May 2020 20:43:19 +0200 (CEST) Received: from linpower.localnet (X7H34aZlZhPe0kHioGJmNp9z7PjBwteoz9OM883n20cISuyiQR6vdbCayze57P+gzC@[46.86.59.135]) by fwd13.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jXquu-0r4RE00; Sun, 10 May 2020 20:43:12 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 9C379200629; 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 04/10] ui/gtk: remove unused code Date: Sun, 10 May 2020 20:42:58 +0200 Message-Id: <20200510184304.9267-4-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: X7H34aZlZhPe0kHioGJmNp9z7PjBwteoz9OM883n20cISuyiQR6vdbCayze57P+gzC X-TOI-MSGID: 87158edc-5690-4c38-b3b7-a2cfe7a7c11e Received-SPF: none client-ip=194.25.134.19; envelope-from=volker.ruemelin@t-online.de; helo=mailout06.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/10 14:43:11 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This code was last used before commit 2ec78706d1 "ui: convert GTK and SDL1 frontends to keycodemapdb". Signed-off-by: Volker Rümelin Reviewed-by: Philippe Mathieu-Daudé --- ui/gtk.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index 5de2a75691..c70bfc2be4 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -112,15 +112,6 @@ # define VTE_CHECK_VERSION(a, b, c) 0 #endif -/* Some older mingw versions lack this constant or have - * it conditionally defined */ -#ifdef _WIN32 -# ifndef MAPVK_VK_TO_VSC -# define MAPVK_VK_TO_VSC 0 -# endif -#endif - - #define HOTKEY_MODIFIERS (GDK_CONTROL_MASK | GDK_MOD1_MASK) static const guint16 *keycode_map; From patchwork Sun May 10 18:42:59 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: 1287277 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=t-online.de 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 ozlabs.org (Postfix) with ESMTPS id 49KtJF0rTQz9sPF for ; Mon, 11 May 2020 04:43:57 +1000 (AEST) Received: from localhost ([::1]:35294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXqva-0007tQ-SS for incoming@patchwork.ozlabs.org; Sun, 10 May 2020 14:43:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqv1-0007qH-1K for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:19 -0400 Received: from mailout02.t-online.de ([194.25.134.17]:36484) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqv0-0005Qj-1w for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:18 -0400 Received: from fwd32.aul.t-online.de (fwd32.aul.t-online.de [172.20.26.144]) by mailout02.t-online.de (Postfix) with SMTP id 5D87941ACBAA; Sun, 10 May 2020 20:43:16 +0200 (CEST) Received: from linpower.localnet (bHC234ZvYhqqiycqzb-FGY2RKNXtxkMVJ7AimXqY37O5ZudUwK4a4UPvwxe+uPiwcp@[46.86.59.135]) by fwd32.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jXqux-0uILmS0; Sun, 10 May 2020 20:43:15 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 9E4DC20062B; 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 05/10] ui/gtk: remove unused variable ignore_keys Date: Sun, 10 May 2020 20:42:59 +0200 Message-Id: <20200510184304.9267-5-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: bHC234ZvYhqqiycqzb-FGY2RKNXtxkMVJ7AimXqY37O5ZudUwK4a4UPvwxe+uPiwcp X-TOI-MSGID: 786493ba-6b4b-4b8a-accc-f216fa1b679f Received-SPF: none client-ip=194.25.134.17; envelope-from=volker.ruemelin@t-online.de; helo=mailout02.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/10 14:43:16 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Since the removal of GTK2 code the code around ignore_keys is unused. See commit 1a01716a30 "gtk: Avoid accel key leakage into guest on console switch" why it was needed before. Signed-off-by: Volker Rümelin Reviewed-by: Philippe Mathieu-Daudé --- ui/gtk.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index c70bfc2be4..5a25e3fa4c 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -168,8 +168,6 @@ struct GtkDisplayState { bool external_pause_update; - bool ignore_keys; - DisplayOptions *opts; }; @@ -1085,14 +1083,8 @@ static gboolean gd_text_key_down(GtkWidget *widget, static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) { VirtualConsole *vc = opaque; - GtkDisplayState *s = vc->s; int qcode; - if (s->ignore_keys) { - s->ignore_keys = (key->type == GDK_KEY_PRESS); - return TRUE; - } - #ifdef WIN32 /* on windows, we ought to ignore the reserved key event? */ if (key->hardware_keycode == 0xff) @@ -1189,7 +1181,6 @@ static void gd_menu_switch_vc(GtkMenuItem *item, void *opaque) gtk_notebook_set_current_page(nb, page); gtk_widget_grab_focus(vc->focus); } - s->ignore_keys = false; } static void gd_accel_switch_vc(void *opaque) From patchwork Sun May 10 18:43:00 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: 1287282 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=t-online.de 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 ozlabs.org (Postfix) with ESMTPS id 49KtLB1KNgz9sSd for ; Mon, 11 May 2020 04:45:38 +1000 (AEST) Received: from localhost ([::1]:42288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXqxD-0002JF-RL for incoming@patchwork.ozlabs.org; Sun, 10 May 2020 14:45:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqv2-0007s3-2I for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:20 -0400 Received: from mailout06.t-online.de ([194.25.134.19]:58892) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqv1-0005Qt-9D for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:19 -0400 Received: from fwd23.aul.t-online.de (fwd23.aul.t-online.de [172.20.26.128]) by mailout06.t-online.de (Postfix) with SMTP id 1786C412B004; Sun, 10 May 2020 20:43:18 +0200 (CEST) Received: from linpower.localnet (Gh9NZQZFQhuH0mfL3pChJ28OX01dW7wLS3WP2GNaZrgxM6KSKi2xrQ2ZCaGjc3sg8h@[46.86.59.135]) by fwd23.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jXquz-1VhHDU0; Sun, 10 May 2020 20:43:17 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id A094B20062E; 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 06/10] ui/sdl2: fix handling of AltGr key on Windows Date: Sun, 10 May 2020 20:43:00 +0200 Message-Id: <20200510184304.9267-6-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: Gh9NZQZFQhuH0mfL3pChJ28OX01dW7wLS3WP2GNaZrgxM6KSKi2xrQ2ZCaGjc3sg8h X-TOI-MSGID: f270ecb2-bd2a-4931-ae7d-9bd289b80a3e Received-SPF: none client-ip=194.25.134.19; envelope-from=volker.ruemelin@t-online.de; helo=mailout06.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/10 14:43:11 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Wire up the keyboard hooking code on Windows to fix the AltGr key and improve keyboard grabbing. Signed-off-by: Volker Rümelin --- ui/sdl2.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ui/sdl2.c b/ui/sdl2.c index 3c9424eb42..ec1cb8131f 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -30,6 +30,9 @@ #include "ui/sdl2.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" +#ifdef CONFIG_WIN32 +#include "win32-kbd-hook.h" +#endif static int sdl2_num_outputs; static struct sdl2_console *sdl2_console; @@ -220,6 +223,9 @@ static void sdl_grab_start(struct sdl2_console *scon) } SDL_SetWindowGrab(scon->real_window, SDL_TRUE); gui_grab = 1; +#ifdef CONFIG_WIN32 + win32_kbd_set_grab(true); +#endif sdl_update_caption(scon); } @@ -227,6 +233,9 @@ static void sdl_grab_end(struct sdl2_console *scon) { SDL_SetWindowGrab(scon->real_window, SDL_FALSE); gui_grab = 0; +#ifdef CONFIG_WIN32 + win32_kbd_set_grab(false); +#endif sdl_show_cursor(scon); sdl_update_caption(scon); } @@ -532,6 +541,18 @@ static void handle_windowevent(SDL_Event *ev) sdl2_redraw(scon); break; case SDL_WINDOWEVENT_FOCUS_GAINED: +#ifdef CONFIG_WIN32 + if (qemu_console_is_graphic(scon->dcl.con)) { + SDL_SysWMinfo info; + + SDL_VERSION(&info.version); + if (SDL_GetWindowWMInfo(scon->real_window, &info)) { + win32_kbd_set_grab(gui_grab); + win32_kbd_set_window(info.info.win.window); + } + } +#endif + /* fall through */ case SDL_WINDOWEVENT_ENTER: if (!gui_grab && (qemu_input_is_absolute() || absolute_enabled)) { absolute_mouse_grab(scon); @@ -546,6 +567,11 @@ static void handle_windowevent(SDL_Event *ev) scon->ignore_hotkeys = get_mod_state(); break; case SDL_WINDOWEVENT_FOCUS_LOST: +#ifdef CONFIG_WIN32 + if (qemu_console_is_graphic(scon->dcl.con)) { + win32_kbd_set_window(NULL); + } +#endif if (gui_grab && !gui_fullscreen) { sdl_grab_end(scon); } 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: 1287281 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=t-online.de 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 ozlabs.org (Postfix) with ESMTPS id 49KtL44d6yz9sSd for ; Mon, 11 May 2020 04:45:32 +1000 (AEST) Received: from localhost ([::1]:41798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXqx8-00027C-Ao for incoming@patchwork.ozlabs.org; Sun, 10 May 2020 14:45:30 -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+incoming=patchwork.ozlabs.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: 1287284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=t-online.de 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 ozlabs.org (Postfix) with ESMTPS id 49KtRG0ppwz9sPF for ; Mon, 11 May 2020 04:50:02 +1000 (AEST) Received: from localhost ([::1]:54912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXr1T-0000R1-TV for incoming@patchwork.ozlabs.org; Sun, 10 May 2020 14:49:59 -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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Volker Rümelin Reviewed-by: Philippe Mathieu-Daudé --- 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:03 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: 1287285 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=t-online.de 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 ozlabs.org (Postfix) with ESMTPS id 49KtSR17J7z9sPF for ; Mon, 11 May 2020 04:51:03 +1000 (AEST) Received: from localhost ([::1]:57086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXr2S-000263-UU for incoming@patchwork.ozlabs.org; Sun, 10 May 2020 14:51:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqv9-000868-Gt for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:27 -0400 Received: from mailout08.t-online.de ([194.25.134.20]:45714) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqv8-0005T4-Ot for qemu-devel@nongnu.org; Sun, 10 May 2020 14:43:27 -0400 Received: from fwd08.aul.t-online.de (fwd08.aul.t-online.de [172.20.26.151]) by mailout08.t-online.de (Postfix) with SMTP id 9FFDA411E3C0; Sun, 10 May 2020 20:43:25 +0200 (CEST) Received: from linpower.localnet (bR6pEQZZQhGTvGIx2LKkfKiVVWtHblG8vwx1Phx6Kl1nHSm0QRfZzqDQUs0tM80QOC@[46.86.59.135]) by fwd08.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jXqv7-2SgojY0; Sun, 10 May 2020 20:43:25 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id A6BE9200632; 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 09/10] ui/gtk: don't pass on win keys without keyboard grab Date: Sun, 10 May 2020 20:43:03 +0200 Message-Id: <20200510184304.9267-9-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: bR6pEQZZQhGTvGIx2LKkfKiVVWtHblG8vwx1Phx6Kl1nHSm0QRfZzqDQUs0tM80QOC X-TOI-MSGID: ef055f01-332d-42aa-a346-50fa83c172d3 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch applies commit c68f74b02e "win32: do not handle win keys when the keyboard is not grabbed" from project spice-gtk to ui/gtk.c. Signed-off-by: Volker Rümelin --- ui/gtk.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/gtk.c b/ui/gtk.c index 5a25e3fa4c..a43fddc57f 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1085,10 +1085,17 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) VirtualConsole *vc = opaque; int qcode; -#ifdef WIN32 +#ifdef G_OS_WIN32 /* on windows, we ought to ignore the reserved key event? */ if (key->hardware_keycode == 0xff) return false; + + if (!vc->s->kbd_owner) { + if (key->hardware_keycode == VK_LWIN || + key->hardware_keycode == VK_RWIN) { + return FALSE; + } + } #endif if (key->keyval == GDK_KEY_Pause 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: 1287287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=t-online.de 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 ozlabs.org (Postfix) with ESMTPS id 49KtTg1cgfz9sSd for ; Mon, 11 May 2020 04:52:07 +1000 (AEST) Received: from localhost ([::1]:59422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXr3U-000335-T8 for incoming@patchwork.ozlabs.org; Sun, 10 May 2020 14:52:04 -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+incoming=patchwork.ozlabs.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,