From 22a4cb079cbcc9caf6cc2cb18e3e833f7a9a2c1d Mon Sep 17 00:00:00 2001 From: 82ba10b5e8dc <47543507+82ba10b5e8dc@users.noreply.github.com> Date: Tue, 30 Jun 2020 09:41:29 -0700 Subject: [PATCH] Ensure window exits fullscreen before closing (#4376) --- main.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 2558b25338..93b0e61895 100644 --- a/main.js +++ b/main.js @@ -403,7 +403,21 @@ async function createWindow() { // Prevent the shutdown e.preventDefault(); - mainWindow.hide(); + + /** + * if the user is in fullscreen mode and closes the window, not the + * application, we need them leave fullscreen first before closing it to + * prevent a black screen. + * + * issue: https://github.com/signalapp/Signal-Desktop/issues/4348 + */ + + if (mainWindow.isFullScreen()) { + mainWindow.once('leave-full-screen', () => mainWindow.hide()) + mainWindow.setFullScreen(false) + } else { + mainWindow.hide() + } // On Mac, or on other platforms when the tray icon is in use, the window // should be only hidden, not closed, when the user clicks the close button