Skip to content

Commit

Permalink
Move PeekMessage() to SetCooperativeLevel()
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Sep 13, 2024
1 parent b5d75d9 commit ebd7690
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 7150
#define BUILD_NUMBER 7151
10 changes: 1 addition & 9 deletions d3d9/IDirect3D9Ex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,6 @@ void UpdatePresentParameter(D3DPRESENT_PARAMETERS* pPresentationParameters, HWND
(IsWindow(pPresentationParameters->hDeviceWindow)) ? pPresentationParameters->hDeviceWindow :
DeviceDetails.DeviceWindow;

// Make sure all windows messages are handled before creating or resetting the device
MSG msg;
if (PeekMessageA(&msg, DeviceDetails.DeviceWindow, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessageA(&msg);
}

// Check if window is minimized
if (IsIconic(DeviceDetails.DeviceWindow))
{
Expand Down Expand Up @@ -599,7 +591,7 @@ void UpdatePresentParameter(D3DPRESENT_PARAMETERS* pPresentationParameters, HWND

void GetFinalPresentParameter(D3DPRESENT_PARAMETERS* pPresentationParameters, DEVICEDETAILS& DeviceDetails)
{
if (IsWindow(pPresentationParameters->hDeviceWindow) || IsWindow(DeviceDetails.DeviceWindow))
if (pPresentationParameters && (IsWindow(pPresentationParameters->hDeviceWindow) || IsWindow(DeviceDetails.DeviceWindow)))
{
DeviceDetails.BufferWidth = (pPresentationParameters->BackBufferWidth) ? pPresentationParameters->BackBufferWidth : DeviceDetails.BufferWidth;
DeviceDetails.BufferHeight = (pPresentationParameters->BackBufferHeight) ? pPresentationParameters->BackBufferHeight : DeviceDetails.BufferHeight;
Expand Down
8 changes: 8 additions & 0 deletions ddraw/IDirectDrawX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,14 @@ HRESULT m_IDirectDrawX::SetCooperativeLevel(HWND hWnd, DWORD dwFlags, DWORD Dire
// The flag (DDSCL_NOWINDOWCHANGES) means DirectDraw is not allowed to minimize or restore the application window on activation.
Device.NoWindowChanges = ((dwFlags & DDSCL_NOWINDOWCHANGES) != 0);

// Make sure all windows messages are handled
MSG msg;
if (PeekMessageA(&msg, DisplayMode.hWnd, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessageA(&msg);
}

// Reset if mode was changed
if ((dwFlags & (DDSCL_NORMAL | DDSCL_EXCLUSIVE)) && (d3d9Device || LastUsedHWnd == DisplayMode.hWnd) &&
(LastExclusiveMode != ExclusiveMode || LasthWnd != DisplayMode.hWnd || LastFPUPreserve != Device.FPUPreserve))
Expand Down

0 comments on commit ebd7690

Please sign in to comment.