Fixed events for windows that have had their window proc hooked at creation time

This commit is contained in:
Sam Lantinga
2025-11-24 19:29:13 -08:00
parent 55a566a6b4
commit 24fe3c48a0
3 changed files with 14 additions and 17 deletions

View File

@@ -2496,11 +2496,6 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
}
}
LRESULT CALLBACK WIN_DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam);
}
int WIN_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS)
{
if (g_WindowsEnableMessageLoop) {
@@ -2804,7 +2799,7 @@ bool SDL_RegisterApp(const char *name, Uint32 style, void *hInst)
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.lpszClassName = SDL_Appname;
wcex.style = SDL_Appstyle;
wcex.lpfnWndProc = WIN_DefWindowProc;
wcex.lpfnWndProc = WIN_WindowProc;
wcex.hInstance = SDL_Instance;
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)

View File

@@ -29,7 +29,6 @@ extern HINSTANCE SDL_Instance;
extern LRESULT CALLBACK WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam);
extern LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
extern LRESULT CALLBACK WIN_DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
extern void WIN_PollRawInput(SDL_VideoDevice *_this, Uint64 poll_start);
extern void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, bool initial_check);
extern void WIN_PumpEvents(SDL_VideoDevice *_this);

View File

@@ -425,19 +425,22 @@ static bool SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwn
window->internal = data;
// Set up the window proc function
if (window->flags & SDL_WINDOW_EXTERNAL) {
#ifdef GWLP_WNDPROC
data->wndproc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC);
if (data->wndproc == WIN_DefWindowProc) {
data->wndproc = NULL;
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)WIN_WindowProc);
}
data->wndproc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC);
if (data->wndproc != WIN_WindowProc) {
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)WIN_WindowProc);
}
#else
data->wndproc = (WNDPROC)GetWindowLong(hwnd, GWL_WNDPROC);
if (data->wndproc == WIN_DefWindowProc) {
data->wndproc = NULL;
SetWindowLong(hwnd, GWL_WNDPROC, (LONG_PTR)WIN_WindowProc);
}
data->wndproc = (WNDPROC)GetWindowLong(hwnd, GWL_WNDPROC);
if (data->wndproc != WIN_WindowProc) {
SetWindowLong(hwnd, GWL_WNDPROC, (LONG_PTR)WIN_WindowProc);
}
#endif
} else {
// We set up our window proc function at window creation.
// If someone has set hooks to modify it, leave it alone.
}
// Fill in the SDL window with the window state
{