https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c5fb89dced1da2ed4d6be…
commit c5fb89dced1da2ed4d6bedd478e417ef385cd71b
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Sun Jan 9 11:33:38 2022 +0100
Commit: hpoussin <32227662+hpoussin(a)users.noreply.github.com>
CommitDate: Fri Apr 15 23:09:16 2022 +0200
[WIN32SS] Add PDEVOBJ_vEnableDisplay and PDEVOBJ_bDisplayDisplay
Use them where appropriate.
---
win32ss/gdi/eng/pdevobj.c | 48 +++++++++++++++++++++++++++++++++++++++++------
win32ss/gdi/eng/pdevobj.h | 8 ++++++++
2 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/win32ss/gdi/eng/pdevobj.c b/win32ss/gdi/eng/pdevobj.c
index 1bf060dbec2..f6b58b1dd8d 100644
--- a/win32ss/gdi/eng/pdevobj.c
+++ b/win32ss/gdi/eng/pdevobj.c
@@ -276,6 +276,45 @@ PDEVOBJ_pSurface(
return ppdev->pSurface;
}
+VOID
+PDEVOBJ_vEnableDisplay(
+ _Inout_ PPDEVOBJ ppdev)
+{
+ BOOL assertVal;
+
+ if (!(ppdev->flFlags & PDEV_DISABLED))
+ return;
+
+ /* Try to enable display until success */
+ do
+ {
+ TRACE("DrvAssertMode(dhpdev %p, TRUE)\n", ppdev->dhpdev);
+ assertVal = ppdev->pfn.AssertMode(ppdev->dhpdev, TRUE);
+ TRACE("DrvAssertMode(dhpdev %p, TRUE) => %d\n", ppdev->dhpdev,
assertVal);
+ } while (!assertVal);
+
+ ppdev->flFlags &= ~PDEV_DISABLED;
+}
+
+BOOL
+PDEVOBJ_bDisableDisplay(
+ _Inout_ PPDEVOBJ ppdev)
+{
+ BOOL assertVal;
+
+ if (ppdev->flFlags & PDEV_DISABLED)
+ return TRUE;
+
+ TRACE("DrvAssertMode(dhpdev %p, FALSE)\n", ppdev->dhpdev);
+ assertVal = ppdev->pfn.AssertMode(ppdev->dhpdev, FALSE);
+ TRACE("DrvAssertMode(dhpdev %p, FALSE) => %d\n", ppdev->dhpdev,
assertVal);
+
+ if (assertVal)
+ ppdev->flFlags |= PDEV_DISABLED;
+
+ return assertVal;
+}
+
VOID
NTAPI
PDEVOBJ_vRefreshModeList(
@@ -509,9 +548,9 @@ PDEVOBJ_bSwitchMode(
// pdm = LDEVOBJ_bProbeAndCaptureDevmode(ppdev, pdm);
/* 1. Temporarily disable the current PDEV and reset video to its default mode */
- if (!ppdev->pfn.AssertMode(ppdev->dhpdev, FALSE))
+ if (!PDEVOBJ_bDisableDisplay(ppdev))
{
- DPRINT1("DrvAssertMode(FALSE) failed\n");
+ DPRINT1("PDEVOBJ_bDisableDisplay() failed\n");
goto leave;
}
@@ -560,10 +599,7 @@ PDEVOBJ_bSwitchMode(
leave2:
/* Set the new video mode, or restore the original one in case of failure */
- if (!ppdev->pfn.AssertMode(ppdev->dhpdev, TRUE))
- {
- DPRINT1("DrvAssertMode(TRUE) failed\n");
- }
+ PDEVOBJ_vEnableDisplay(ppdev);
leave:
/* Unlock everything else */
diff --git a/win32ss/gdi/eng/pdevobj.h b/win32ss/gdi/eng/pdevobj.h
index 4943c994d29..c9fdd3252c1 100644
--- a/win32ss/gdi/eng/pdevobj.h
+++ b/win32ss/gdi/eng/pdevobj.h
@@ -219,4 +219,12 @@ PDEVOBJ_bDynamicModeChange(
_Inout_ PPDEVOBJ ppdev,
_Inout_ PPDEVOBJ ppdev2);
+VOID
+PDEVOBJ_vEnableDisplay(
+ _Inout_ PPDEVOBJ ppdev);
+
+BOOL
+PDEVOBJ_bDisableDisplay(
+ _Inout_ PPDEVOBJ ppdev);
+
#endif /* !__WIN32K_PDEVOBJ_H */