Author: tkreuzer
Date: Sat Oct 15 21:22:19 2011
New Revision: 54151
URL:
http://svn.reactos.org/svn/reactos?rev=54151&view=rev
Log:
[WIN32K]
- Fix a bug when iterating through the DEVMODE list
- Handle VgaCompatible flag differently, by reading this value from the registry for every
installed driver.
- Priorize non-vga compatible devices over vga compatible, unless /BASEVIDEO is requested
- Fall back to vga compatible driver when no other is present
Modified:
trunk/reactos/subsystems/win32/win32k/eng/device.c
trunk/reactos/subsystems/win32/win32k/include/pdevobj.h
trunk/reactos/subsystems/win32/win32k/ntuser/display.c
Modified: trunk/reactos/subsystems/win32/win32k/eng/device.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/en…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/eng/device.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/eng/device.c [iso-8859-1] Sat Oct 15 21:22:19
2011
@@ -151,7 +151,7 @@
/* Loop all DEVMODEs */
pdmEnd = (DEVMODEW*)((PCHAR)pdminfo->adevmode + pdminfo->cbdevmode);
for (pdm = pdminfo->adevmode;
- pdm + 1 <= pdmEnd;
+ (pdm + 1 <= pdmEnd) && (pdm->dmSize != 0);
pdm = (DEVMODEW*)((PCHAR)pdm + pdm->dmSize + pdm->dmDriverExtra))
{
/* Count this DEVMODE */
@@ -195,7 +195,7 @@
/* Loop through the DEVMODEs */
for (pdm = pdminfo->adevmode;
- pdm + 1 <= pdmEnd;
+ (pdm + 1 <= pdmEnd) && (pdm->dmSize != 0);
pdm = (PDEVMODEW)((PCHAR)pdm + pdm->dmSize + pdm->dmDriverExtra))
{
/* Compare with the default entry */
Modified: trunk/reactos/subsystems/win32/win32k/include/pdevobj.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/pdevobj.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/pdevobj.h [iso-8859-1] Sat Oct 15
21:22:19 2011
@@ -44,7 +44,7 @@
DEVMODEW adevmode[1];
} DEVMODEINFO, *PDEVMODEINFO;
-typedef struct
+typedef struct _DEVMODEENTRY
{
DWORD dwFlags;
PDEVMODEW pdm;
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/display.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] Sat Oct 15
21:22:19 2011
@@ -74,6 +74,7 @@
ULONG cbSize;
HKEY hkey;
DEVMODEW dmDefault;
+ DWORD dwVga;
ERR("InitDisplayDriver(%S, %S);\n",
pwszDeviceName, pwszRegKey);
@@ -128,6 +129,11 @@
/* Query the default settings */
RegReadDisplaySettings(hkey, &dmDefault);
+ /* Query if this is a VGA compatible driver */
+ cbSize = sizeof(DWORD);
+ Status = RegQueryValue(hkey, L"VgaCompatible", REG_DWORD, &dwVga,
&cbSize);
+ if (!NT_SUCCESS(Status)) dwVga = 0;
+
/* Close the registry key */
ZwClose(hkey);
@@ -137,6 +143,10 @@
&ustrDisplayDrivers,
&ustrDescription,
&dmDefault);
+ if (pGraphicsDevice && dwVga)
+ {
+ pGraphicsDevice->StateFlags |= DISPLAY_DEVICE_VGA_COMPATIBLE;
+ }
return pGraphicsDevice;
}
@@ -197,7 +207,7 @@
ERR("Could not read MaxObjectNumber, defaulting to 0.\n");
}
- TRACE("Found %ld devices\n", ulMaxObjectNumber);
+ TRACE("Found %ld devices\n", ulMaxObjectNumber + 1);
/* Loop through all adapters */
for (iDevNum = 0; iDevNum <= ulMaxObjectNumber; iDevNum++)
@@ -218,31 +228,30 @@
pGraphicsDevice = InitDisplayDriver(awcDeviceName, awcBuffer);
if (!pGraphicsDevice) continue;
- /* Check if this is the VGA adapter */
- if (iDevNum == iVGACompatible)
- {
- /* Set the VGA device as primary */
- gpVgaGraphicsDevice = pGraphicsDevice;
- ERR("gpVgaGraphicsDevice = %p\n", gpVgaGraphicsDevice);
- }
-
- /* Set the first one as primary device */
- if (!gpPrimaryGraphicsDevice)
- gpPrimaryGraphicsDevice = pGraphicsDevice;
+ /* Check if this is a VGA compatible adapter */
+ if (pGraphicsDevice->StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE)
+ {
+ /* Save this as the VGA adapter */
+ if (!gpVgaGraphicsDevice)
+ gpVgaGraphicsDevice = pGraphicsDevice;
+ TRACE("gpVgaGraphicsDevice = %p\n", gpVgaGraphicsDevice);
+ }
+ else
+ {
+ /* Set the first one as primary device */
+ if (!gpPrimaryGraphicsDevice)
+ gpPrimaryGraphicsDevice = pGraphicsDevice;
+ TRACE("gpPrimaryGraphicsDevice = %p\n", gpPrimaryGraphicsDevice);
+ }
}
/* Close the device map registry key */
ZwClose(hkey);
- /* Check if we had any success */
- if (!gpPrimaryGraphicsDevice)
- {
- ERR("No usable display driver was found.\n");
- return STATUS_UNSUCCESSFUL;
- }
-
+ /* Was VGA mode requested? */
if (gbBaseVideo)
{
+ /* Check if we found a VGA compatible device */
if (gpVgaGraphicsDevice)
{
/* Set the VgaAdapter as primary */
@@ -252,6 +261,22 @@
else
{
ERR("Could not find VGA compatible driver. Trying normal.\n");
+ }
+ }
+
+ /* Check if we had any success */
+ if (!gpPrimaryGraphicsDevice)
+ {
+ /* Check if there is a VGA device we skipped */
+ if (gpVgaGraphicsDevice)
+ {
+ /* There is, use the VGA device */
+ gpPrimaryGraphicsDevice = gpVgaGraphicsDevice;
+ }
+ else
+ {
+ ERR("No usable display driver was found.\n");
+ return STATUS_UNSUCCESSFUL;
}
}