# HG changeset patch # User Ryan C. Gordon # Date 1123722121 0 # Node ID 242a35a858527092d7ae135cfd29d9f69e019ab3 # Parent 39408f59a0f79c895df464f8ff9a8085c7560b07 Patches to make SDL compatible with Win95 again. diff -r 39408f59a0f7 -r 242a35a85852 src/video/windx5/SDL_dx5events.c --- a/src/video/windx5/SDL_dx5events.c Thu Aug 11 00:56:16 2005 +0000 +++ b/src/video/windx5/SDL_dx5events.c Thu Aug 11 01:02:01 2005 +0000 @@ -68,6 +68,19 @@ and give him a chance to handle some messages. */ static WNDPROC userWindowProc = NULL; +static HWND GetTopLevelParent(HWND hWnd) +{ + HWND hParentWnd; + while (1) + { + hParentWnd = GetParent(hWnd); + if (hParentWnd == NULL) + break; + hWnd = hParentWnd; + } + return hWnd; +} + /* Convert a DirectInput return code to a text message */ static void SetDIerror(char *function, int code) { @@ -168,7 +181,7 @@ SetDIerror("DirectInputDevice::QueryInterface", result); return(-1); } - topwnd = GetAncestor(SDL_Window, GA_ROOT); + topwnd = GetTopLevelParent(SDL_Window, GA_ROOT); result = IDirectInputDevice2_SetCooperativeLevel(SDL_DIdev[i], topwnd, inputs[i].win_level); if ( result != DI_OK ) { @@ -652,7 +665,7 @@ level = inputs[i].win_level; } IDirectInputDevice2_Unacquire(SDL_DIdev[i]); - topwnd = GetAncestor(SDL_Window, GA_ROOT); + topwnd = GetTopLevelParent(SDL_Window, GA_ROOT); result = IDirectInputDevice2_SetCooperativeLevel( SDL_DIdev[i], topwnd, level); IDirectInputDevice2_Acquire(SDL_DIdev[i]);