https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7278ed20159f95550b5bd…
commit 7278ed20159f95550b5bd0468e2be453320f0359
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Wed Sep 28 18:26:44 2022 +0200
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Wed Sep 28 18:31:19 2022 +0200
[WIN32SS] Change LDEVOBJ_bProbeAndCaptureDevmode to account for not provided fields
when searching an exact mode
This fixes mode change if an application requests (for example) 640x480x32, without
providing display frequency.
---
win32ss/gdi/eng/ldevobj.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/win32ss/gdi/eng/ldevobj.c b/win32ss/gdi/eng/ldevobj.c
index 6408c20648f..803cbd37fe1 100644
--- a/win32ss/gdi/eng/ldevobj.c
+++ b/win32ss/gdi/eng/ldevobj.c
@@ -804,9 +804,9 @@ LDEVOBJ_bProbeAndCaptureDevmode(
if (!bResult)
return FALSE;
- if (bSearchClosestMode)
+ if (LDEVOBJ_bGetClosestMode(pGraphicsDevice, &dmSearch, &pdmSelected))
{
- if (LDEVOBJ_bGetClosestMode(pGraphicsDevice, &dmSearch, &pdmSelected))
+ if (bSearchClosestMode)
{
/* Ok, found a closest mode. Update search */
dmSearch.dmBitsPerPel = pdmSelected->dmBitsPerPel;
@@ -814,6 +814,29 @@ LDEVOBJ_bProbeAndCaptureDevmode(
dmSearch.dmPelsHeight = pdmSelected->dmPelsHeight;
dmSearch.dmDisplayFrequency = pdmSelected->dmDisplayFrequency;
}
+ else
+ {
+ /* Only update not provided fields */
+ _SEH2_TRY
+ {
+ if (!(RequestedMode->dmFields & DM_BITSPERPEL) ||
RequestedMode->dmBitsPerPel == 0)
+ dmSearch.dmBitsPerPel = pdmSelected->dmBitsPerPel;
+ if (!(RequestedMode->dmFields & DM_PELSWIDTH) ||
RequestedMode->dmPelsWidth == 0)
+ dmSearch.dmPelsWidth = pdmSelected->dmPelsWidth;
+ if (!(RequestedMode->dmFields & DM_PELSHEIGHT) ||
RequestedMode->dmPelsHeight == 0)
+ dmSearch.dmPelsHeight = pdmSelected->dmPelsHeight;
+ if (!(RequestedMode->dmFields & DM_DISPLAYFREQUENCY) ||
RequestedMode->dmDisplayFrequency == 0)
+ dmSearch.dmDisplayFrequency = pdmSelected->dmDisplayFrequency;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ bResult = FALSE;
+ }
+ _SEH2_END;
+
+ if (!bResult)
+ return FALSE;
+ }
}
/* Now, search the exact mode to return to caller */