[0.4.11][WIN32SS] Fix many regressions of fullscreen switching, all caused by SVN...
authorJoachim Henze <Joachim.Henze@reactos.org>
Wed, 7 Oct 2020 00:32:44 +0000 (02:32 +0200)
committerJoachim Henze <Joachim.Henze@reactos.org>
Wed, 7 Oct 2020 00:32:44 +0000 (02:32 +0200)
CORE-16393 'switching to fullscreen via Alt+Enter in cmd now leaves the taskbar visible'
CORE-15477 'TileWorld 1.3.2 when started in fullscreen mode it now leaves the taskbar visible'
CORE-14979 'It depends on the desktop color-depth bpp whether taskbar is hidden in fullscreen of Anno 1602'
CORE-15599 'Rocks&Diamonds 3.3.1.2 from rapps leaves its taskbar visible when switching into fullscreen via alt+enter'
CORE-15600 'LGeneral from rapps leaves the taskbar visible when selecting fullscreen from context menu'
CORE-15654 'Exiting "Bound Around Demo" from fullscreen leaves black borders around the desktop'

All those cases regressed by SVN r75407 == git
09ab5ea7ed2ab0e709ed2e8f8f9f6c3711b2ac7f

To date I am not aware of more that broke by that historic commit, but we still have some cases that still
do not work as intended, they are linked as blocker against the EPIC CORE-11242.
But at least no regressions known anymore to date by that specific commit into display.c.

In sum this brings us in the context of this regression in this file
for the functions UserChangeDisplaySettings() & NtUserChangeDisplaySettings()
to the state of
- for master:    0.4.14-dev-38-g96ef605
- for 0.4.13rls: 0.4.13-RC-11-g0a03b36
- for 0.4.12rls: 0.4.12-release-4-g8c5e349

win32ss/user/ntuser/display.c

index 2850f41..25ccf76 100644 (file)
@@ -712,9 +712,13 @@ UserChangeDisplaySettings(
         }
     }
     else if (pdm->dmSize < FIELD_OFFSET(DEVMODEW, dmFields))
-        return DISP_CHANGE_BADMODE; /* This is what winXP SP3 returns */
+    {
+        return DISP_CHANGE_BADMODE; /* This is what WinXP SP3 returns */
+    }
     else
+    {
         dm = *pdm;
+    }
 
     /* Save original bit count */
     OrigBC = gpsi->BitCount;
@@ -735,13 +739,13 @@ UserChangeDisplaySettings(
     }
 
     /* Fixup values */
-    if(dm.dmBitsPerPel == 0 || !(dm.dmFields & DM_BITSPERPEL))
+    if (dm.dmBitsPerPel == 0 || !(dm.dmFields & DM_BITSPERPEL))
     {
         dm.dmBitsPerPel = ppdev->pdmwDev->dmBitsPerPel;
         dm.dmFields |= DM_BITSPERPEL;
     }
 
-    if((dm.dmFields & DM_DISPLAYFREQUENCY) && (dm.dmDisplayFrequency == 0))
+    if ((dm.dmFields & DM_DISPLAYFREQUENCY) && (dm.dmDisplayFrequency == 0))
         dm.dmDisplayFrequency = ppdev->pdmwDev->dmDisplayFrequency;
 
     /* Look for the requested DEVMODE */
@@ -779,6 +783,13 @@ UserChangeDisplaySettings(
         }
     }
 
