From: alaanourali@gmail.com
To: barebox@lists.infradead.org
Cc: A.fatoum@barebox.org, Alaa Ali <alaanourali@gmail.com>
Subject: [PATCH] Fix unresponsive SDL GUI by handling SDL_QUIT events
Date: Sun, 27 Oct 2024 11:17:53 +0300 [thread overview]
Message-ID: <20241027081753.256921-1-alaanourali@gmail.com> (raw)
From: Alaa Ali <alaanourali@gmail.com>
The SDL GUI in the scanout function can appear unresponsive to the
operating system, as it lacks an event handler. This patch adds a
new function, handle_sdl_events(), which processes SDL events to
ensure the window can respond to close requests.
This addresses issues where Linux might think the SDL window is
unresponsive, allowing it to handle SDL_QUIT events properly and
initiate shutdown.
Signed-off-by: Alaa Ali <alaanourali@gmail.com>
---
arch/sandbox/os/sdl.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/sandbox/os/sdl.c b/arch/sandbox/os/sdl.c
index 13178abfc0..0fc281b7b8 100644
--- a/arch/sandbox/os/sdl.c
+++ b/arch/sandbox/os/sdl.c
@@ -13,6 +13,15 @@ static void sdl_perror(const char *what)
printf("SDL: Could not %s: %s.\n", what, SDL_GetError());
}
+static void handle_sdl_events(void)
+{
+ SDL_Event event;
+ while (SDL_PollEvent(&event)) {
+ if (event.type == SDL_QUIT)
+ SDL_AtomicSet(&shutdown, true);
+ }
+}
+
static struct sdl_fb_info info;
static SDL_atomic_t shutdown;
SDL_Window *window;
@@ -47,6 +56,7 @@ static int scanout(void *ptr)
while (!SDL_AtomicGet(&shutdown)) {
SDL_Delay(100);
+ handle_sdl_events(); /* Handle events like window close */
SDL_UpdateTexture(texture, NULL, buf, surface->pitch);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
--
2.43.0
next reply other threads:[~2024-10-27 8:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-27 8:17 alaanourali [this message]
2024-10-27 9:35 ` Ahmad Fatoum
2024-10-28 12:30 ` Sascha Hauer
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=20241027081753.256921-1-alaanourali@gmail.com \
--to=alaanourali@gmail.com \
--cc=A.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/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