https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a0cfdcd4093a2707d4558…
commit a0cfdcd4093a2707d455880d332d402ac21a649d
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Sun Mar 20 15:38:20 2022 +0100
Commit: hpoussin <32227662+hpoussin(a)users.noreply.github.com>
CommitDate: Fri Apr 15 23:09:16 2022 +0200
[WIN32SS] Introduce the MDEVOBJ structure
This will be used (later) to store the list of all enabled display devices.
Add a global variable gpmdev (should really be stored in DISPLAYINFO structure)
Replace global variable gppdevPrimary by pmdev->ppdevGlobal.
---
win32ss/CMakeLists.txt | 1 +
win32ss/gdi/eng/device.c | 2 +-
win32ss/gdi/eng/engbrush.c | 4 ++--
win32ss/gdi/eng/mdevobj.c | 13 +++++++++++++
win32ss/gdi/eng/mdevobj.h | 17 +++++++++++++++++
win32ss/gdi/eng/pdevobj.c | 16 +++++++---------
win32ss/gdi/eng/pdevobj.h | 5 -----
win32ss/gdi/ntgdi/dclife.c | 2 +-
win32ss/gdi/ntgdi/device.c | 10 +++++-----
win32ss/gdi/ntgdi/gdidbg.c | 1 +
win32ss/user/ntuser/metric.c | 8 ++++----
win32ss/user/ntuser/tags.h | 1 +
win32ss/user/ntuser/win32kdebug.h | 1 +
win32ss/user/ntuser/winsta.c | 15 +++++++++++----
win32ss/win32kp.h | 1 +
15 files changed, 66 insertions(+), 31 deletions(-)
diff --git a/win32ss/CMakeLists.txt b/win32ss/CMakeLists.txt
index 51c8ec4c5f4..a786921291c 100644
--- a/win32ss/CMakeLists.txt
+++ b/win32ss/CMakeLists.txt
@@ -73,6 +73,7 @@ list(APPEND SOURCE
gdi/eng/ldevobj.c
gdi/eng/mapping.c
gdi/eng/math.c
+ gdi/eng/mdevobj.c
gdi/eng/mem.c
gdi/eng/engmisc.c
gdi/eng/mouse.c
diff --git a/win32ss/gdi/eng/device.c b/win32ss/gdi/eng/device.c
index af1c57f2652..d6c38b4c6d4 100644
--- a/win32ss/gdi/eng/device.c
+++ b/win32ss/gdi/eng/device.c
@@ -198,7 +198,7 @@ VideoPortCallout(
if (CallbackParams->Param == TRUE)
{
/* Re-enable the display */
- UserRefreshDisplay(gppdevPrimary);
+ UserRefreshDisplay(gpmdev->ppdevGlobal);
}
else
{
diff --git a/win32ss/gdi/eng/engbrush.c b/win32ss/gdi/eng/engbrush.c
index f57bc4778ec..c520d3a7efc 100644
--- a/win32ss/gdi/eng/engbrush.c
+++ b/win32ss/gdi/eng/engbrush.c
@@ -324,7 +324,7 @@ EBRUSHOBJ_bRealizeBrush(EBRUSHOBJ *pebo, BOOL bCallDriver)
ppdev = (PPDEVOBJ)pebo->psurfTrg->SurfObj.hdev;
if (!ppdev)
- ppdev = gppdevPrimary;
+ ppdev = gpmdev->ppdevGlobal;
if (bCallDriver)
{
@@ -458,7 +458,7 @@ EBRUSHOBJ_psoMask(EBRUSHOBJ *pebo)
/* Get the PDEV */
ppdev = (PPDEVOBJ)pebo->psurfTrg->SurfObj.hdev;
if (!ppdev)
- ppdev = gppdevPrimary;
+ ppdev = gpmdev->ppdevGlobal;
/* Use the hatch bitmap as the mask */
hbmMask = (HBITMAP)ppdev->ahsurf[pebo->pbrush->iHatch];
diff --git a/win32ss/gdi/eng/mdevobj.c b/win32ss/gdi/eng/mdevobj.c
new file mode 100644
index 00000000000..25b85b6e94c
--- /dev/null
+++ b/win32ss/gdi/eng/mdevobj.c
@@ -0,0 +1,13 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * PURPOSE: Support for meta devices
+ * FILE: win32ss/gdi/eng/mdevobj.c
+ * PROGRAMER: Hervé Poussineau
+ */
+
+#include <win32k.h>
+#define NDEBUG
+#include <debug.h>
+
+PMDEVOBJ gpmdev = NULL; /* FIXME: should be stored in gpDispInfo->pmdev */
diff --git a/win32ss/gdi/eng/mdevobj.h b/win32ss/gdi/eng/mdevobj.h
new file mode 100644
index 00000000000..1d687d436a4
--- /dev/null
+++ b/win32ss/gdi/eng/mdevobj.h
@@ -0,0 +1,17 @@
+#ifndef __WIN32K_MDEVOBJ_H
+#define __WIN32K_MDEVOBJ_H
+
+/* Type definitions ***********************************************************/
+
+typedef struct _PDEVOBJ *PPDEVOBJ;
+
+typedef struct _MDEVOBJ
+{
+ PPDEVOBJ ppdevGlobal;
+} MDEVOBJ, *PMDEVOBJ;
+
+/* Globals ********************************************************************/
+
+extern PMDEVOBJ gpmdev; /* FIXME: should be stored in gpDispInfo->pmdev */
+
+#endif /* !__WIN32K_MDEVOBJ_H */
diff --git a/win32ss/gdi/eng/pdevobj.c b/win32ss/gdi/eng/pdevobj.c
index 6cc941dabd3..a24a8c05dee 100644
--- a/win32ss/gdi/eng/pdevobj.c
+++ b/win32ss/gdi/eng/pdevobj.c
@@ -11,8 +11,6 @@
#include <debug.h>
DBG_DEFAULT_CHANNEL(EngPDev);
-PPDEVOBJ gppdevPrimary = NULL;
-
static PPDEVOBJ gppdevList = NULL;
static HSEMAPHORE ghsemPDEV;
@@ -150,8 +148,8 @@ PDEVOBJ_vRelease(
}
/* Is this the primary one ? */
- if (ppdev == gppdevPrimary)
- gppdevPrimary = NULL;
+ if (ppdev == gpmdev->ppdevGlobal)
+ gpmdev->ppdevGlobal = NULL;
/* Unload display driver */
EngUnloadImage(ppdev->pldev);
@@ -615,7 +613,7 @@ PDEVOBJ_bSwitchMode(
PDEVOBJ_vRelease(ppdevTmp);
/* Update primary display capabilities */
- if (ppdev == gppdevPrimary)
+ if (ppdev == gpmdev->ppdevGlobal)
{
PDEVOBJ_vGetDeviceCaps(ppdev, &GdiHandleTable->DevCaps);
}
@@ -669,10 +667,10 @@ EngpGetPDEV(
}
}
}
- else
+ else if (gpmdev)
{
/* Otherwise use the primary PDEV */
- ppdev = gppdevPrimary;
+ ppdev = gpmdev->ppdevGlobal;
}
/* Did we find one? */
@@ -695,9 +693,9 @@ EngpGetPDEV(
if (ppdev)
{
/* Set as primary PDEV, if we don't have one yet */
- if (!gppdevPrimary)
+ if (!gpmdev->ppdevGlobal)
{
- gppdevPrimary = ppdev;
+ gpmdev->ppdevGlobal = ppdev;
ppdev->pGraphicsDevice->StateFlags |=
DISPLAY_DEVICE_PRIMARY_DEVICE;
}
}
diff --git a/win32ss/gdi/eng/pdevobj.h b/win32ss/gdi/eng/pdevobj.h
index fbd17f4a2cd..5590ac9548f 100644
--- a/win32ss/gdi/eng/pdevobj.h
+++ b/win32ss/gdi/eng/pdevobj.h
@@ -150,11 +150,6 @@ typedef struct _PDEVOBJ
struct _EDD_DIRECTDRAW_GLOBAL * pEDDgpl;
} PDEVOBJ, *PPDEVOBJ;
-/* Globals ********************************************************************/
-
-extern PPDEVOBJ gppdevPrimary;
-
-
/* Function prototypes ********************************************************/
PPDEVOBJ
diff --git a/win32ss/gdi/ntgdi/dclife.c b/win32ss/gdi/ntgdi/dclife.c
index 2a405ee7a93..caa66eda073 100644
--- a/win32ss/gdi/ntgdi/dclife.c
+++ b/win32ss/gdi/ntgdi/dclife.c
@@ -144,7 +144,7 @@ DC_vInitDc(
pdc->pdcattr = &pdc->dcattr;
pdc->dcattr.pvLDC = NULL;
pdc->dcattr.ulDirty_ = DIRTY_DEFAULT;
- if (ppdev == gppdevPrimary)
+ if (ppdev == gpmdev->ppdevGlobal)
pdc->dcattr.ulDirty_ |= DC_PRIMARY_DISPLAY;
/* Setup the DC size */
diff --git a/win32ss/gdi/ntgdi/device.c b/win32ss/gdi/ntgdi/device.c
index 9b1ca91bcdb..9a8bf433374 100644
--- a/win32ss/gdi/ntgdi/device.c
+++ b/win32ss/gdi/ntgdi/device.c
@@ -29,13 +29,13 @@ BOOL FASTCALL
IntCreatePrimarySurface(VOID)
{
/* Create surface */
- PDEVOBJ_pSurface(gppdevPrimary);
+ PDEVOBJ_pSurface(gpmdev->ppdevGlobal);
- DPRINT("IntCreatePrimarySurface, gppdevPrimary=%p, gppdevPrimary->pSurface =
%p\n",
- gppdevPrimary, gppdevPrimary->pSurface);
+ DPRINT("IntCreatePrimarySurface, ppdevGlobal=%p, ppdevGlobal->pSurface =
%p\n",
+ gpmdev->ppdevGlobal, gpmdev->ppdevGlobal->pSurface);
// Init Primary Displays Device Capabilities.
- PDEVOBJ_vGetDeviceCaps(gppdevPrimary, &GdiHandleTable->DevCaps);
+ PDEVOBJ_vGetDeviceCaps(gpmdev->ppdevGlobal, &GdiHandleTable->DevCaps);
return TRUE;
}
@@ -51,7 +51,7 @@ IntEnumHDev(VOID)
{
// I guess we will soon have more than one primary surface.
// This will do for now.
- return gppdevPrimary;
+ return gpmdev->ppdevGlobal;
}
diff --git a/win32ss/gdi/ntgdi/gdidbg.c b/win32ss/gdi/ntgdi/gdidbg.c
index b75bb01c986..51de52670b8 100644
--- a/win32ss/gdi/ntgdi/gdidbg.c
+++ b/win32ss/gdi/ntgdi/gdidbg.c
@@ -32,6 +32,7 @@ DBG_CHANNEL DbgChannels[DbgChCount] = {
{L"EngLDev", DbgChEngLDev},
{L"EngLine", DbgChEngLine},
{L"EngMapping", DbgChEngMapping},
+ {L"EngMDev", DbgChEngMDev},
{L"EngPDev", DbgChEngPDev},
{L"EngSurface", DbgChEngSurface},
{L"EngWnd", DbgChEngWnd},
diff --git a/win32ss/user/ntuser/metric.c b/win32ss/user/ntuser/metric.c
index 35f840d5d6a..a50d10df4c8 100644
--- a/win32ss/user/ntuser/metric.c
+++ b/win32ss/user/ntuser/metric.c
@@ -47,16 +47,16 @@ InitMetrics(VOID)
ZwClose(hKey);
}
- /* FIXME: HACK, due to missing PDEV on first init */
- if (!gppdevPrimary)
+ /* FIXME: HACK, due to missing MDEV on first init */
+ if (!gpmdev)
{
Width = 640;
Height = 480;
}
else
{
- Width = gppdevPrimary->gdiinfo.ulHorzRes;
- Height = gppdevPrimary->gdiinfo.ulVertRes;
+ Width = gpmdev->ppdevGlobal->gdiinfo.ulHorzRes;
+ Height = gpmdev->ppdevGlobal->gdiinfo.ulVertRes;
}
/* Screen sizes */
diff --git a/win32ss/user/ntuser/tags.h b/win32ss/user/ntuser/tags.h
index 0cce9da16ff..f644b930d8c 100644
--- a/win32ss/user/ntuser/tags.h
+++ b/win32ss/user/ntuser/tags.h
@@ -71,6 +71,7 @@
#define GDITAG_DC_FREELIST 'fcdG'
#define GDITAG_DWMSTATE 'scDG'
#define GDITAG_DEVMODE 'vedG'
+#define GDITAG_MDEV 'vdmG'
#define GDITAG_PDEV 'veDG'
#define GDITAG_HGLYPH_ARRAY 'mfdG'
#define GDITAG_DRVSUP 'srdG'
diff --git a/win32ss/user/ntuser/win32kdebug.h b/win32ss/user/ntuser/win32kdebug.h
index 1211994a00d..48175854401 100644
--- a/win32ss/user/ntuser/win32kdebug.h
+++ b/win32ss/user/ntuser/win32kdebug.h
@@ -53,6 +53,7 @@
DbgChEngLDev,
DbgChEngLine,
DbgChEngMapping,
+ DbgChEngMDev,
DbgChEngPDev,
DbgChEngSurface,
DbgChEngWnd,
diff --git a/win32ss/user/ntuser/winsta.c b/win32ss/user/ntuser/winsta.c
index 16e4f3c40b9..ba1db88a6bd 100644
--- a/win32ss/user/ntuser/winsta.c
+++ b/win32ss/user/ntuser/winsta.c
@@ -263,6 +263,13 @@ co_IntInitializeDesktopGraphics(VOID)
UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"DISPLAY");
PDESKTOP pdesk;
+ gpmdev = ExAllocatePoolZero(PagedPool, sizeof(MDEVOBJ), GDITAG_MDEV);
+ if (!gpmdev)
+ {
+ ERR("Failed to allocate MDEV.\n");
+ return FALSE;
+ }
+
ScreenDeviceContext = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE);
if (NULL == ScreenDeviceContext)
{
@@ -285,11 +292,11 @@ co_IntInitializeDesktopGraphics(VOID)
InitMetrics();
/* Set new size of the monitor */
- UserUpdateMonitorSize((HDEV)gppdevPrimary);
+ UserUpdateMonitorSize((HDEV)gpmdev->ppdevGlobal);
/* Update the SERVERINFO */
- gpsi->aiSysMet[SM_CXSCREEN] = gppdevPrimary->gdiinfo.ulHorzRes;
- gpsi->aiSysMet[SM_CYSCREEN] = gppdevPrimary->gdiinfo.ulVertRes;
+ gpsi->aiSysMet[SM_CXSCREEN] = gpmdev->ppdevGlobal->gdiinfo.ulHorzRes;
+ gpsi->aiSysMet[SM_CYSCREEN] = gpmdev->ppdevGlobal->gdiinfo.ulVertRes;
gpsi->Planes = NtGdiGetDeviceCaps(ScreenDeviceContext, PLANES);
gpsi->BitsPixel = NtGdiGetDeviceCaps(ScreenDeviceContext, BITSPIXEL);
gpsi->BitCount = gpsi->Planes * gpsi->BitsPixel;
@@ -311,7 +318,7 @@ co_IntInitializeDesktopGraphics(VOID)
gpsi->ptCursor.y = gpsi->aiSysMet[SM_CYSCREEN] / 2;
/* Attach monitor */
- UserAttachMonitor((HDEV)gppdevPrimary);
+ UserAttachMonitor((HDEV)gpmdev->ppdevGlobal);
/* Setup the cursor */
co_IntLoadDefaultCursors();
diff --git a/win32ss/win32kp.h b/win32ss/win32kp.h
index a336c2fe42c..e8f401d35c2 100644
--- a/win32ss/win32kp.h
+++ b/win32ss/win32kp.h
@@ -23,6 +23,7 @@ typedef struct _DC *PDC;
#include "gdi/ntgdi/gdiobj.h"
#include "gdi/ntgdi/palette.h"
#include "gdi/eng/surface.h"
+#include "gdi/eng/mdevobj.h"
#include "gdi/eng/pdevobj.h"
#include "gdi/eng/ldevobj.h"
#include "gdi/eng/device.h"