+    /* Check if DEVMODE matches the current mode */
+    if (pdm == ppdev->pdmwDev && !(flags & CDS_RESET))
+    {
+        ERR("DEVMODE matches, nothing to do\n");
+        goto leave;
+    }
+
     /* Shall we apply the settings? */
     if (!(flags & CDS_NORESET))
     {
@@ -796,38 +807,55 @@ UserChangeDisplaySettings(
         pvOldCursor = UserSetCursor(pvOldCursor, TRUE);
         ASSERT(pvOldCursor == NULL);
 
-        /* Check for failure */
+        /* Check for success or failure */
         if (!ulResult)
         {
+            /* Setting mode failed */
             ERR("Failed to set mode\n");
-            lResult = (lResult == DISP_CHANGE_NOTUPDATED) ?
-                DISP_CHANGE_FAILED : DISP_CHANGE_RESTART;
 
-            goto leave;
+            /* Set the correct return value */
+            if ((flags & CDS_UPDATEREGISTRY) && (lResult != DISP_CHANGE_NOTUPDATED))
+                lResult = DISP_CHANGE_RESTART;
+            else
+                lResult = DISP_CHANGE_FAILED;
         }
+        else
+        {
+            /* Setting mode succeeded */
+            lResult = DISP_CHANGE_SUCCESSFUL;
 
-        UserUpdateFullscreen(flags);
+            UserUpdateFullscreen(flags);
 
-        /* Update the system metrics */
-        InitMetrics();
+            /* Update the system metrics */
+            InitMetrics();
 
-        /* Set new size of the monitor */
-        UserUpdateMonitorSize((HDEV)ppdev);
+            /* Set new size of the monitor */
+            UserUpdateMonitorSize((HDEV)ppdev);
 
-        /* Update the SERVERINFO */
-        gpsi->dmLogPixels = ppdev->gdiinfo.ulLogPixelsY;
-        gpsi->Planes      = ppdev->gdiinfo.cPlanes;
-        gpsi->BitsPixel   = ppdev->gdiinfo.cBitsPixel;
-        gpsi->BitCount    = gpsi->Planes * gpsi->BitsPixel;
-        if (ppdev->gdiinfo.flRaster & RC_PALETTE)
-        {
-            gpsi->PUSIFlags |= PUSIF_PALETTEDISPLAY;
+            /* Update the SERVERINFO */
+            gpsi->dmLogPixels = ppdev->gdiinfo.ulLogPixelsY;
+            gpsi->Planes      = ppdev->gdiinfo.cPlanes;
+            gpsi->BitsPixel   = ppdev->gdiinfo.cBitsPixel;
+            gpsi->BitCount    = gpsi->Planes * gpsi->BitsPixel;
+            gpsi->aiSysMet[SM_CXSCREEN] = ppdev->gdiinfo.ulHorzRes;
+            gpsi->aiSysMet[SM_CYSCREEN] = ppdev->gdiinfo.ulVertRes;
+            if (ppdev->gdiinfo.flRaster & RC_PALETTE)
+            {
+                gpsi->PUSIFlags |= PUSIF_PALETTEDISPLAY;
+            }
+            else
+            {
+                gpsi->PUSIFlags &= ~PUSIF_PALETTEDISPLAY;
+            }
+            // Font is realized and this dc was previously set to internal DC_ATTR.
+            gpsi->cxSysFontChar = IntGetCharDimensions(hSystemBM, &tmw, (DWORD*)&gpsi->cySysFontChar);
+            gpsi->tmSysFont     = tmw;
         }
-        else
-            gpsi->PUSIFlags &= ~PUSIF_PALETTEDISPLAY;
-        // Font is realized and this dc was previously set to internal DC_ATTR.
-        gpsi->cxSysFontChar = IntGetCharDimensions(hSystemBM, &tmw, (DWORD*)&gpsi->cySysFontChar);
-        gpsi->tmSysFont     = tmw;
+
+        /*
+         * Refresh the display on success and even on failure,
+         * since the display may have been messed up.
+         */
 
         /* Remove all cursor clipping */
         UserClipCursor(NULL);
@@ -836,20 +864,23 @@ UserChangeDisplaySettings(
         //IntHideDesktop(pdesk);
 
         /* Send WM_DISPLAYCHANGE to all toplevel windows */
-        UserSendNotifyMessage( HWND_BROADCAST,
-                               WM_DISPLAYCHANGE,
-                               gpsi->BitCount,
-                               MAKELONG(gpsi->aiSysMet[SM_CXSCREEN], gpsi->aiSysMet[SM_CYSCREEN]) );
+        co_IntSendMessageTimeout( HWND_BROADCAST,
+                                  WM_DISPLAYCHANGE,
+                                  gpsi->BitCount,
+                                  MAKELONG(gpsi->aiSysMet[SM_CXSCREEN], gpsi->aiSysMet[SM_CYSCREEN]),
+                                  SMTO_NORMAL,
+                                  100,
+                                  &ulResult );
 
         ERR("BitCount New %d Orig %d ChkNew %d\n",gpsi->BitCount,OrigBC,ppdev->gdiinfo.cBitsPixel);
 
         /* Not full screen and different bit count, send messages */
         if (!(flags & CDS_FULLSCREEN) &&
-              gpsi->BitCount != OrigBC )
+            gpsi->BitCount != OrigBC)
         {
-           ERR("Detect settings changed.\n");
-           UserSendNotifyMessage( HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0 );
-           UserSendNotifyMessage( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0 );
+            ERR("Detect settings changed.\n");
+            UserSendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);
+            UserSendNotifyMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0);
         }
 
         //co_IntShowDesktop(pdesk, ppdev->gdiinfo.ulHorzRes, ppdev->gdiinfo.ulVertRes);
@@ -902,6 +933,11 @@ NtUserChangeDisplaySettings(
         return DISP_CHANGE_BADFLAGS;
     }
 
+    if ((dwflags & CDS_RESET) && (dwflags & CDS_NORESET))
+    {
+        return DISP_CHANGE_BADFLAGS;
+    }
+
     /* Copy the device name */
     if (pustrDevice)
     {