SDL: Support dark theme for tray menus on Windows

From b6dc44b1335804936f0bfcaa9763930c0a4f8164 Mon Sep 17 00:00:00 2001
From: Semphris <[EMAIL REDACTED]>
Date: Sat, 4 Jan 2025 13:41:12 -0500
Subject: [PATCH] Support dark theme for tray menus on Windows

---
 src/tray/windows/SDL_tray.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/tray/windows/SDL_tray.c b/src/tray/windows/SDL_tray.c
index 125daa10ff6a5..5b123e343d14e 100644
--- a/src/tray/windows/SDL_tray.c
+++ b/src/tray/windows/SDL_tray.c
@@ -23,6 +23,7 @@
 
 #include "../SDL_tray_utils.h"
 #include "../../core/windows/SDL_windows.h"
+#include "../../video/windows/SDL_windowswindow.h"
 
 #include <windowsx.h>
 #include <shellapi.h>
@@ -130,6 +131,12 @@ LRESULT CALLBACK TrayWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
             }
             break;
 
+        case WM_SETTINGCHANGE:
+            if (wParam == 0 && lParam != 0 && SDL_wcscmp((wchar_t *)lParam, L"ImmersiveColorSet") == 0) {
+                WIN_UpdateDarkModeForHWND(hwnd);
+            }
+            break;
+
         default:
             return DefWindowProc(hwnd, uMsg, wParam, lParam);
     }
@@ -193,6 +200,8 @@ SDL_Tray *SDL_CreateTray(SDL_Surface *icon, const char *tooltip)
     tray->hwnd = CreateWindowEx(0, TEXT("Message"), NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL);
     SetWindowLongPtr(tray->hwnd, GWLP_WNDPROC, (LONG_PTR) TrayWindowProc);
 
+    WIN_UpdateDarkModeForHWND(tray->hwnd);
+
     SDL_zero(tray->nid);
     tray->nid.cbSize = sizeof(NOTIFYICONDATAW);
     tray->nid.hWnd = tray->hwnd;