mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-31 22:42:52 +08: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)
|
int WIN_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS)
|
||||||
{
|
{
|
||||||
if (g_WindowsEnableMessageLoop) {
|
if (g_WindowsEnableMessageLoop) {
|
||||||
@@ -2754,7 +2759,7 @@ bool SDL_RegisterApp(const char *name, Uint32 style, void *hInst)
|
|||||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||||
wcex.lpszClassName = SDL_Appname;
|
wcex.lpszClassName = SDL_Appname;
|
||||||
wcex.style = SDL_Appstyle;
|
wcex.style = SDL_Appstyle;
|
||||||
wcex.lpfnWndProc = DefWindowProc;
|
wcex.lpfnWndProc = WIN_DefWindowProc;
|
||||||
wcex.hInstance = SDL_Instance;
|
wcex.hInstance = SDL_Instance;
|
||||||
|
|
||||||
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ extern Uint32 SDL_Appstyle;
|
|||||||
extern HINSTANCE SDL_Instance;
|
extern HINSTANCE SDL_Instance;
|
||||||
|
|
||||||
extern LRESULT CALLBACK WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
extern LRESULT CALLBACK WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||||
extern LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam,
|
extern LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
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_PollRawInput(SDL_VideoDevice *_this, Uint64 poll_start);
|
||||||
extern void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, bool initial_check);
|
extern void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, bool initial_check);
|
||||||
extern void WIN_PumpEvents(SDL_VideoDevice *_this);
|
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
|
// Set up the window proc function
|
||||||
#ifdef GWLP_WNDPROC
|
#ifdef GWLP_WNDPROC
|
||||||
data->wndproc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC);
|
data->wndproc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC);
|
||||||
if (data->wndproc == DefWindowProc) {
|
if (data->wndproc == WIN_DefWindowProc) {
|
||||||
data->wndproc = NULL;
|
data->wndproc = NULL;
|
||||||
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)WIN_WindowProc);
|
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)WIN_WindowProc);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
data->wndproc = (WNDPROC)GetWindowLong(hwnd, GWL_WNDPROC);
|
data->wndproc = (WNDPROC)GetWindowLong(hwnd, GWL_WNDPROC);
|
||||||
if (data->wndproc == DefWindowProc) {
|
if (data->wndproc == WIN_DefWindowProc) {
|
||||||
data->wndproc = NULL;
|
data->wndproc = NULL;
|
||||||
SetWindowLong(hwnd, GWL_WNDPROC, (LONG_PTR)WIN_WindowProc);
|
SetWindowLong(hwnd, GWL_WNDPROC, (LONG_PTR)WIN_WindowProc);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user