From f40a530fd9fcdea79986de12d305426c0304d60e Mon Sep 17 00:00:00 2001
From: expikr <[EMAIL REDACTED]>
Date: Wed, 25 Dec 2024 03:01:04 +0800
Subject: [PATCH] subclass the builtin system message class instead
---
src/tray/windows/SDL_tray.c | 28 ++--------------------------
1 file changed, 2 insertions(+), 26 deletions(-)
diff --git a/src/tray/windows/SDL_tray.c b/src/tray/windows/SDL_tray.c
index a09a086ca4af0..e2823a1c8832c 100644
--- a/src/tray/windows/SDL_tray.c
+++ b/src/tray/windows/SDL_tray.c
@@ -183,26 +183,6 @@ static wchar_t *convert_label(const char *in)
return out;
}
-static void register_tray_window_class(void)
-{
- static bool init = false;
-
- if (init) {
- return;
- }
-
- HINSTANCE hInstance = GetModuleHandle(NULL);
- WNDCLASSW wc;
- ZeroMemory(&wc, sizeof(WNDCLASS));
- wc.lpfnWndProc = TrayWindowProc;
- wc.hInstance = hInstance;
- wc.lpszClassName = L"SDLTrayRunner";
-
- RegisterClassW(&wc);
-
- init = true;
-}
-
SDL_Tray *SDL_CreateTray(SDL_Surface *icon, const char *tooltip)
{
SDL_Tray *tray = SDL_malloc(sizeof(SDL_Tray));
@@ -211,13 +191,9 @@ SDL_Tray *SDL_CreateTray(SDL_Surface *icon, const char *tooltip)
return NULL;
}
- tray->hwnd = NULL;
tray->menu = NULL;
-
- register_tray_window_class();
-
- HINSTANCE hInstance = GetModuleHandle(NULL);
- tray->hwnd = CreateWindowExW(0, L"SDLTrayRunner", NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, hInstance, NULL);
+ 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);
ZeroMemory(&tray->nid, sizeof(NOTIFYICONDATAW));
tray->nid.cbSize = sizeof(NOTIFYICONDATAW);