[WIN32K]
authorThomas Faber <thomas.faber@reactos.org>
Mon, 17 Apr 2017 20:25:55 +0000 (20:25 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Mon, 17 Apr 2017 20:25:55 +0000 (20:25 +0000)
Fix automatic resolution change when resizing the VirtualBox window. Based on a patch by Ismael Ferreras Morezuelas.
- Provide a function, PDEVOBJ_vRefreshModeList, to reload the list of display modes
- Call PDEVOBJ_vRefreshModeList from UserEnumDisplaySettings to get an updated list of modes each time
CORE-6742 #resolve

svn path=/trunk/; revision=74360

reactos/win32ss/gdi/eng/device.h
reactos/win32ss/gdi/eng/pdevobj.c
reactos/win32ss/user/ntuser/display.c

index 35ac63a..c035441 100644 (file)
@@ -3,6 +3,11 @@
 
 #define TAG_GDEV 'gdev'
 
+VOID
+NTAPI
+PDEVOBJ_vRefreshModeList(
+    PPDEVOBJ ppdev);
+
 extern PGRAPHICS_DEVICE gpPrimaryGraphicsDevice;
 extern PGRAPHICS_DEVICE gpVgaGraphicsDevice;
 
index 823c946..5847f3b 100644 (file)
@@ -258,6 +258,45 @@ PDEVOBJ_pSurface(
     return ppdev->pSurface;
 }
 
+VOID
+NTAPI
+PDEVOBJ_vRefreshModeList(
+    PPDEVOBJ ppdev)
+{
+    PGRAPHICS_DEVICE pGraphicsDevice;
+    PDEVMODEINFO pdminfo, pdmiNext;
+    DEVMODEW dmDefault;
+
+    /* Lock the PDEV */
+    EngAcquireSemaphore(ppdev->hsemDevLock);
+
+    pGraphicsDevice = ppdev->pGraphicsDevice;
+
+    /* Remember our default mode */
+    dmDefault = *pGraphicsDevice->pDevModeList[pGraphicsDevice->iDefaultMode].pdm;
+
+    /* Clear out the modes */
+    for (pdminfo = pGraphicsDevice->pdevmodeInfo;
+         pdminfo;
+         pdminfo = pdmiNext)
+    {
+        pdmiNext = pdminfo->pdmiNext;
+        ExFreePoolWithTag(pdminfo, GDITAG_DEVMODE);
+    }
+    pGraphicsDevice->pdevmodeInfo = NULL;
+    ExFreePoolWithTag(pGraphicsDevice->pDevModeList, GDITAG_GDEVICE);
+    pGraphicsDevice->pDevModeList = NULL;
+
+    /* Now re-populate the list */
+    if (!EngpPopulateDeviceModeList(pGraphicsDevice, &dmDefault))
+    {
+        DPRINT1("FIXME: EngpPopulateDeviceModeList failed, we just destroyed a perfectly good mode list\n");
+    }
+
+    /* Unlock PDEV */
+    EngReleaseSemaphore(ppdev->hsemDevLock);
+}
+
 PDEVMODEW
 NTAPI
 PDEVOBJ_pdmMatchDevMode(
index e63f38a..4414be6 100644 (file)
@@ -463,20 +463,28 @@ UserEnumDisplaySettings(
     PGRAPHICS_DEVICE pGraphicsDevice;
     PDEVMODEENTRY pdmentry;
     ULONG i, iFoundMode;
+    PPDEVOBJ ppdev;
 
     TRACE("Enter UserEnumDisplaySettings('%wZ', %lu)\n",
           pustrDevice, iModeNum);
 
     /* Ask GDI for the GRAPHICS_DEVICE */
     pGraphicsDevice = EngpFindGraphicsDevice(pustrDevice, 0, 0);
+    ppdev = EngpGetPDEV(pustrDevice);
 
-    if (!pGraphicsDevice)
+    if (!pGraphicsDevice || !ppdev)
     {
         /* No device found */
         ERR("No device found!\n");
         return STATUS_INVALID_PARAMETER_1;
     }
 
+    /* let's politely ask the driver for an updated mode list,
+       just in case there's something new in there (vbox) */
+
+    PDEVOBJ_vRefreshModeList(ppdev);
+    PDEVOBJ_vRelease(ppdev);
+
     iFoundMode = 0;
     for (i = 0; i < pGraphicsDevice->cDevModes; i++)
     {