From 7df6a9ea595544184e1306e5927b5dca8fa08766 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 27 Jul 2021 10:44:04 -0700
Subject: [PATCH] Add a test case for bug
https://github.com/libsdl-org/SDL/issues/4469
---
test/testwm2.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/test/testwm2.c b/test/testwm2.c
index 1dc66350d7..30b93bd233 100644
--- a/test/testwm2.c
+++ b/test/testwm2.c
@@ -38,6 +38,7 @@ static const char *cursorNames[] = {
};
int system_cursor = -1;
SDL_Cursor *cursor = NULL;
+SDL_bool relative_mode = SDL_FALSE;
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
static void
@@ -76,6 +77,17 @@ loop()
SDL_GetDisplayName(SDL_GetWindowDisplayIndex(window)));
}
}
+ if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
+ relative_mode = SDL_GetRelativeMouseMode();
+ if (relative_mode) {
+ SDL_SetRelativeMouseMode(SDL_FALSE);
+ }
+ }
+ if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) {
+ if (relative_mode) {
+ SDL_SetRelativeMouseMode(SDL_TRUE);
+ }
+ }
}
if (event.type == SDL_KEYUP) {
SDL_bool updateCursor = SDL_FALSE;