From patchwork Wed Sep 11 12:14:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 827443 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp771219wrc; Wed, 11 Sep 2024 05:37:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVHk2rTW2ol5c222o4YrO+9l2xZsWGwheqyeXbgq/fiXenpmyHTVfJirHJmtO5tOkqrqiKmuA==@linaro.org X-Google-Smtp-Source: AGHT+IHGXsOXXMTWphpAOoMiZmQnq/o7ntL9u4KR1Xdc+TKeuAu57E+eei5xRUSr8CH3+f9RbAkB X-Received: by 2002:a05:620a:3727:b0:7a9:c146:a9eb with SMTP id af79cd13be357-7a9c146af12mr845890485a.20.1726058269666; Wed, 11 Sep 2024 05:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726058269; cv=none; d=google.com; s=arc-20240605; b=iUUzYRqo7A9QAAR7wAbVclkaYkUwlBSC8jTPTSFTxZo91dZiIhx0pFxAZ7WG8gZRM0 xnPYq527KyE1ImFRzxXEX9cR+h9rBvkZEEQqYgRTWWqN04pn2ZUa62JZDGbDHk2fqKkw UuchjMBw+vk6oxNR6HidI4KsiDfPK1m7ITPD3RoMyRECU2YTaJOEcvPmQfJBiEsLGzdH IG0zRN5xn5ZirYaSZuOhWJaM2TeTazHAkXwXStvqc5RszldEdDxjv4fwvgiEBDKqQjMT BxTLsZ//i4ai8KcPq39odTG9sy/RLwRRLmjWh6pf/ZaGdE2pqjtSy908oWRJ16EMXIV3 I7Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vsK0mdY5OlPxji3PY5r+h72YwQWFU0AxW9NvQTZMW7U=; fh=+aSvXDiqZ2W0q/7kXE8ttXnONuOwKPBBQR1BEfKH9WY=; b=Ie7+lTYs6LoD55AHv9PqzEmXblS8faB6JZGICVmjf4Ju6KfGbnqock9hWs2XDRQEes Vsry1CTJoQ1/uZ6+TCAyWw6iPw8dhjY4H17JqUuIX2AyyEI5i/NnJOihgVsBlcVkHRVx 46A1+Pub9jGupzsEm5XhivQk9Nmp97JCcy3bmCMSZK/A5FAm0mA0hYWqqduvsz1e/8oY h2/bvgl7iB8QC08lEWitF+E1gz9uqG72my8i15UVGW9+ndtmaNk5BC3L5jApDp4LwSRY GkUNjemxo+/YmVnYVNeCak96yn5uvizZB2yDT014ATNCGjP2QrnwkE2leX3lM33w80ta lyVg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u7+MSQb2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a9a7a47aaesi988852685a.436.2024.09.11.05.37.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2024 05:37:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u7+MSQb2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soMKq-0007xG-Gc; Wed, 11 Sep 2024 08:20:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1soMKk-0007cY-P2 for qemu-devel@nongnu.org; Wed, 11 Sep 2024 08:20:33 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1soMKi-0007yB-Pl for qemu-devel@nongnu.org; Wed, 11 Sep 2024 08:20:30 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42cbaf9bfdbso23686595e9.0 for ; Wed, 11 Sep 2024 05:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726057227; x=1726662027; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vsK0mdY5OlPxji3PY5r+h72YwQWFU0AxW9NvQTZMW7U=; b=u7+MSQb2UDgsa7MXNtwayQKUqEvYsdRjrM+1fOCjckgOwjzE3cfKumnYfMNf7ey3Hh GY/5x7gC/noYYvciqOiiBtxwCk5O3sa8G479CLc6oGpy+Zh63R6Tr720Oj2gAHHnJ5p4 7WVdB8tKxevXtp4cPsvVI4NEF3HIv1sIJIhmOWYKw2tHKyam49gVC+8+vN6yMrNDR6ng eCIpi/8ZLEtXsaQQymw8wVl2zmXUtBobzuqRx2WgOa2PLlVsqy2ZRULLd391tqFwD6+M k+etd1yzDx8mFFEEMKkCtNSZxVnrltzHdEvmbfBMkdIdIOQSu5rbrj1KpQSnvaqqnN3Y v2fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726057227; x=1726662027; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vsK0mdY5OlPxji3PY5r+h72YwQWFU0AxW9NvQTZMW7U=; b=tXBpFoGNdDkLW8mNXUY4dPXxX2kSvvfrizO8shXtPuYvDQzn4l6vvW5KHkfTfegE+i G5hvCsSdQ486xtDVQq1evcVGH6mySYurpJmK1kdfOony9BYfMDsYClUhllblhLUGp5o5 gkyUjNT8BGjaYgevDQnIpdqBJaoPr723r0TlqwvcUnZ00HaEwP7uzZ/6YXUmBR9YUiVV dhyAKAHK2v2lXjsIyR9APP7ZkTTPaFSHTTlsyX5/NRk1YgBqsurNfTSIwCKZYYgSN0u2 rIwSCLU3muAth72RSELzjz75EkT1qHHqHfxQm+DjZmsjW8yZk6ofDJfsV262kjY9JDLx BYfw== X-Gm-Message-State: AOJu0YwHcAHO0MtDQ+Kcq6lzMaX26r2rDnwtGRRwTe1xzEQUWC3NfP+6 4XJN76ShbTT80eDqJ/2ymSUjilcmgC/W/CGLa2SbwBJqbPyCBaQkG513BaBbwL2UdUqnORoMSZu h X-Received: by 2002:a7b:c858:0:b0:42c:af06:71b with SMTP id 5b1f17b1804b1-42caf060978mr98192025e9.28.1726057226929; Wed, 11 Sep 2024 05:20:26 -0700 (PDT) Received: from m1x-phil.lan ([176.187.196.107]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42caeb815f4sm142611685e9.30.2024.09.11.05.20.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 11 Sep 2024 05:20:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Volker_R=C3=BCmelin?= , Howard Spoelstra , Bernhard Beschow , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 54/56] ui/sdl2: ignore GUI keys in SDL_TEXTINPUT handler Date: Wed, 11 Sep 2024 14:14:19 +0200 Message-ID: <20240911121422.52585-55-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240911121422.52585-1-philmd@linaro.org> References: <20240911121422.52585-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Volker Rümelin Ignore GUI keys for SDL_TEXTINPUT events, just like GUI keys are ignored for SDL_KEYDOWN events. This prevents unintended text input in a text console when hiding the text console with the GUI keys. The SDL_TEXTINPUT event always comes after the SDL_KEYDOWN event. See https://github.com/libsdl-org/SDL/issues/1659. Tested-by: Howard Spoelstra Signed-off-by: Volker Rümelin Tested-by: Bernhard Beschow Message-ID: <20240909061552.6122-3-vr_qemu@t-online.de> Signed-off-by: Philippe Mathieu-Daudé --- include/ui/sdl2.h | 1 + ui/sdl2.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h index 6907115809..dbe6e3d973 100644 --- a/include/ui/sdl2.h +++ b/include/ui/sdl2.h @@ -42,6 +42,7 @@ struct sdl2_console { int updates; int idle_counter; int ignore_hotkeys; + bool gui_keysym; SDL_GLContext winctx; QKbdState *kbd; #ifdef CONFIG_OPENGL diff --git a/ui/sdl2.c b/ui/sdl2.c index bf6868f204..574a22306d 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -388,12 +388,13 @@ 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) { return; } + scon->gui_keysym = false; + if (!scon->ignore_hotkeys && gui_key_modifier_pressed && !ev->key.repeat) { switch (ev->key.keysym.scancode) { case SDL_SCANCODE_2: @@ -419,15 +420,15 @@ static void handle_keydown(SDL_Event *ev) } } sdl2_release_modifiers(scon); - gui_keysym = 1; + scon->gui_keysym = true; } break; case SDL_SCANCODE_F: toggle_full_screen(scon); - gui_keysym = 1; + scon->gui_keysym = true; break; case SDL_SCANCODE_G: - gui_keysym = 1; + scon->gui_keysym = true; if (!gui_grab) { sdl_grab_start(scon); } else if (!gui_fullscreen) { @@ -440,7 +441,7 @@ static void handle_keydown(SDL_Event *ev) /* re-create scon->texture */ sdl2_2d_switch(&scon->dcl, scon->surface); } - gui_keysym = 1; + scon->gui_keysym = true; break; #if 0 case SDL_SCANCODE_KP_PLUS: @@ -459,14 +460,14 @@ static void handle_keydown(SDL_Event *ev) __func__, width, height); sdl_scale(scon, width, height); sdl2_redraw(scon); - gui_keysym = 1; + scon->gui_keysym = true; } #endif default: break; } } - if (!gui_keysym) { + if (!scon->gui_keysym) { sdl2_process_key(scon, &ev->key); } } @@ -492,7 +493,7 @@ static void handle_textinput(SDL_Event *ev) return; } - if (QEMU_IS_TEXT_CONSOLE(con)) { + if (!scon->gui_keysym && QEMU_IS_TEXT_CONSOLE(con)) { qemu_text_console_put_string(QEMU_TEXT_CONSOLE(con), ev->text.text, strlen(ev->text.text)); } }