[WIN32K]
authorJérôme Gardou <jerome.gardou@reactos.org>
Tue, 25 May 2010 20:24:21 +0000 (20:24 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Tue, 25 May 2010 20:24:21 +0000 (20:24 +0000)
  - 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

svn path=/branches/reactos-yarotows/; revision=47353

subsystems/win32/win32k/eng/pdevobj.c
subsystems/win32/win32k/ntuser/display.c

index 9ca4311..a904b4f 100644 (file)
@@ -192,6 +192,7 @@ PDEVOBJ_pdmMatchDevMode(
     PGRAPHICS_DEVICE pGraphicsDevice;
     PDEVMODEW pdmCurrent;
     INT i;
+    DWORD dwFields;
 
     pGraphicsDevice = ppdev->pGraphicsDevice;
 
@@ -199,15 +200,25 @@ PDEVOBJ_pdmMatchDevMode(
     {
         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 @@ PDEVOBJ_vSwitchPdev(
     PPDEVOBJ ppdev2)
 {
     PDEVOBJ pdevTmp;
+    DWORD tmpStateFlags;
 
     /* Exchange data */
     pdevTmp = *ppdev;
@@ -334,7 +346,12 @@ PDEVOBJ_vSwitchPdev(
 
     /* 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 @@ EngpGetPDEV(
             if (!gppdevPrimary)
             {
                 gppdevPrimary = ppdev;
+                ppdev->pGraphicsDevice->StateFlags |= DISPLAY_DEVICE_PRIMARY_DEVICE;
             }
         }
     }
index 5c28c62..25344c4 100644 (file)
@@ -721,6 +721,12 @@ UserChangeDisplaySettings(
         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)