Skip to content

Commit

Permalink
Prepare display resolution before creating device
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Oct 1, 2024
1 parent d526321 commit f1937f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 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 7223
#define BUILD_NUMBER 7224
18 changes: 13 additions & 5 deletions ddraw/IDirectDrawX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3125,21 +3125,29 @@ HRESULT m_IDirectDrawX::CreateD9Device(char* FunctionName)
ReleaseD9Device();

// Reset display mode after release
if (presParams.Windowed && DisplayMode.Width == CurrentWidth && DisplayMode.Height == CurrentHeight && IsWindow(DisplayMode.hWnd))
if (presParams.Windowed && DisplayMode.Width == CurrentWidth && DisplayMode.Height == CurrentHeight)
{
Utils::SetDisplaySettings(DisplayMode.hWnd, DisplayMode.Width, DisplayMode.Height);
Utils::SetDisplaySettings(hWnd, DisplayMode.Width, DisplayMode.Height);
}
}
}

// Create d3d9 Device
if (!d3d9Device)
{
// Prepare window size
if (!presParams.Windowed)
// Prepare window and display size
if (!presParams.Windowed && !Config.EnableWindowMode)
{
DWORD DisplayWidth = 0, DisplayHeight = 0;
Utils::GetScreenSize(hWnd, (LONG&)DisplayWidth, (LONG&)DisplayHeight);

if (presParams.BackBufferWidth > DisplayWidth || presParams.BackBufferHeight > DisplayHeight)
{
Utils::SetDisplaySettings(hWnd, presParams.BackBufferWidth, presParams.BackBufferHeight);
}

SetWindowPos(hWnd, ((GetWindowLong(hWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) ? HWND_TOPMOST : HWND_TOP),
0, 0, presParams.BackBufferWidth, presParams.BackBufferHeight, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER);
0, 0, presParams.BackBufferWidth, presParams.BackBufferHeight, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOREPOSITION | SWP_NOMOVE | SWP_NOREDRAW);
}

// Check window handle thread
Expand Down

0 comments on commit f1937f0

Please sign in to comment.