mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-02 13:49:21 +00:00
Fixed windows events on 32-bit Windows
When running on 32-bit Windows, DefWindowProc resolves to a function in ntdll.dll, but after the window is created the actual window proc is a function in user32.dll. We solve this by using our own custom default window proc and looking for that instead. Fixes https://github.com/libsdl-org/SDL/issues/1442
This commit is contained in:
@@ -2471,6 +2471,11 @@ 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) {
|
||||
@@ -2754,7 +2759,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 = DefWindowProc;
|
||||
wcex.lpfnWndProc = WIN_DefWindowProc;
|
||||
wcex.hInstance = SDL_Instance;
|
||||
|
||||
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
||||
|
||||
@@ -28,8 +28,8 @@ extern Uint32 SDL_Appstyle;
|
||||
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_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);
|
||||
|
||||
@@ -427,13 +427,13 @@ static bool SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwn
|
||||
// Set up the window proc function
|
||||
#ifdef GWLP_WNDPROC
|
||||
data->wndproc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC);
|
||||
if (data->wndproc == DefWindowProc) {
|
||||
if (data->wndproc == WIN_DefWindowProc) {
|
||||
data->wndproc = NULL;
|
||||
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)WIN_WindowProc);
|
||||
}
|
||||
#else
|
||||
data->wndproc = (WNDPROC)GetWindowLong(hwnd, GWL_WNDPROC);
|
||||
if (data->wndproc == DefWindowProc) {
|
||||
if (data->wndproc == WIN_DefWindowProc) {
|
||||
data->wndproc = NULL;
|
||||
SetWindowLong(hwnd, GWL_WNDPROC, (LONG_PTR)WIN_WindowProc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user