qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Volker Rümelin" <vr_qemu@t-online.de>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Stefan Weil" <sw@weilnetz.de>
Cc: Howard Spoelstra <hsp.cat7@gmail.com>,
	Bernhard Beschow <shentey@gmail.com>,
	qemu-devel@nongnu.org
Subject: [PATCH 2/3] ui/sdl2: release all modifiers
Date: Mon,  9 Sep 2024 08:15:51 +0200	[thread overview]
Message-ID: <20240909061552.6122-2-vr_qemu@t-online.de> (raw)
In-Reply-To: <ae9b2c56-dab2-4b8f-bb5e-2087e9ccaa92@t-online.de>

Each virtual console in the SDL2 frontend has a key state map.
When switching windows with GUI keys we have to release all
pressed modifier keys in the currently active window, because
after the switch the now inactive window no longer receives the
key release events.

To reproduce the issue open a text editor in the SDL UI and then
press Ctrl-Alt-2 to open a Compat Monitor Console. Close the
console with the mouse. Try to enter text in the text editor and
notice that the modifier keys Ctrl and Alt are stuck and need to
be pressed once to be released.

Tested-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
 include/ui/sdl2.h | 1 +
 ui/sdl2-input.c   | 5 +++++
 ui/sdl2.c         | 1 +
 3 files changed, 7 insertions(+)

diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h
index e3acc7c82a..6907115809 100644
--- a/include/ui/sdl2.h
+++ b/include/ui/sdl2.h
@@ -60,6 +60,7 @@ void sdl2_poll_events(struct sdl2_console *scon);
 
 void sdl2_process_key(struct sdl2_console *scon,
                       SDL_KeyboardEvent *ev);
+void sdl2_release_modifiers(struct sdl2_console *scon);
 
 void sdl2_2d_update(DisplayChangeListener *dcl,
                     int x, int y, int w, int h);
diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c
index b02a89ee7c..2286df4223 100644
--- a/ui/sdl2-input.c
+++ b/ui/sdl2-input.c
@@ -58,3 +58,8 @@ void sdl2_process_key(struct sdl2_console *scon,
         }
     }
 }
+
+void sdl2_release_modifiers(struct sdl2_console *scon)
+{
+    qkbd_state_lift_all_keys(scon->kbd);
+}
diff --git a/ui/sdl2.c b/ui/sdl2.c
index ac37c173a1..9d9a9362cb 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -426,6 +426,7 @@ static void handle_keydown(SDL_Event *ev)
                         SDL_ShowWindow(sdl2_console[win].real_window);
                     }
                 }
+                sdl2_release_modifiers(scon);
                 gui_keysym = 1;
             }
             break;
-- 
2.35.3



  parent reply	other threads:[~2024-09-09  6:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-09  6:12 SDL2 keyboard fixes on Windows Volker Rümelin
2024-09-09  6:15 ` [PATCH 1/3] ui/sdl2: reenable the SDL2 Windows keyboard hook procedure Volker Rümelin
2024-09-09  7:26   ` Marc-André Lureau
2024-09-09  8:02     ` Stefan Weil via
2024-09-09 19:38     ` Volker Rümelin
2024-09-11 11:57       ` Philippe Mathieu-Daudé
2024-09-11 11:59         ` Philippe Mathieu-Daudé
2024-09-11 12:16           ` Bernhard Beschow
2024-12-07 12:46       ` Bernhard Beschow
2024-09-09  6:15 ` Volker Rümelin [this message]
2024-09-09  6:15 ` [PATCH 3/3] ui/sdl2: ignore GUI keys in SDL_TEXTINPUT handler Volker Rümelin
2024-09-11 11:19 ` SDL2 keyboard fixes on Windows Bernhard Beschow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240909061552.6122-2-vr_qemu@t-online.de \
    --to=vr_qemu@t-online.de \
    --cc=hsp.cat7@gmail.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=shentey@gmail.com \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).