SDL: Remove the SDL_EVENT_WINDOW_TAKE_FOCUS event

From 74cc06db1b0ee0db89e18afc1c6d6e771bafff61 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Wed, 3 Jul 2024 11:39:59 -0400
Subject: [PATCH] Remove the SDL_EVENT_WINDOW_TAKE_FOCUS event

This was added by the Unreal Engine to handle the input focus for popups and dialogs, window types for which SDL3 has built-in, cross-platform support.

This was only ever implemented in X11, and the only purpose was to hint that a client application may want to call the SDL_SetWindowInputFocus() function, which has since been removed, rendering it pointless now.
---
 docs/README-migration.md      | 4 +++-
 include/SDL3/SDL_events.h     | 1 -
 src/events/SDL_events.c       | 1 -
 src/test/SDL_test_common.c    | 3 ---
 src/video/x11/SDL_x11events.c | 9 ---------
 5 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/docs/README-migration.md b/docs/README-migration.md
index 82f6cdc4f7091..61411ded21e6e 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -2008,10 +2008,12 @@ The following symbols have been renamed:
 * SDL_WINDOWEVENT_RESTORED => SDL_EVENT_WINDOW_RESTORED
 * SDL_WINDOWEVENT_SHOWN => SDL_EVENT_WINDOW_SHOWN
 * SDL_WINDOWEVENT_SIZE_CHANGED => SDL_EVENT_WINDOW_SIZE_CHANGED
-* SDL_WINDOWEVENT_TAKE_FOCUS => SDL_EVENT_WINDOW_TAKE_FOCUS
 * SDL_WINDOW_ALLOW_HIGHDPI => SDL_WINDOW_HIGH_PIXEL_DENSITY
 * SDL_WINDOW_INPUT_GRABBED => SDL_WINDOW_MOUSE_GRABBED
 
+The following symbols have been removed:
+* SDL_WINDOWEVENT_TAKE_FOCUS
+
 The following window operations are now considered to be asynchronous requests and should not be assumed to succeed unless
 a corresponding event has been received:
 * SDL_SetWindowSize() (SDL_EVENT_WINDOW_RESIZED)
diff --git a/include/SDL3/SDL_events.h b/include/SDL3/SDL_events.h
index dafc544f500cb..678ce88d19cb1 100644
--- a/include/SDL3/SDL_events.h
+++ b/include/SDL3/SDL_events.h
@@ -136,7 +136,6 @@ typedef enum SDL_EventType
     SDL_EVENT_WINDOW_FOCUS_GAINED,      /**< Window has gained keyboard focus */
     SDL_EVENT_WINDOW_FOCUS_LOST,        /**< Window has lost keyboard focus */
     SDL_EVENT_WINDOW_CLOSE_REQUESTED,   /**< The window manager requests that the window be closed */
-    SDL_EVENT_WINDOW_TAKE_FOCUS,        /**< Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore) */
     SDL_EVENT_WINDOW_HIT_TEST,          /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL */
     SDL_EVENT_WINDOW_ICCPROF_CHANGED,   /**< The ICC profile of the window's display has changed */
     SDL_EVENT_WINDOW_DISPLAY_CHANGED,   /**< Window has been moved to display data1 */
diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c
index 6df6b9cd3badd..20a5aa97da08e 100644
--- a/src/events/SDL_events.c
+++ b/src/events/SDL_events.c
@@ -317,7 +317,6 @@ static void SDL_LogEvent(const SDL_Event *event)
         SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_FOCUS_GAINED);
         SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_FOCUS_LOST);
         SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_CLOSE_REQUESTED);
-        SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_TAKE_FOCUS);
         SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_HIT_TEST);
         SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_ICCPROF_CHANGED);
         SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_DISPLAY_CHANGED);
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 0a6f3b30ed13a..584c06c3777f6 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1635,9 +1635,6 @@ static void SDLTest_PrintEvent(const SDL_Event *event)
     case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
         SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " closed", event->window.windowID);
         break;
-    case SDL_EVENT_WINDOW_TAKE_FOCUS:
-        SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " take focus", event->window.windowID);
-        break;
     case SDL_EVENT_WINDOW_HIT_TEST:
         SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " hit test", event->window.windowID);
         break;
diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c
index daf6d9379881b..3831c4fcbf035 100644
--- a/src/video/x11/SDL_x11events.c
+++ b/src/video/x11/SDL_x11events.c
@@ -1425,15 +1425,6 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent)
 #endif
             SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_CLOSE_REQUESTED, 0, 0);
             break;
-        } else if ((xevent->xclient.message_type == videodata->WM_PROTOCOLS) &&
-                   (xevent->xclient.format == 32) &&
-                   (xevent->xclient.data.l[0] == videodata->WM_TAKE_FOCUS)) {
-
-#ifdef DEBUG_XEVENTS
-            printf("window %p: WM_TAKE_FOCUS\n", data);
-#endif
-            SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_TAKE_FOCUS, 0, 0);
-            break;
         }
     } break;