Author: jgardou
Date: Tue May 25 22:24:21 2010
New Revision: 47353
URL: 
http://svn.reactos.org/svn/reactos?rev=47353&view=rev
Log:
[WIN32K]
  - Set DISPLAY_DEVICE_PRIMARY_DEVICE to Graphics device object when creating the primary
device object
  - switch state flags of the graphics device objects when switching mode
  - Only compare valid fields when searching for a device mode in a device object
  - implement CDS_TEST flag in NtUserSetDisplaySettings
Modified:
    branches/reactos-yarotows/subsystems/win32/win32k/eng/pdevobj.c
    branches/reactos-yarotows/subsystems/win32/win32k/ntuser/display.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/pdevobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/eng/pdevobj.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/eng/pdevobj.c [iso-8859-1] Tue May
25 22:24:21 2010
@@ -192,6 +192,7 @@
     PGRAPHICS_DEVICE pGraphicsDevice;
     PDEVMODEW pdmCurrent;
     INT i;
+    DWORD dwFields;
     pGraphicsDevice = ppdev->pGraphicsDevice;
@@ -199,15 +200,25 @@
     {
         pdmCurrent = pGraphicsDevice->pDevModeList[i].pdm;
-        /* Compare DEVMODE fields */
-        if (pdmCurrent->dmBitsPerPel == pdm->dmBitsPerPel &&
-            pdmCurrent->dmPelsWidth == pdm->dmPelsWidth &&
-            pdmCurrent->dmPelsHeight == pdm->dmPelsHeight &&
-            pdmCurrent->dmDisplayFrequency == pdm->dmDisplayFrequency)
-        {
-            /* Match! Return the DEVMODE */
-            return pdmCurrent;
-        }
+        /* Compare asked DEVMODE fields
+         * Only compare those that are valid in both DEVMODE structs */
+        dwFields = pdmCurrent->dmFields & pdm->dmFields ;
+        /* For now, we only need those */
+        if ((dwFields & DM_BITSPERPEL) &&
+                (pdmCurrent->dmBitsPerPel != pdm->dmBitsPerPel))
+            continue;
+        if ((dwFields & DM_PELSWIDTH) &&
+                (pdmCurrent->dmPelsWidth != pdm->dmPelsWidth))
+            continue;
+        if ((dwFields & DM_PELSHEIGHT) &&
+                (pdmCurrent->dmPelsHeight != pdm->dmPelsHeight))
+            continue;
+        if ((dwFields & DM_DISPLAYFREQUENCY) &&
+                (pdmCurrent->dmDisplayFrequency != pdm->dmDisplayFrequency))
+            continue;
+
+        /* Match! Return the DEVMODE */
+        return pdmCurrent;
     }
     /* Nothing found */
@@ -302,6 +313,7 @@
     PPDEVOBJ ppdev2)
 {
     PDEVOBJ pdevTmp;
+    DWORD tmpStateFlags;
     /* Exchange data */
     pdevTmp = *ppdev;
@@ -334,7 +346,12 @@
     /* Exchange DEVMODE */
     ppdev->pdmwDev = ppdev2->pdmwDev;
-    ppdev2->pdmwDev = pdevTmp.pdmwDev ;
+    ppdev2->pdmwDev = pdevTmp.pdmwDev;
+
+    /* Exchange state flags */
+    tmpStateFlags = ppdev->pGraphicsDevice->StateFlags;
+    ppdev->pGraphicsDevice->StateFlags = ppdev2->pGraphicsDevice->StateFlags;
+    ppdev2->pGraphicsDevice->StateFlags = tmpStateFlags;
     /* Notify each driver instance of its new HDEV association */
     ppdev->pfn.CompletePDEV(ppdev->dhpdev, (HDEV)ppdev);
@@ -471,6 +488,7 @@
             if (!gppdevPrimary)
             {
                 gppdevPrimary = ppdev;
+                ppdev->pGraphicsDevice->StateFlags |=
DISPLAY_DEVICE_PRIMARY_DEVICE;
             }
         }
     }
Modified: branches/reactos-yarotows/subsystems/win32/win32k/ntuser/display.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/ntuser/display.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] Tue
May 25 22:24:21 2010
@@ -721,6 +721,12 @@
         lResult = DISP_CHANGE_BADMODE;
         goto leave;
     }
+    else if (flags & CDS_TEST)
+    {
+        /* It's possible, go ahead! */
+        lResult = DISP_CHANGE_SUCCESSFUL;
+        goto leave;
+    }
     /* Shall we update the registry? */
     if (flags & CDS_UPDATEREGISTRY)