[WIN32SS] Remember the last process that changed the displaymode with CDS_FULLSCREEN...
authorMark Jansen <mark.jansen@reactos.org>
Sun, 5 Jun 2016 11:16:02 +0000 (11:16 +0000)
committerMark Jansen <mark.jansen@reactos.org>
Sun, 5 Jun 2016 11:16:02 +0000 (11:16 +0000)
svn path=/trunk/; revision=71529

reactos/win32ss/user/ntuser/display.c
reactos/win32ss/user/ntuser/main.c

index 7b6a753..5c44f2a 100644 (file)
@@ -10,6 +10,7 @@
 DBG_DEFAULT_CHANNEL(UserDisplay);
 
 BOOL gbBaseVideo = 0;
+static PPROCESSINFO gpFullscreen = NULL;
 
 static const PWCHAR KEY_VIDEO = L"\\Registry\\Machine\\HARDWARE\\DEVICEMAP\\VIDEO";
 
@@ -650,6 +651,16 @@ NtUserEnumDisplaySettings(
     return Status;
 }
 
+VOID
+UserUpdateFullscreen(
+    DWORD flags)
+{
+    if (flags & CDS_FULLSCREEN)
+        gpFullscreen = gptiCurrent->ppi;
+    else
+        gpFullscreen = NULL;
+}
+
 LONG
 APIENTRY
 UserChangeDisplaySettings(
@@ -774,6 +785,8 @@ UserChangeDisplaySettings(
             goto leave;
         }
 
+        UserUpdateFullscreen(flags);
+
         /* Update the system metrics */
         InitMetrics();
 
@@ -809,6 +822,18 @@ leave:
     return lResult;
 }
 
+VOID
+UserDisplayNotifyShutdown(
+    PPROCESSINFO ppiCurrent)
+{
+    if (ppiCurrent == gpFullscreen)
+    {
+        UserChangeDisplaySettings(NULL, NULL, 0, NULL);
+        if (gpFullscreen)
+            ERR("Failed to restore display mode!\n");
+    }
+}
+
 LONG
 APIENTRY
 NtUserChangeDisplaySettings(
index 0da71f8..f274273 100644 (file)
@@ -677,6 +677,9 @@ error:
     return Status;
 }
 
+VOID
+UserDisplayNotifyShutdown(PPROCESSINFO ppiCurrent);
+
 NTSTATUS
 NTAPI
 ExitThreadCallback(PETHREAD Thread)
@@ -806,6 +809,11 @@ ExitThreadCallback(PETHREAD Thread)
        gptiForeground = NULL;
     }
 
+    /* Restore display mode when we are the last thread, and we changed the display mode */
+    if (ppiCurrent->cThreads == 0)
+        UserDisplayNotifyShutdown(ppiCurrent);
+
+
     // Fixes CORE-6384 & CORE-7030.
 /*    if (ptiLastInput == ptiCurrent)
     {